diff --git a/CMakeLists.txt b/CMakeLists.txt
index d964ad64..b5ea0522 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,6 +96,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${MY_CMAKE_FLAGS}")
+add_definitions(-DDISABLE_OBJ_POOL)
#set(MY_CMAKE_POOL_FLAG " -DPOOL_TESTING -DUSE_VALGRIND")
#add_definitions(-DPOOL_TESTING)
#add_definitions(-DLS_WORKCREW_DEBUG)
diff --git a/LSQUICCOMMIT b/LSQUICCOMMIT
index e93306e8..9ef0f299 100644
--- a/LSQUICCOMMIT
+++ b/LSQUICCOMMIT
@@ -1 +1 @@
-497ec21d1605aeaaa21fb2e67066d7d47e3d916d
+e237d779199dab262c54d104238006efa9abd766
diff --git a/dist/add-ons/webcachemgr/VERSION b/dist/add-ons/webcachemgr/VERSION
index 66060a1f..a86adafd 100644
--- a/dist/add-ons/webcachemgr/VERSION
+++ b/dist/add-ons/webcachemgr/VERSION
@@ -1 +1 @@
-1.13.11.1
\ No newline at end of file
+1.13.13.1
\ No newline at end of file
diff --git a/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php b/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php
index d8982b55..43a38b89 100644
--- a/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php
+++ b/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php
@@ -4,7 +4,7 @@
* LiteSpeed Web Server Cache Manager
*
* @author LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
- * @copyright (c) 2017-2021
+ * @copyright (c) 2017-2022
* ******************************************* */
namespace Lsc\Wp\Panel;
@@ -36,7 +36,7 @@ abstract class ControlPanel
/**
* @var string
*/
- const PANEL_API_VERSION = '1.13.11.1';
+ const PANEL_API_VERSION = '1.13.13.1';
/**
* @since 1.9
@@ -986,6 +986,9 @@ public static function meetsMinAPIVerRequirement()
public static function checkPanelAPICompatibility( $panelAPIVer )
{
$supportedAPIVers = array(
+ '1.13.13.1',
+ '1.13.13',
+ '1.13.12',
'1.13.11.1',
'1.13.11',
'1.13.10.2',
diff --git a/dist/add-ons/webcachemgr/src/Panel/CustomPanel.php b/dist/add-ons/webcachemgr/src/Panel/CustomPanel.php
index c92fc463..1380cbd1 100644
--- a/dist/add-ons/webcachemgr/src/Panel/CustomPanel.php
+++ b/dist/add-ons/webcachemgr/src/Panel/CustomPanel.php
@@ -9,7 +9,7 @@
namespace Lsc\Wp\Panel;
-use \Lsc\Wp\WPInstall;
+use Lsc\Wp\WPInstall;
class CustomPanel
extends CustomPanelBase
diff --git a/dist/add-ons/webcachemgr/src/PluginVersion.php b/dist/add-ons/webcachemgr/src/PluginVersion.php
index 74ddc270..e7c40d54 100644
--- a/dist/add-ons/webcachemgr/src/PluginVersion.php
+++ b/dist/add-ons/webcachemgr/src/PluginVersion.php
@@ -4,7 +4,7 @@
* LiteSpeed Web Server Cache Manager
*
* @author LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
- * @copyright (c) 2018-2020
+ * @copyright (c) 2018-2022
* *******************************************
*/
@@ -416,17 +416,19 @@ protected function refreshVersionList( $isforced = false )
if ( $isforced || !file_exists($this->versionFile)
|| (time() - filemtime($this->versionFile)) > 86400 ) {
- $content = Util::get_url_contents($versionsUrl);
-
- if ( !empty($content) ) {
+ if ( !file_exists(Context::LOCAL_PLUGIN_DIR) ) {
+ $this->createDownloadDir();
+ }
- if ( !file_exists(Context::LOCAL_PLUGIN_DIR) ) {
- $this->createDownloadDir();
- }
+ $content = Util::get_url_contents($versionsUrl);
+ if ( !empty($content) && substr($content, 0, 7) == 'allowed' ) {
file_put_contents($this->versionFile, $content);
Logger::info('LSCache for WordPress version list updated');
}
+ else {
+ touch($this->versionFile);
+ }
}
}
diff --git a/dist/add-ons/webcachemgr/src/Util.php b/dist/add-ons/webcachemgr/src/Util.php
index 1465a89a..db07060e 100644
--- a/dist/add-ons/webcachemgr/src/Util.php
+++ b/dist/add-ons/webcachemgr/src/Util.php
@@ -466,4 +466,70 @@ public static function rrmdir( $dir, $keepParent = false )
return false;
}
+ /**
+ * Wrapper for idn_to_utf8() function call to avoid "undefined" exceptions
+ * when PHP intl module is not installed and enabled.
+ *
+ * @since 1.13.13.1
+ *
+ * @param string $domain
+ * @param int $flags
+ * @param int|null $variant
+ * @param array|null $idna_info
+ *
+ * @return false|string
+ */
+ public static function tryIdnToUtf8(
+ $domain,
+ $flags = 0,
+ $variant = null,
+ array &$idna_info = null )
+ {
+ if ( function_exists('idn_to_utf8') ) {
+
+ if ( $variant == null ) {
+ $variant = INTL_IDNA_VARIANT_UTS46;
+ }
+
+ return idn_to_utf8($domain, $flags, $variant, $idna_info);
+ }
+
+ return $domain;
+ }
+
+ /**
+ * Wrapper for idn_to_ascii() function call to avoid "undefined" exceptions
+ * when PHP intl module is not installed and enabled.
+ *
+ * @since 1.13.13.1
+ *
+ * @param string $domain
+ * @param int|null $flags
+ * @param int|null $variant
+ * @param array|null $idna_info
+ *
+ * @return false|string
+ */
+ public static function tryIdnToAscii(
+ $domain,
+ $flags = null,
+ $variant = null,
+ array &$idna_info = null )
+ {
+ if ( function_exists('idn_to_ascii') ) {
+
+ if ($flags = null ) {
+ $flags = IDNA_DEFAULT;
+ }
+
+ if ( $variant == null ) {
+ $variant = INTL_IDNA_VARIANT_UTS46;
+ }
+
+ return idn_to_ascii($domain, $flags, $variant, $idna_info);
+ }
+
+ return $domain;
+ }
+
}
diff --git a/dist/add-ons/webcachemgr/src/View/Model/Ajax/CacheMgrRowViewModel.php b/dist/add-ons/webcachemgr/src/View/Model/Ajax/CacheMgrRowViewModel.php
index 63da7bd0..86c12cd8 100644
--- a/dist/add-ons/webcachemgr/src/View/Model/Ajax/CacheMgrRowViewModel.php
+++ b/dist/add-ons/webcachemgr/src/View/Model/Ajax/CacheMgrRowViewModel.php
@@ -11,6 +11,7 @@
use \Lsc\Wp\Context\Context;
use \Lsc\Wp\LSCMException;
use \Lsc\Wp\PluginVersion;
+use Lsc\Wp\Util;
use \Lsc\Wp\WPInstall;
class CacheMgrRowViewModel
@@ -79,7 +80,9 @@ protected function setListRowData()
'statusData' =>
$this->getStatusDisplayData(),
'flagData' => $this->getFlagDisplayData(),
- 'siteUrl' => $this->wpInstall->getData(WPInstall::FLD_SITEURL)
+ 'siteUrl' => Util::tryIdnToUtf8(
+ $this->wpInstall->getData(WPInstall::FLD_SITEURL)
+ )
);
$listData[$this->wpInstall->getPath()] = $info;
diff --git a/dist/add-ons/webcachemgr/src/View/Model/ManageViewModel.php b/dist/add-ons/webcachemgr/src/View/Model/ManageViewModel.php
index da2911c0..de4c649b 100644
--- a/dist/add-ons/webcachemgr/src/View/Model/ManageViewModel.php
+++ b/dist/add-ons/webcachemgr/src/View/Model/ManageViewModel.php
@@ -10,6 +10,7 @@
namespace Lsc\Wp\View\Model;
use \Lsc\Wp\Context\Context;
+use Lsc\Wp\Util;
use \Lsc\Wp\WPInstallStorage;
use \Lsc\Wp\WPInstall;
use \Lsc\Wp\PluginVersion;
@@ -255,7 +256,9 @@ protected function setListAndCountData()
$this->getStatusDisplayData($wpInstall, $countData),
'flagData' =>
$this->getFlagDisplayData($wpInstall, $countData),
- 'siteUrl' => $wpInstall->getData(WPInstall::FLD_SITEURL)
+ 'siteUrl' => Util::tryIdnToUtf8(
+ $wpInstall->getData(WPInstall::FLD_SITEURL)
+ )
);
$listData[$wpInstall->getPath()] = $info;
diff --git a/dist/add-ons/webcachemgr/src/WPInstall.php b/dist/add-ons/webcachemgr/src/WPInstall.php
index f2309381..25add354 100644
--- a/dist/add-ons/webcachemgr/src/WPInstall.php
+++ b/dist/add-ons/webcachemgr/src/WPInstall.php
@@ -192,7 +192,7 @@ public function __toString()
$this->path,
$this->data[self::FLD_STATUS],
$this->data[self::FLD_DOCROOT],
- $this->data[self::FLD_SITEURL]
+ Util::tryIdnToUtf8($this->data[self::FLD_SITEURL])
);
}
@@ -231,7 +231,10 @@ public function getServerName()
*/
public function setServerName( $serverName )
{
- return $this->setData(self::FLD_SERVERNAME, $serverName);
+ return $this->setData(
+ self::FLD_SERVERNAME,
+ Util::tryIdnToAscii($serverName)
+ );
}
/**
@@ -243,7 +246,10 @@ public function setServerName( $serverName )
*/
public function setSiteUrlDirect( $siteUrl )
{
- return $this->setData(self::FLD_SITEURL, $siteUrl);
+ return $this->setData(
+ self::FLD_SITEURL,
+ Util::tryIdnToAscii($siteUrl)
+ );
}
/**
@@ -464,10 +470,11 @@ public function populateDataFromUrl( $url )
$info = parse_url($parseSafeUrl);
- $serverName = strtolower($info['host']);
+ $serverName = Util::tryIdnToAscii($info['host']);
+
$this->setData(self::FLD_SERVERNAME, $serverName);
- $siteUrlTrim = $info['host'];
+ $siteUrlTrim = $serverName;
if ( isset($info['path']) ) {
$siteUrlTrim .= $info['path'];
@@ -482,8 +489,8 @@ public function populateDataFromUrl( $url )
$this->setStatus(self::ST_ERR_DOCROOT);
$this->addUserFlagFile(false);
- $msg = "{$this->path} - Could not find matching document root for "
- . "WP siteurl/servername {$serverName}.";
+ $msg = "$this->path - Could not find matching document root for "
+ . "WP siteurl/servername $serverName.";
$this->setCmdStatusAndMsg(UserCommand::EXIT_ERROR, $msg);
Logger::error($msg);
diff --git a/dist/docs/AdminGeneral_Help.html b/dist/docs/AdminGeneral_Help.html
index d2076dec..055657ae 100644
--- a/dist/docs/AdminGeneral_Help.html
+++ b/dist/docs/AdminGeneral_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/AdminListeners_General_Help.html b/dist/docs/AdminListeners_General_Help.html
index 594d7b88..4cc294d9 100644
--- a/dist/docs/AdminListeners_General_Help.html
+++ b/dist/docs/AdminListeners_General_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/AdminListeners_SSL_Help.html b/dist/docs/AdminListeners_SSL_Help.html
index 7337be24..4d8df640 100644
--- a/dist/docs/AdminListeners_SSL_Help.html
+++ b/dist/docs/AdminListeners_SSL_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/AdminSecurity_Help.html b/dist/docs/AdminSecurity_Help.html
index 913072c2..27a9920e 100644
--- a/dist/docs/AdminSecurity_Help.html
+++ b/dist/docs/AdminSecurity_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/App_Server_Context.html b/dist/docs/App_Server_Context.html
index 052e9bf1..f93674aa 100644
--- a/dist/docs/App_Server_Context.html
+++ b/dist/docs/App_Server_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/App_Server_Help.html b/dist/docs/App_Server_Help.html
index 9138f000..a689df9f 100644
--- a/dist/docs/App_Server_Help.html
+++ b/dist/docs/App_Server_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/CGI_Context.html b/dist/docs/CGI_Context.html
index 6e1972d6..93346f75 100644
--- a/dist/docs/CGI_Context.html
+++ b/dist/docs/CGI_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/CompilePHP_Help.html b/dist/docs/CompilePHP_Help.html
index dc50282c..8fa51928 100644
--- a/dist/docs/CompilePHP_Help.html
+++ b/dist/docs/CompilePHP_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Context_Help.html b/dist/docs/Context_Help.html
index e5b41f3f..1da699af 100644
--- a/dist/docs/Context_Help.html
+++ b/dist/docs/Context_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/ExtApp_Help.html b/dist/docs/ExtApp_Help.html
index bfb8fa8d..1a9c3b68 100644
--- a/dist/docs/ExtApp_Help.html
+++ b/dist/docs/ExtApp_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/External_FCGI.html b/dist/docs/External_FCGI.html
index 521b7bfb..f2495f8d 100644
--- a/dist/docs/External_FCGI.html
+++ b/dist/docs/External_FCGI.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/External_FCGI_Auth.html b/dist/docs/External_FCGI_Auth.html
index 9a738d2d..32eb7d32 100644
--- a/dist/docs/External_FCGI_Auth.html
+++ b/dist/docs/External_FCGI_Auth.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/External_LB.html b/dist/docs/External_LB.html
index 5a482dca..65212a55 100644
--- a/dist/docs/External_LB.html
+++ b/dist/docs/External_LB.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/External_LSAPI.html b/dist/docs/External_LSAPI.html
index 5b1cc8ac..cd5093c9 100644
--- a/dist/docs/External_LSAPI.html
+++ b/dist/docs/External_LSAPI.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/External_PL.html b/dist/docs/External_PL.html
index 6cb127e4..bba8ee3a 100644
--- a/dist/docs/External_PL.html
+++ b/dist/docs/External_PL.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/External_Servlet.html b/dist/docs/External_Servlet.html
index 3dca3b0b..e09f0403 100644
--- a/dist/docs/External_Servlet.html
+++ b/dist/docs/External_Servlet.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/External_WS.html b/dist/docs/External_WS.html
index ac682372..3018a257 100644
--- a/dist/docs/External_WS.html
+++ b/dist/docs/External_WS.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/FCGI_Context.html b/dist/docs/FCGI_Context.html
index dbff7d51..225f6b0e 100644
--- a/dist/docs/FCGI_Context.html
+++ b/dist/docs/FCGI_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Java_Web_App_Context.html b/dist/docs/Java_Web_App_Context.html
index 96b896f8..e267111c 100644
--- a/dist/docs/Java_Web_App_Context.html
+++ b/dist/docs/Java_Web_App_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/LB_Context.html b/dist/docs/LB_Context.html
index 99d0ea69..7ff7c744 100644
--- a/dist/docs/LB_Context.html
+++ b/dist/docs/LB_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/LSAPI_Context.html b/dist/docs/LSAPI_Context.html
index ce46b33e..1eeb1014 100644
--- a/dist/docs/LSAPI_Context.html
+++ b/dist/docs/LSAPI_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Listeners_General_Help.html b/dist/docs/Listeners_General_Help.html
index 2746482e..faec6393 100644
--- a/dist/docs/Listeners_General_Help.html
+++ b/dist/docs/Listeners_General_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Listeners_SSL_Help.html b/dist/docs/Listeners_SSL_Help.html
index c6b423f9..d958f0c6 100644
--- a/dist/docs/Listeners_SSL_Help.html
+++ b/dist/docs/Listeners_SSL_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Module_Context.html b/dist/docs/Module_Context.html
index d88a987c..ea871995 100644
--- a/dist/docs/Module_Context.html
+++ b/dist/docs/Module_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Module_Help.html b/dist/docs/Module_Help.html
index bdbc336c..a5646a4c 100644
--- a/dist/docs/Module_Help.html
+++ b/dist/docs/Module_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Proxy_Context.html b/dist/docs/Proxy_Context.html
index 6d027146..3ce4549b 100644
--- a/dist/docs/Proxy_Context.html
+++ b/dist/docs/Proxy_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Redirect_Context.html b/dist/docs/Redirect_Context.html
index a1927770..f01cbcb7 100644
--- a/dist/docs/Redirect_Context.html
+++ b/dist/docs/Redirect_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Rewrite_Help.html b/dist/docs/Rewrite_Help.html
index b261b2d8..7beaf942 100644
--- a/dist/docs/Rewrite_Help.html
+++ b/dist/docs/Rewrite_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/ScriptHandler_Help.html b/dist/docs/ScriptHandler_Help.html
index 5534e80d..6eb222df 100644
--- a/dist/docs/ScriptHandler_Help.html
+++ b/dist/docs/ScriptHandler_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/ServGeneral_Help.html b/dist/docs/ServGeneral_Help.html
index 93583367..4c64f87e 100644
--- a/dist/docs/ServGeneral_Help.html
+++ b/dist/docs/ServGeneral_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/ServLog_Help.html b/dist/docs/ServLog_Help.html
index 2b796e12..22c4cbe6 100644
--- a/dist/docs/ServLog_Help.html
+++ b/dist/docs/ServLog_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/ServSecurity_Help.html b/dist/docs/ServSecurity_Help.html
index 26e5a89f..de0cef90 100644
--- a/dist/docs/ServSecurity_Help.html
+++ b/dist/docs/ServSecurity_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/ServTuning_Help.html b/dist/docs/ServTuning_Help.html
index c19da377..f827c34a 100644
--- a/dist/docs/ServTuning_Help.html
+++ b/dist/docs/ServTuning_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/ServerStat_Help.html b/dist/docs/ServerStat_Help.html
index 69498bf7..c35dcfc8 100644
--- a/dist/docs/ServerStat_Help.html
+++ b/dist/docs/ServerStat_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Servlet_Context.html b/dist/docs/Servlet_Context.html
index 4fa38dbf..6f44ba22 100644
--- a/dist/docs/Servlet_Context.html
+++ b/dist/docs/Servlet_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Static_Context.html b/dist/docs/Static_Context.html
index cb55d8a4..38c5110d 100644
--- a/dist/docs/Static_Context.html
+++ b/dist/docs/Static_Context.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/Templates_Help.html b/dist/docs/Templates_Help.html
index e0b83bb3..6083f545 100644
--- a/dist/docs/Templates_Help.html
+++ b/dist/docs/Templates_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
@@ -121,7 +121,7 @@ Table of Contents
Description
A unique name for the template.
Description
Specifies the path to the configuration file of this template. The file must be located within $SERVER_ROOT/conf/templates/ with a ".conf" filename. If the file you designate does not exist, after trying to save the template an error will appear with the link "CLICK TO CREATE". This link will generate a new empty template file. When you delete the template, the entry will be removed from your configurations, but the actual template config file will not be deleted.
Syntax
path
@@ -133,7 +133,7 @@ Table of Contents
Default Virtual Host Root⇑
Description
Specifies the default root directory for member virtual hosts using this template. Variable $VH_NAME must appear in the path. This will allow each member template to be automatically assigned a separate root directory based on its name.
Syntax
path
Instantiated VHost Config File⇑
Description
Specifies the location of the config file generated when you instantiate a member virtual host. Variable $VH_NAME must appear in the path so each virtual host will have its own file. Must be located under $SERVER_ROOT/conf/vhosts/. This config file will be created only after you move a member vhost out of the template through instantiation.
Syntax
String with $VH_NAME variable and .conf suffix
Tips
$VH_NAME/vhconf.conf is recommended for easy management.
Description
Specifies the unique path for each member virtual host's document root. Variable $VH_NAME or $VH_ROOT must appear in the path so each member virtual host will have its own document root.
Syntax
path with $VH_NAME or $VH_ROOT variable
Example
$VH_ROOT/public_html/ or $SERVER_ROOT/$VH_NAME/public_html.
-File Name Used In Template⇑
Description
Specifies a path for the file to be used for member virtual hosts. Variable $VH_NAME or $VH_ROOT must appear in the path so each member virtual host will have its own file.
Syntax
string
+Description
Specifies the unique path for each member virtual host's configuration file. Variable $VH_NAME or $VH_ROOT must appear in the path so each member virtual host will have its own configuration file.
Syntax
path with $VH_NAME or $VH_ROOT variable
diff --git a/dist/docs/VHGeneral_Help.html b/dist/docs/VHGeneral_Help.html
index d096ae72..c2fc189a 100644
--- a/dist/docs/VHGeneral_Help.html
+++ b/dist/docs/VHGeneral_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/VHSSL_Help.html b/dist/docs/VHSSL_Help.html
index 6c14d205..3462b040 100644
--- a/dist/docs/VHSSL_Help.html
+++ b/dist/docs/VHSSL_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/VHSecurity_Help.html b/dist/docs/VHSecurity_Help.html
index ceb047ee..a5a3311e 100644
--- a/dist/docs/VHSecurity_Help.html
+++ b/dist/docs/VHSecurity_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/VHWebSocket_Help.html b/dist/docs/VHWebSocket_Help.html
index f96b1cad..fe078b69 100644
--- a/dist/docs/VHWebSocket_Help.html
+++ b/dist/docs/VHWebSocket_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/VirtualHosts_Help.html b/dist/docs/VirtualHosts_Help.html
index 2d4baa86..96dcecec 100644
--- a/dist/docs/VirtualHosts_Help.html
+++ b/dist/docs/VirtualHosts_Help.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/admin.html b/dist/docs/admin.html
index c2bf3698..80e1e82f 100644
--- a/dist/docs/admin.html
+++ b/dist/docs/admin.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/config.html b/dist/docs/config.html
index 8cb81b83..9a517e83 100644
--- a/dist/docs/config.html
+++ b/dist/docs/config.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/index.html b/dist/docs/index.html
index 653faa63..4ef4020a 100644
--- a/dist/docs/index.html
+++ b/dist/docs/index.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
@@ -102,7 +102,7 @@
Users' Manual
- — Rev. 27
+ — Rev. 28
diff --git a/dist/docs/install.html b/dist/docs/install.html
index 7198ef9e..d13317a1 100644
--- a/dist/docs/install.html
+++ b/dist/docs/install.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/intro.html b/dist/docs/intro.html
index 1b45cf28..345a00b0 100644
--- a/dist/docs/intro.html
+++ b/dist/docs/intro.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/license.html b/dist/docs/license.html
index 53d235d6..250ff132 100644
--- a/dist/docs/license.html
+++ b/dist/docs/license.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/security.html b/dist/docs/security.html
index 244ec043..259a6c68 100644
--- a/dist/docs/security.html
+++ b/dist/docs/security.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/dist/docs/webconsole.html b/dist/docs/webconsole.html
index 06ee7040..39c593a7 100644
--- a/dist/docs/webconsole.html
+++ b/dist/docs/webconsole.html
@@ -17,7 +17,7 @@
- Version 1.7 — Rev. 27
+ Version 1.7 — Rev. 28
diff --git a/src/h2/unpackedheaders.cpp b/src/h2/unpackedheaders.cpp
index 5a63ff6d..acec02f3 100644
--- a/src/h2/unpackedheaders.cpp
+++ b/src/h2/unpackedheaders.cpp
@@ -1407,6 +1407,8 @@ lsxpack_err_code UpkdHdrBuilder::process(lsxpack_header *hdr)
return LSXPACK_ERR_BAD_REQ_HEADER;
else if (hdr->name_len == 6 && memcmp(name, "cookie", 6) == 0)
idx = HttpHeader::H_COOKIE;
+ else if (hdr->name_len == 17 && memcmp(name, "transfer-encoding", 17) == 0)
+ idx = HttpHeader::H_TRANSFER_ENCODING;
else if (hdr->name_len == 0)
{
//NOTE: skip blank header
@@ -1451,6 +1453,11 @@ lsxpack_err_code UpkdHdrBuilder::process(lsxpack_header *hdr)
++cookie_count;
return LSXPACK_OK;
}
+ else if (idx == HttpHeader::H_TRANSFER_ENCODING)
+ {
+ if (hdr->val_len == 7 && strncasecmp(val, "chunked", 7) == 0)
+ return LSXPACK_ERR_BAD_REQ_HEADER;
+ }
else if (hdr->name_len == 2 && memcmp(name, "te", 2) == 0)
{
if (hdr->val_len != 8 || strncasecmp("trailers", val, 8) != 0)
diff --git a/src/http/httpreq.cpp b/src/http/httpreq.cpp
index 2e7d16c8..718e7103 100644
--- a/src/http/httpreq.cpp
+++ b/src/http/httpreq.cpp
@@ -2325,15 +2325,21 @@ int HttpReq::checkStrictOwnership(const char *path, uid_t st_uid)
{
if (!m_pVHost->isStrictOwner())
return 0;
- uid_t uid = m_pVHost->getOwnerUid();
- if (st_uid != uid
- && st_uid != ServerProcessConfig::getInstance().getUid()
- && st_uid != 0)
+ if (m_pContext->getURILen() == 1
+ || strncmp(m_pContext->getLocation(),
+ m_pVHost->getDocRoot()->c_str(),
+ m_pVHost->getDocRoot()->len()) == 0)
{
- LS_INFO(getLogSession(),
- "owner of file does not match owner of vhost, path [%s], access denied.",
- path);
- return SC_403;
+ uid_t uid = m_pVHost->getOwnerUid();
+ if (st_uid != uid
+ && st_uid != ServerProcessConfig::getInstance().getUid()
+ && st_uid != 0)
+ {
+ LS_INFO(getLogSession(),
+ "owner of file does not match owner of vhost, path [%s], access denied.",
+ path);
+ return SC_403;
+ }
}
return 0;
}
diff --git a/src/http/httpresp.cpp b/src/http/httpresp.cpp
index 68a14214..2ba260dd 100644
--- a/src/http/httpresp.cpp
+++ b/src/http/httpresp.cpp
@@ -60,12 +60,30 @@ void HttpResp::reset(int delCookies)
void HttpResp::resetRespBody()
{
+ rewindRespBodyBuf();
if (m_pGzipBuf)
m_pGzipBuf->reinit();
+}
+
+
+void HttpResp::rewindRespBodyBuf()
+{
+ if (m_pGzipBuf)
+ m_pGzipBuf->resetCompressCache();
+ else
+ rewindRespBodyBuf2();
+}
+
+
+void HttpResp::rewindRespBodyBuf2()
+{
if (m_pRespBodyBuf)
{
+ m_pRespBodyBuf->validateCurWPos();
m_pRespBodyBuf->rewindReadBuf();
+ m_pRespBodyBuf->validateCurWPos();
m_pRespBodyBuf->rewindWriteBuf();
+ m_pRespBodyBuf->validateCurWPos();
}
}
diff --git a/src/http/httpresp.h b/src/http/httpresp.h
index 1f078f77..d5c6f262 100644
--- a/src/http/httpresp.h
+++ b/src/http/httpresp.h
@@ -47,6 +47,7 @@ class HttpResp
void operator=(const HttpResp &rhs);
+ void rewindRespBodyBuf2();
void addWWWAuthHeader(const HttpReq *pReq);
public:
explicit HttpResp(ls_xpool_t *pool);
@@ -79,6 +80,7 @@ class HttpResp
VMemBuf *getRespBodyBuf() const { return m_pRespBodyBuf; }
void setRespBodyBuf(VMemBuf *pBuf) { m_pRespBodyBuf = pBuf; }
void resetRespBody();
+ void rewindRespBodyBuf();
GzipBuf *getGzipBuf() const { return m_pGzipBuf; }
void setGzipBuf(GzipBuf *pGzip) { m_pGzipBuf = pGzip; }
diff --git a/src/http/httpsession.cpp b/src/http/httpsession.cpp
index 8a59059d..89abb62e 100644
--- a/src/http/httpsession.cpp
+++ b/src/http/httpsession.cpp
@@ -3376,7 +3376,8 @@ int HttpSession::detectKeepAliveTimeout(int delta)
if (c)
{
HttpStats::decIdleConns();
- getStream()->close();
+ setState(HSS_DROP);
+ getStream()->tobeClosed();
}
return c;
}
@@ -3523,13 +3524,7 @@ void HttpSession::rewindRespBodyBuf()
LS_DBG_M(getLogger(),
"[%s] Rewind RespBodyBuf, current size: %lld \n",
getLogId(), (long long)wPos);
- if (getGzipBuf())
- getGzipBuf()->resetCompressCache();
- else
- {
- getRespBodyBuf()->rewindReadBuf();
- getRespBodyBuf()->rewindWriteBuf();
- }
+ m_response.rewindRespBodyBuf();
}
}
@@ -3625,6 +3620,7 @@ int HttpSession::setupRespBodyBuf()
(long long)m_response.getContentLen());
return LS_FAIL;
}
+ getRespBodyBuf()->validateCurWPos();
m_lDynBodySent = 0;
}
return 0;
@@ -3689,7 +3685,11 @@ int HttpSession::setupGzipFilter()
if (!hkptNogzip)
{
if (!getRespBodyBuf()->empty())
+ {
+ getRespBodyBuf()->validateCurWPos();
getRespBodyBuf()->rewindWriteBuf();
+ getRespBodyBuf()->validateCurWPos();
+ }
if (m_response.getContentLen() > 200 ||
m_response.getContentLen() < 0)
{
@@ -3939,16 +3939,7 @@ int HttpSession::shouldSuspendReadingResp()
void HttpSession::resetRespBodyBuf()
{
-
- {
- if (getGzipBuf())
- getGzipBuf()->resetCompressCache();
- else
- {
- getRespBodyBuf()->rewindReadBuf();
- getRespBodyBuf()->rewindWriteBuf();
- }
- }
+ m_response.rewindRespBodyBuf();
}
diff --git a/src/http/ntwkiolink.cpp b/src/http/ntwkiolink.cpp
index f4f99cf5..ebb90cfd 100644
--- a/src/http/ntwkiolink.cpp
+++ b/src/http/ntwkiolink.cpp
@@ -1031,7 +1031,7 @@ int NtwkIOLink::onTimer()
}
if (detectClose())
- return 0;
+ return 1;
m_iInProcess = 1;
(*m_pFpList->m_onTimer_fp)(this);
m_iInProcess = 0;
@@ -1320,6 +1320,7 @@ int NtwkIOLink::detectClose()
{
LS_DBG_M(this, "Shutdown time out!");
closeSocket();
+ return 1;
}
else if (getState() == HIOS_CONNECTED)
{
diff --git a/src/http/rewriterule.cpp b/src/http/rewriterule.cpp
index abeb08bd..47fef414 100644
--- a/src/http/rewriterule.cpp
+++ b/src/http/rewriterule.cpp
@@ -839,16 +839,16 @@ int RewriteRule::parseOneFlag(const char *&pRuleStr, const char *pEnd,
m_flag |= RULE_FLAG_NOESCAPE;
pRuleStr += 8;
}
- else if (strncasecmp(pRuleStr, "ne", 2) == 0)
- {
- m_flag |= RULE_FLAG_NOESCAPE;
- pRuleStr += 2;
- }
else if (strncasecmp(pRuleStr, "next", 4) == 0)
{
m_flag |= RULE_FLAG_NEXT;
pRuleStr += 4;
}
+ else if (strncasecmp(pRuleStr, "ne", 2) == 0)
+ {
+ m_flag |= RULE_FLAG_NOESCAPE;
+ pRuleStr += 2;
+ }
else // 'N'
{
m_flag |= RULE_FLAG_NEXT;
diff --git a/src/main/lshttpdmain.cpp b/src/main/lshttpdmain.cpp
index 2ba402d1..7f67b10c 100644
--- a/src/main/lshttpdmain.cpp
+++ b/src/main/lshttpdmain.cpp
@@ -81,7 +81,7 @@
/***
* Do not change the below format, it will be set correctly while packing the code
*/
-#define BUILDTIME "built: Tue Feb 8 17:55:20 UTC 2022"
+#define BUILDTIME "built: Thu Apr 28 20:35:55 UTC 2022"
static const char s_pVersionFull[] = "LiteSpeed/" PACKAGE_VERSION
" Open (" LS_MODULE_VERSION_INFO_ONELINE ") BUILD (" BUILDTIME ")";
diff --git a/src/main/serverinfo.cpp b/src/main/serverinfo.cpp
index 168ae725..a0c48723 100644
--- a/src/main/serverinfo.cpp
+++ b/src/main/serverinfo.cpp
@@ -43,6 +43,11 @@ ServerInfo::ServerInfo(char *pBegin, char *pEnd)
ServerInfo::~ServerInfo()
{
+ if (m_pChroot)
+ {
+ free(m_pChroot);
+ m_pChroot = NULL;
+ }
}
void ServerInfo::addUnixSocket(const char *pSock, struct stat *pStat)
diff --git a/src/modules/cache/cacheentry.cpp b/src/modules/cache/cacheentry.cpp
index 086a4667..7909cc84 100644
--- a/src/modules/cache/cacheentry.cpp
+++ b/src/modules/cache/cacheentry.cpp
@@ -159,7 +159,7 @@ int CacheEntry::verifyKey(CacheKey *pKey) const
if (pKey->m_iQsLen > 0)
{
if ((*p != '?') ||
- (memcmp(p + 1, pKey->m_pQs, pKey->m_iQsLen) != 0))
+ (strncmp(p + 1, pKey->m_pQs, pKey->m_iQsLen) != 0))
return -2;
p += pKey->m_iQsLen + 1;
}
@@ -167,7 +167,7 @@ int CacheEntry::verifyKey(CacheKey *pKey) const
if (pKey->m_iCookieVary > 0)
{
if ((*p != '#') ||
- (memcmp(p + 1, pKey->m_sCookie.c_str(), pKey->m_iCookieVary) != 0))
+ (strncmp(p + 1, pKey->m_sCookie.c_str(), pKey->m_iCookieVary) != 0))
return -3;
p += pKey->m_iCookieVary + 1;
@@ -188,7 +188,7 @@ int CacheEntry::verifyKey(CacheKey *pKey) const
if (!isPublic)
{
if ((*p != '~') ||
- (memcmp(p + 1, pKey->m_sCookie.c_str() + pKey->m_iCookieVary,
+ (strncmp(p + 1, pKey->m_sCookie.c_str() + pKey->m_iCookieVary,
pKey->m_iCookiePrivate) != 0))
return -4;
}
@@ -198,7 +198,7 @@ int CacheEntry::verifyKey(CacheKey *pKey) const
if (!isPublic)
{
if ((*p != '@') ||
- (memcmp(p + 1, pKey->m_pIP, pKey->m_ipLen) != 0))
+ (strncmp(p + 1, pKey->m_pIP, pKey->m_ipLen) != 0))
return -5;
p += pKey->m_ipLen + 1;
}
diff --git a/src/shm/lsshmpool.cpp b/src/shm/lsshmpool.cpp
index 0120e366..02eec8f1 100644
--- a/src/shm/lsshmpool.cpp
+++ b/src/shm/lsshmpool.cpp
@@ -1126,8 +1126,7 @@ void LsShmPool::reduceFreeFromBot(
{
// remove myself from freelist
markTopUsed(ap);
- disconnectFromFree(ap,
- (LShmFreeBot *)offset2ptr(ap->x_iFreeSize - sizeof(LShmFreeBot)));
+ disconnectFromFree(ap, offset);
return;
}
@@ -1143,7 +1142,7 @@ void LsShmPool::reduceFreeFromBot(
}
-void LsShmPool::disconnectFromFree(LShmFreeTop *ap, LShmFreeBot *bp)
+void LsShmPool::disconnectFromFree(LShmFreeTop *ap, LsShmOffset_t offset)
{
LsShmOffset_t myNext, myPrev;
myNext = ap->x_iFreeNext;
@@ -1156,7 +1155,12 @@ void LsShmPool::disconnectFromFree(LShmFreeTop *ap, LShmFreeBot *bp)
xp = (LShmFreeTop *)offset2ptr(myPrev);
if (xp->x_iFreeNext == myNext)
{
- assert(!"Looping link corruption detected in SHM free pages");
+ LS_ERROR("[SHM] [%d-%d:%p] Looping link corruption detected in SHM"
+ " free pages, both current and next are 0x%x, head is 0x%x",
+ s_pid, m_pShm->getfd(), this, myNext,
+ pDataMap->x_iFreePageList);
+ if (pDataMap->x_iFreePageList == offset)
+ pDataMap->x_iFreePageList = 0;
myNext = 0;
}
xp->x_iFreeNext = myNext;
@@ -1165,7 +1169,9 @@ void LsShmPool::disconnectFromFree(LShmFreeTop *ap, LShmFreeBot *bp)
{
if (pDataMap->x_iFreePageList == myNext)
{
- assert(!"Looping link corruption detected in head of SHM free pages");
+ LS_ERROR("[SHM] [%d-%d:%p] Looping link corruption detected in "
+ "head of SHM free pages, both link head and next are 0x%x",
+ s_pid, m_pShm->getfd(), this, myNext);
myNext = 0;
}
pDataMap->x_iFreePageList = myNext;
@@ -1246,7 +1252,7 @@ bool LsShmPool::isFreeBlockBelow(
markTopUsed(ap);
if (joinFlag == 2)
{
- disconnectFromFree(ap, bp);
+ disconnectFromFree(ap, belowOffset);
// merge to top
LShmFreeTop *xp = (LShmFreeTop *)offset2ptr(offset);
xp->x_iFreeSize += ap->x_iFreeSize;
diff --git a/src/shm/lsshmpool.h b/src/shm/lsshmpool.h
index b45d710e..ea7707ae 100644
--- a/src/shm/lsshmpool.h
+++ b/src/shm/lsshmpool.h
@@ -233,7 +233,7 @@ class LsShmPool : public ls_shmpool_s
LsShmOffset_t getFromFreeList(LsShmSize_t pagesize);
void reduceFreeFromBot(LShmFreeTop *ap,
LsShmOffset_t offset, LsShmSize_t newsize);
- void disconnectFromFree(LShmFreeTop *ap, LShmFreeBot *bp);
+ void disconnectFromFree(LShmFreeTop *ap, LsShmOffset_t offset);
void incrCheck(LsShmXSize_t *ptr, LsShmSize_t size);
diff --git a/src/sslpp/ls_fdbuf_bio.c b/src/sslpp/ls_fdbuf_bio.c
index 34f77388..96d059ad 100644
--- a/src/sslpp/ls_fdbuf_bio.c
+++ b/src/sslpp/ls_fdbuf_bio.c
@@ -250,6 +250,8 @@ static int bio_fd_read(BIO *b, char *out, int outl)
if (ret < 0)
{
err = errno;
+ DEBUG_MESSAGE("[BIO] bio_fd_read: Read error: (%d) %s \n",
+ err, strerror(err));
if (total)
{
DEBUG_MESSAGE("[BIO] bio_fd_read: error but I have data\n");
diff --git a/src/sslpp/sslticket.cpp b/src/sslpp/sslticket.cpp
index b3186316..5056ce76 100644
--- a/src/sslpp/sslticket.cpp
+++ b/src/sslpp/sslticket.cpp
@@ -437,7 +437,7 @@ int SslTicket::ticketCb(SSL *pSSL, unsigned char aName[16], unsigned char *iv,
if (pSessKey->expireSec < (DateTime::s_curTime + (m_iLifetime >> 1)))
{
- LS_NOTICE("[SSLTicket] ticketCb() SHM keys need rotation");
+ LS_DBG("[SSLTicket] ticketCb() SHM keys need rotation");
checkShmExpire(pShmData);
memmove(&m_keys, &pShmData->m_keys,
(sizeof(STKey_t) + sizeof(short)) * SSLTICKET_NUMKEYS);
diff --git a/src/util/compressor.cpp b/src/util/compressor.cpp
index 62b764c4..acf4cf0e 100644
--- a/src/util/compressor.cpp
+++ b/src/util/compressor.cpp
@@ -42,14 +42,6 @@ Compressor::~Compressor()
}
-int Compressor::resetCompressCache()
-{
- m_pCompressCache->rewindReadBuf();
- m_pCompressCache->rewindWriteBuf();
- return 0;
-}
-
-
int Compressor::processFile(int type, const char *pFileName,
const char *pCompressFileName)
{
diff --git a/src/util/compressor.h b/src/util/compressor.h
index 8d7e23d6..adae41cd 100644
--- a/src/util/compressor.h
+++ b/src/util/compressor.h
@@ -59,7 +59,7 @@ class Compressor
virtual int reset() = 0;
virtual const char *getLastError() const = 0;
- virtual int resetCompressCache();
+ virtual int resetCompressCache() = 0;
virtual int write(const char *pBuf, int len) = 0;
virtual int processFile(int type, const char *pFileName,
const char *pCompressFileName);
diff --git a/src/util/gzipbuf.cpp b/src/util/gzipbuf.cpp
index c91f7be1..a61f330e 100644
--- a/src/util/gzipbuf.cpp
+++ b/src/util/gzipbuf.cpp
@@ -156,8 +156,11 @@ int GzipBuf::endStream()
int GzipBuf::resetCompressCache()
{
+ m_pCompressCache->validateCurWPos();
m_pCompressCache->rewindReadBuf();
+ m_pCompressCache->validateCurWPos();
m_pCompressCache->rewindWriteBuf();
+ m_pCompressCache->validateCurWPos();
size_t size;
m_zstr.next_out = (unsigned char *)
m_pCompressCache->getWriteBuffer(size);
diff --git a/src/util/vmembuf.cpp b/src/util/vmembuf.cpp
index 76fff6c4..2e5dad51 100644
--- a/src/util/vmembuf.cpp
+++ b/src/util/vmembuf.cpp
@@ -228,8 +228,7 @@ int VMemBuf::shrinkBuf(off_t size)
m_iCurTotalSize -= pBuf->getBlockSize();
recycle(pBuf);
}
- if (!m_bufList.empty())
- m_pCurWBlock = m_pCurRBlock = m_bufList.begin();
+ rewindToBeginning();
return 0;
}
@@ -317,22 +316,27 @@ int VMemBuf::reinit(off_t TargetSize)
ls_atomic_spin_unlock(&s_LockAnonPool);
}
// All locks are off now.
+ rewindToBeginning();
+ return 0;
+}
+
+
+void VMemBuf::rewindToBeginning()
+{
if (!m_bufList.empty())
{
-
+ validateCurWPos();
m_pCurWBlock = m_pCurRBlock = m_bufList.begin();
if (*m_pCurWBlock)
{
m_curWBlkPos = m_curRBlkPos = (*m_pCurWBlock)->getBlockSize();
m_pCurRPos = m_pCurWPos = (*m_pCurWBlock)->getBuf();
- }
- else
- {
- m_curWBlkPos = m_curRBlkPos = 0;
- m_pCurRPos = m_pCurWPos = NULL;
+ validateCurWPos();
+ return;
}
}
- return 0;
+ m_curWBlkPos = m_curRBlkPos = 0;
+ m_pCurRPos = m_pCurWPos = NULL;
}
@@ -449,9 +453,8 @@ int VMemBuf::set(int type, int size)
if (pBlock)
{
appendBlock(pBlock);
- m_pCurRPos = m_pCurWPos = pBlock->getBuf();
- m_iCurTotalSize = m_curRBlkPos = m_curWBlkPos = pBlock->getBlockSize();
- m_pCurRBlock = m_pCurWBlock = m_bufList.begin();
+ rewindToBeginning();
+ m_iCurTotalSize = m_curRBlkPos;
}
return 0;
}
@@ -532,9 +535,8 @@ int VMemBuf::set(int type, BlockBuf *pBlock)
assert(pBlock);
m_iType = type;
appendBlock(pBlock);
- m_pCurRBlock = m_pCurWBlock = m_bufList.begin();
- m_pCurRPos = m_pCurWPos = pBlock->getBuf();
- m_iCurTotalSize = m_curRBlkPos = m_curWBlkPos = pBlock->getBlockSize();
+ rewindToBeginning();
+ m_iCurTotalSize = m_curRBlkPos;
return 0;
}
@@ -596,6 +598,7 @@ void VMemBuf::rewindReadWriteBuf()
#endif
ls_atomic_spin_lock(&m_lock);
m_pCurRBlock = m_bufList.begin();
+ validateCurWPos();
if (m_pCurRBlock)
{
m_curRBlkPos = (*m_pCurRBlock)->getBlockSize();
@@ -613,6 +616,7 @@ void VMemBuf::rewindReadWriteBuf()
m_curRBlkPos = m_curWBlkPos;
m_pCurRPos = m_pCurWPos;
}
+ validateCurWPos();
ls_atomic_spin_unlock(&m_lock);
}
@@ -620,6 +624,7 @@ void VMemBuf::rewindReadWriteBuf()
void VMemBuf::rewindWriteBuf()
{
ls_atomic_spin_lock(&m_lock);
+ validateCurWPos();
if (m_pCurRBlock)
{
if (m_pCurWBlock != m_pCurRBlock)
@@ -635,6 +640,7 @@ void VMemBuf::rewindWriteBuf()
m_curRBlkPos = m_curWBlkPos;
m_pCurRPos = m_pCurWPos;
}
+ validateCurWPos();
ls_atomic_spin_unlock(&m_lock);
}
@@ -733,12 +739,7 @@ int VMemBuf::mapNextWBlock()
}
#endif
ls_atomic_spin_lock(&m_lock);
- m_pCurWBlock = m_pCurRBlock = m_bufList.begin();
- m_curWBlkPos = 0;
- m_curRBlkPos = (*m_pCurWBlock)->getBlockSize();
- m_pCurRPos = (*m_pCurWBlock)->getBuf();
- m_curWBlkPos += (*m_pCurWBlock)->getBlockSize();
- m_pCurWPos = (*m_pCurWBlock)->getBuf();
+ rewindToBeginning();
ls_atomic_spin_unlock(&m_lock);
}
return 0;
@@ -765,7 +766,7 @@ int VMemBuf::grow()
}
break;
case VMBUF_FILE_MAP:
- if (ftruncate(m_iFd, m_iCurTotalSize + s_iBlockSize) == -1)
+ if (posix_fallocate(m_iFd, m_iCurTotalSize, s_iBlockSize) == -1)
{
perror("Failed to increase temp file size with ftrancate()");
return LS_FAIL;
@@ -824,8 +825,17 @@ char *VMemBuf::getReadBuffer(size_t &size)
}
+void VMemBuf::validateCurWPos() const
+{
+ assert(!m_pCurWBlock || !(*m_pCurWBlock)
+ || (m_pCurWPos >= (*m_pCurWBlock)->getBuf()
+ && m_pCurWPos <= (*m_pCurWBlock)->getBufEnd()));
+}
+
+
char *VMemBuf::getWriteBuffer(size_t &size)
{
+ validateCurWPos();
if ((!m_pCurWBlock) || (m_pCurWPos >= (*m_pCurWBlock)->getBufEnd()))
{
if (mapNextWBlock() != 0)
@@ -833,6 +843,7 @@ char *VMemBuf::getWriteBuffer(size_t &size)
return NULL;
}
}
+ validateCurWPos();
size = (*m_pCurWBlock)->getBufEnd() - m_pCurWPos;
return m_pCurWPos;
}
@@ -1101,7 +1112,7 @@ int VMemBuf::copyToFile(off_t startOff, off_t len,
//destSize -= destSize % s_iBlockSize;
if (st.st_size < destSize)
{
- if (ftruncate(fd, destSize) == -1)
+ if (posix_fallocate(fd, st.st_size, destSize) == -1)
return LS_FAIL;
}
BlockBuf destBlock;
diff --git a/src/util/vmembuf.h b/src/util/vmembuf.h
index 2e5f837a..1c0b725c 100644
--- a/src/util/vmembuf.h
+++ b/src/util/vmembuf.h
@@ -76,6 +76,7 @@ class VMemBuf
void recycle(BlockBuf *pBuf);
int remapBlock(BlockBuf *pBlock, off_t pos);
+ void rewindToBeginning();
public:
void deallocate();
@@ -107,7 +108,9 @@ class VMemBuf
void writeUsed(off_t len)
{
ls_atomic_spin_lock(&m_lock);
+ validateCurWPos();
m_pCurWPos += len;
+ validateCurWPos();
ls_atomic_spin_unlock(&m_lock);
}
char *getCurRPos() const { return m_pCurRPos; }
@@ -148,6 +151,7 @@ class VMemBuf
void initBlank(int type);
int copyToBuf(char *buf, int offset, int len);
int writeToFile(int fd);
+ void validateCurWPos() const;
};
class MMapVMemBuf : public VMemBuf
diff --git a/test/http/statusurlmaptest.cpp b/test/http/statusurlmaptest.cpp
index 117fa06b..a35b1cc4 100644
--- a/test/http/statusurlmaptest.cpp
+++ b/test/http/statusurlmaptest.cpp
@@ -32,7 +32,7 @@ TEST(StatusUrlMapTest_test)
CHECK(map1.getUrl(i) == NULL);
for (i = 300; i <= 308; ++i)
CHECK(map1.setStatusUrlMap(i, "/url3xx") == 0);
- for (i = 400; i <= 431; ++i)
+ for (i = 400; i <= 451; ++i)
CHECK(map1.setStatusUrlMap(i, "/url4xx") == 0);
for (i = 500; i <= 513; ++i)
CHECK(map1.setStatusUrlMap(i, "/url5xx") == 0);
diff --git a/test/util/httpfetchtest.cpp b/test/util/httpfetchtest.cpp
index d6079382..5e1979ec 100644
--- a/test/util/httpfetchtest.cpp
+++ b/test/util/httpfetchtest.cpp
@@ -21,10 +21,12 @@
#include
#include
#include
+#include
#include "socket/gsockaddr.h"
#include "unittest-cpp/UnitTest++.h"
#include
#include
+#include
#include
#include
#include
@@ -49,6 +51,9 @@ TEST(httpfetchTest_Test)
const char *pSaveFile = "./lswslogo3.png";
+ Adns::getInstance().init();
+ EvtcbQue::getInstance().initNotifier();
+
pHttpFetch->setProxyServerAddr("127.0.0.1:8000");
int ret = pHttpFetch->startReq("http://www.litespeedtech.com/templates/litespeed/images/lswslogo3.png",
nonblock, 1,