mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-29 18:37:41 +08:00
modify db module
This commit is contained in:
parent
8bd31016de
commit
bc119e8199
@ -229,7 +229,7 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseDll|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;ACL_CPP_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;ACL_CPP_DLL;ACL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@ -279,7 +279,7 @@ copy ..\..\..\dist\lib\win32\lib_protocol.dll $(OutDir) /Y</Command>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ACL_CPP_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ACL_CPP_DLL;ACL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
|
@ -51,6 +51,7 @@ bool http_servlet::doPost(acl::HttpServletRequest& req,
|
||||
|
||||
res.setContentType("text/xml; charset=utf-8") // 设置响应字符集
|
||||
.setKeepAlive(req.isKeepAlive()) // 设置是否保持长连接
|
||||
.setContentEncoding(true) // 自动支持压缩传输
|
||||
.setChunkedTransferEncoding(true); // 采用 chunk 传输方式
|
||||
|
||||
const char* param1 = req.getParameter("name1");
|
||||
|
@ -43,12 +43,15 @@ void acl_clean_env(char **preserve_list)
|
||||
#define STRING_AND_LENGTH(x, y) (x), (ssize_t) (y)
|
||||
|
||||
save_list = acl_argv_alloc(10);
|
||||
for (cpp = preserve_list; *cpp; cpp++)
|
||||
for (cpp = preserve_list; *cpp; cpp++) {
|
||||
if ((eq = strchr(*cpp, '=')) != 0)
|
||||
acl_argv_addn(save_list, STRING_AND_LENGTH(*cpp, eq - *cpp),
|
||||
STRING_AND_LENGTH(eq + 1, strlen(eq + 1)), (char *) 0);
|
||||
acl_argv_addn(save_list,
|
||||
STRING_AND_LENGTH(*cpp, eq - *cpp),
|
||||
STRING_AND_LENGTH(eq + 1, strlen(eq + 1)),
|
||||
(char *) 0);
|
||||
else if ((value = acl_safe_getenv(*cpp)) != 0)
|
||||
acl_argv_add(save_list, *cpp, value, (char *) 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Truncate the process environment, if available. On some systems
|
||||
@ -66,7 +69,8 @@ void acl_clean_env(char **preserve_list)
|
||||
#elif defined(ACL_WINDOWS)
|
||||
if (!SetEnvironmentVariable(cpp[0], cpp[1]))
|
||||
#endif
|
||||
acl_msg_error("setenv(%s, %s): %s", cpp[0], cpp[1], acl_last_serror());
|
||||
acl_msg_error("setenv(%s, %s): %s",
|
||||
cpp[0], cpp[1], acl_last_serror());
|
||||
|
||||
/*
|
||||
* Cleanup.
|
||||
@ -143,7 +147,8 @@ int acl_putenv(char *str)
|
||||
}
|
||||
if (!SetEnvironmentVariable(argv->argv[0], argv->argv[1])) {
|
||||
acl_msg_error("%s(%d): putenv(%s, %s) error(%s)",
|
||||
myname, __LINE__, argv->argv[0], argv->argv[1], acl_last_serror());
|
||||
myname, __LINE__, argv->argv[0],
|
||||
argv->argv[1], acl_last_serror());
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
@ -192,7 +197,8 @@ const char *acl_getenv_list(void)
|
||||
ACL_VSTRING_TERMINATE(buf);
|
||||
return (acl_vstring_str(buf));
|
||||
#else
|
||||
static acl_pthread_key_t buf_key = (acl_pthread_key_t) ACL_TLS_OUT_OF_INDEXES;
|
||||
static acl_pthread_key_t buf_key =
|
||||
(acl_pthread_key_t) ACL_TLS_OUT_OF_INDEXES;
|
||||
ACL_VSTRING *buf;
|
||||
extern char **environ;
|
||||
char **pptr = environ;
|
||||
@ -216,6 +222,7 @@ const char *acl_getenv_list(void)
|
||||
acl_vstring_strcat(buf, *pptr);
|
||||
pptr++;
|
||||
}
|
||||
|
||||
return (acl_vstring_str(buf));
|
||||
#endif
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
修改历史列表:
|
||||
|
||||
------------------------------------------------------------------------
|
||||
348) 2015.8.20
|
||||
348.1) compile: zlib_stream 类内部使用了动态加载 zlib 库的方式。
|
||||
|
||||
347) 2015.8.19
|
||||
347.1) feature: db_handle/db_mysql 支持事务提交接口
|
||||
|
||||
|
@ -302,16 +302,16 @@ public:
|
||||
virtual bool close() = 0;
|
||||
|
||||
/**
|
||||
* 纯虚接口,子类必须实现此接口用于执行 SQL 语句
|
||||
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
|
||||
* 纯虚接口,子类必须实现此接口用于执行 SELECT SQL 语句
|
||||
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注意该
|
||||
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
virtual bool sql_select(const char* sql) = 0;
|
||||
|
||||
/**
|
||||
* 纯虚接口,子类必须实现此接口用于执行 SQL 语句
|
||||
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
|
||||
* 纯虚接口,子类必须实现此接口用于执行 INSERT/UPDATE/DELETE SQL 语句
|
||||
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注意该
|
||||
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
@ -331,7 +331,8 @@ public:
|
||||
|
||||
/**
|
||||
* 更安全易用的查询过程,调用此函数功能等同于 sql_select,只是查询
|
||||
* 对象 query 构建的 sql 语句是安全的,可以防止 sql 注入
|
||||
* 对象 query 构建的 sql 语句是安全的,可以防止 sql 注入,该方法
|
||||
* 执行 SELECT SQL 语句
|
||||
* @param query {query&}
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
@ -339,7 +340,8 @@ public:
|
||||
|
||||
/**
|
||||
* 更安全易用的更新过程,调用此函数功能等同于 sql_update,只是查询
|
||||
* 对象 query 构建的 sql 语句是安全的,可以防止 sql 注入
|
||||
* 对象 query 构建的 sql 语句是安全的,可以防止 sql 注入,该方法
|
||||
* 执行 INSERT/UPDATE/DELETE SQL 语句
|
||||
* @param query {query&}
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
|
@ -86,16 +86,16 @@ public:
|
||||
|
||||
/**
|
||||
* 基类 db_handle 的纯虚接口
|
||||
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
|
||||
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @param sql {const char*} 标准的 SELECT SQL 语句,非空,并且一定
|
||||
* 得要注意该 SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
bool sql_select(const char* sql);
|
||||
|
||||
/**
|
||||
* 基类 db_handle 的纯虚接口
|
||||
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
|
||||
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @param sql {const char*} 标准的 INSERT/UPDATE/DELETE SQL 语句,
|
||||
* 并且一定得要注意该 SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
bool sql_update(const char* sql);
|
||||
|
@ -112,16 +112,16 @@ public:
|
||||
|
||||
/**
|
||||
* 基类 db_handle 的纯虚接口
|
||||
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
|
||||
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @param sql {const char*} 标准的 SELECT SQL 语句,并且一定得要
|
||||
* 注意该 SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
bool sql_select(const char* sql);
|
||||
|
||||
/**
|
||||
* 基类 db_handle 的纯虚接口
|
||||
* @param sql {const char*} 标准的 SQL 语句,非空,并且一定得要注册该
|
||||
* SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @param sql {const char*} 标准的 INSERT/UPDATE/DELETE SQL 语句,
|
||||
* 并且一定得要注意该 SQL 语句必须经过转义处理,以防止 SQL 注入攻击
|
||||
* @return {bool} 执行是否成功
|
||||
*/
|
||||
bool sql_update(const char* sql);
|
||||
|
@ -240,8 +240,8 @@ public:
|
||||
* @return {bool} 操作是否成功
|
||||
* if the command was executed correctly
|
||||
*/
|
||||
bool setbit(const char* key, unsigned offset, bool bit);
|
||||
bool setbit(const char* key, size_t len, unsigned offset, bool bit);
|
||||
bool setbit_(const char* key, unsigned offset, bool bit);
|
||||
bool setbit_(const char* key, size_t len, unsigned offset, bool bit);
|
||||
|
||||
/**
|
||||
* 对 key 所储存的字符串值,获取指定偏移量上的位(bit),当 offset 比字符串值
|
||||
|
@ -166,6 +166,15 @@ public:
|
||||
*/
|
||||
bool zip_reset();
|
||||
|
||||
/**
|
||||
* 在压缩过程中可使用此函数计算数据的 crc32 校验值
|
||||
* @param n {unsigned} 上次计算的校验和值,第一次时可写 0
|
||||
* @param buf {const void*} 需要校验的数据地址,第一次使用时写 NULL
|
||||
* @param dlen {size_t} buf 数据的长度,第一次使用时写 0
|
||||
* @return {unsinged} 本次计算的校验和值
|
||||
*/
|
||||
unsigned crc32_update(unsigned n, const void* buf, size_t dlen);
|
||||
|
||||
/**
|
||||
* 开始解压缩过程,如果采用流式解压缩方式,则调用顺序必须是:
|
||||
* unzip_begin->unzip_update->unzip_finish,如果中间任何一个
|
||||
@ -224,6 +233,17 @@ public:
|
||||
return zstream_;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当采用动态加载方式加载动态库时,可以使用此函数设置动态库的加载全路径
|
||||
*/
|
||||
static void set_loadpath(const char* path);
|
||||
|
||||
/**
|
||||
* 当设置了动态库的动态加载全路径时,可以通过本函数获得动态库加载全路径
|
||||
* @return {const char*} 当未设置时则返回 NULL
|
||||
*/
|
||||
static const char* get_loadpath();
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
bool pipe_zip_begin(zlib_level_t level = zlib_default,
|
||||
|
@ -21,7 +21,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\include;..\lib_protocol\include;..\lib_acl\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_WIN_ICONV"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_WIN_ICONV;HAS_ZLIB_DLL;HAS_MYSQL_DLL"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
@ -69,7 +69,7 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=".\include;..\lib_protocol\include;..\lib_acl\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_WIN_ICONV"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_WIN_ICONV;HAS_ZLIB_DLL;HAS_MYSQL_DLL"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="acl_stdafx.hpp"
|
||||
@ -708,19 +708,19 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y
|
||||
RelativePath=".\src\db\mysql_conf.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\db\mysql_pool.cpp">
|
||||
RelativePath=".\src\db\mysql_manager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\db\mysql_manager.cpp">
|
||||
RelativePath=".\src\db\mysql_pool.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\db\query.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\db\sqlite_pool.cpp">
|
||||
RelativePath=".\src\db\sqlite_manager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\db\sqlite_manager.cpp">
|
||||
RelativePath=".\src\db\sqlite_pool.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
@ -1251,19 +1251,19 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y
|
||||
RelativePath=".\include\acl_cpp\db\mysql_conf.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\acl_cpp\db\mysql_pool.hpp">
|
||||
RelativePath=".\include\acl_cpp\db\mysql_manager.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\acl_cpp\db\mysql_manager.hpp">
|
||||
RelativePath=".\include\acl_cpp\db\mysql_pool.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\acl_cpp\db\query.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\acl_cpp\db\sqlite_pool.hpp">
|
||||
RelativePath=".\include\acl_cpp\db\sqlite_manager.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\acl_cpp\db\sqlite_manager.hpp">
|
||||
RelativePath=".\include\acl_cpp\db\sqlite_pool.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -42,7 +42,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
@ -111,7 +111,7 @@
|
||||
EnableIntrinsicFunctions="true"
|
||||
WholeProgramOptimization="false"
|
||||
AdditionalIncludeDirectories=".\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="2"
|
||||
@ -176,7 +176,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=".\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
@ -255,7 +255,7 @@
|
||||
EnableIntrinsicFunctions="true"
|
||||
WholeProgramOptimization="false"
|
||||
AdditionalIncludeDirectories=".\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_WIN_ICONV;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;HAS_MYSQL_DLL"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_WIN_ICONV;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;HAS_MYSQL_DLL;HAS_ZLIB_DLL"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="2"
|
||||
|
@ -89,7 +89,7 @@
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_MT;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_MT;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
@ -113,7 +113,7 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y</Command>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>acl_stdafx.hpp</PrecompiledHeaderFile>
|
||||
@ -134,7 +134,7 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y</Command>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
@ -167,7 +167,7 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;.\src;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
|
@ -174,7 +174,7 @@
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;_MT;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;_MT;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
@ -199,7 +199,7 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y</Command>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;_MT;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;_MT;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
@ -222,7 +222,7 @@ copy $(TargetName).pdb ..\dist\lib\win64\$(TargetName).pdb /Y</Command>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>acl_stdafx.hpp</PrecompiledHeaderFile>
|
||||
@ -242,7 +242,7 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y</Command>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>acl_stdafx.hpp</PrecompiledHeaderFile>
|
||||
@ -263,7 +263,7 @@ copy $(TargetName).pdb ..\dist\lib\win64\$(TargetName).pdb /Y</Command>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
@ -296,7 +296,7 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
@ -328,7 +328,7 @@ copy $(TargetName).pdb ..\dist\lib\win64\$(TargetName).pdb /Y
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;.\src;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
@ -358,7 +358,7 @@ copy $(TargetName).pdb ..\dist\lib\win32\$(TargetName).pdb /Y
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.\include;..\lib_acl\include;..\lib_protocol\include;..\include\sqlite;..\include\zlib;..\include\mysql;.\src;..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;_MT;ACL_DLL;ACL_CPP_DLL;ACL_CPP_EXPORTS;USE_WIN_ICONV;HAS_MYSQL_DLL;HAS_ZLIB_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
|
@ -7,13 +7,27 @@
|
||||
class test_buf
|
||||
{
|
||||
public:
|
||||
test_buf()
|
||||
test_buf(int i)
|
||||
{
|
||||
i_ = i;
|
||||
}
|
||||
|
||||
~test_buf()
|
||||
{
|
||||
}
|
||||
|
||||
void set(int i)
|
||||
{
|
||||
i_ = i;
|
||||
}
|
||||
|
||||
int get() const
|
||||
{
|
||||
return i_;
|
||||
}
|
||||
|
||||
private:
|
||||
int i_;
|
||||
};
|
||||
|
||||
class test_buf2
|
||||
@ -45,10 +59,11 @@ private:
|
||||
class test_thread : public acl::thread
|
||||
{
|
||||
public:
|
||||
test_thread(int max_loop, int max_count, bool use_pool)
|
||||
test_thread(int max_loop, int max_count, bool use_pool, bool replace)
|
||||
: max_loop_(max_loop)
|
||||
, max_count_(max_count)
|
||||
, use_pool_(use_pool)
|
||||
, replace_(replace)
|
||||
{
|
||||
}
|
||||
|
||||
@ -63,7 +78,12 @@ protected:
|
||||
gettimeofday(&begin, NULL);
|
||||
|
||||
if (use_pool_)
|
||||
test_pool();
|
||||
{
|
||||
if (replace_)
|
||||
test_pool2();
|
||||
else
|
||||
test_pool();
|
||||
}
|
||||
else
|
||||
test_malloc();
|
||||
|
||||
@ -99,6 +119,28 @@ private:
|
||||
pool->destroy();
|
||||
}
|
||||
|
||||
void test_pool2()
|
||||
{
|
||||
acl::dbuf_pool* pool = new acl::dbuf_pool;
|
||||
test_buf* buf;
|
||||
char* ptr;
|
||||
|
||||
for (int i = 0; i < max_loop_; i++)
|
||||
{
|
||||
for (int j = 0; j < max_count_; j++)
|
||||
{
|
||||
ptr = (char*) pool->dbuf_alloc(sizeof(test_buf));
|
||||
buf = new (ptr) test_buf(i);
|
||||
// buf->set(i);
|
||||
buf->~test_buf();
|
||||
}
|
||||
|
||||
pool->dbuf_reset();
|
||||
}
|
||||
|
||||
pool->destroy();
|
||||
}
|
||||
|
||||
void test_malloc()
|
||||
{
|
||||
test_buf* buf;
|
||||
@ -107,7 +149,7 @@ private:
|
||||
{
|
||||
for (int j = 0; j < max_count_; j++)
|
||||
{
|
||||
buf = new test_buf;
|
||||
buf = new test_buf(i);
|
||||
delete buf;
|
||||
}
|
||||
}
|
||||
@ -117,6 +159,7 @@ private:
|
||||
int max_loop_;
|
||||
int max_count_;
|
||||
bool use_pool_;
|
||||
bool replace_;
|
||||
};
|
||||
|
||||
static void usage(const char* procname)
|
||||
@ -125,15 +168,16 @@ static void usage(const char* procname)
|
||||
"\t-n loop \r\n"
|
||||
"\t-m count \r\n"
|
||||
"\t-c max_threads \r\n"
|
||||
"\t-p [use memory pool]\r\n", procname);
|
||||
"\t-p [use memory pool]\r\n"
|
||||
"\t-r [replace new when using pool]\r\n", procname);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
bool use_pool = false;
|
||||
bool use_pool = false, replace = false;
|
||||
int ch, loop = 100, count = 10000, nthreads = 1;
|
||||
|
||||
while ((ch = getopt(argc, argv, "hpn:m:c:")) > 0)
|
||||
while ((ch = getopt(argc, argv, "hpn:m:c:r")) > 0)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
@ -143,6 +187,9 @@ int main(int argc, char* argv[])
|
||||
case 'p':
|
||||
use_pool = true;
|
||||
break;
|
||||
case 'r':
|
||||
replace = true;
|
||||
break;
|
||||
case 'n':
|
||||
loop = atoi(optarg);
|
||||
break;
|
||||
@ -160,7 +207,8 @@ int main(int argc, char* argv[])
|
||||
std::vector<test_thread*> threads;
|
||||
for (int i = 0; i < nthreads; i++)
|
||||
{
|
||||
test_thread* thread = new test_thread(loop, count, use_pool);
|
||||
test_thread* thread = new
|
||||
test_thread(loop, count, use_pool, replace);
|
||||
|
||||
thread->set_detachable(false);
|
||||
thread->start();
|
||||
|
@ -4,10 +4,10 @@ all:
|
||||
@(cd http_request; make)
|
||||
@(cd http_response; make)
|
||||
@(cd http_servlet; make)
|
||||
@(cd cgi_end; make)
|
||||
@(cd cgi_env; make)
|
||||
|
||||
clean:
|
||||
@(cd http_request; make clean)
|
||||
@(cd http_response; make clean)
|
||||
@(cd http_servlet; make clean)
|
||||
@(cd cgi_end; make clean)
|
||||
@(cd cgi_env; make clean)
|
||||
|
@ -1,4 +1,14 @@
|
||||
base_path = ../../..
|
||||
PROG = cgi_env
|
||||
EXTLIBS = -lz
|
||||
include ../../Makefile.in
|
||||
#Path for SunOS
|
||||
ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS)
|
||||
EXTLIBS = -liconv
|
||||
endif
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
EXTLIBS = -L/usr/local/lib -liconv
|
||||
endif
|
||||
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
||||
EXTLIBS += -L/usr/lib -liconv
|
||||
endif
|
||||
EXTLIBS += -lz
|
||||
|
@ -1,4 +1,14 @@
|
||||
base_path = ../../..
|
||||
PROG = http_request
|
||||
EXTLIBS = -lz
|
||||
base_path = ../../..
|
||||
include ../../Makefile.in
|
||||
#Path for SunOS
|
||||
ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS)
|
||||
EXTLIBS = -liconv
|
||||
endif
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
EXTLIBS = -L/usr/local/lib -liconv
|
||||
endif
|
||||
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
||||
EXTLIBS += -L/usr/lib -liconv
|
||||
endif
|
||||
EXTLIBS += -lz
|
||||
|
@ -1,4 +1,14 @@
|
||||
base_path = ../../..
|
||||
PROG = http_response
|
||||
EXTLIBS = -lz
|
||||
include ../../Makefile.in
|
||||
#Path for SunOS
|
||||
ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS)
|
||||
EXTLIBS = -liconv
|
||||
endif
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
EXTLIBS = -L/usr/local/lib -liconv
|
||||
endif
|
||||
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
||||
EXTLIBS += -L/usr/lib -liconv
|
||||
endif
|
||||
EXTLIBS += -lz
|
||||
PROG = http_response
|
||||
|
@ -33,9 +33,13 @@ static void handle_request(acl::socket_stream* conn)
|
||||
|
||||
acl::http_header& header = res.response_header();
|
||||
header.set_status(200);
|
||||
header.set_keep_alive(true);
|
||||
header.set_transfer_gzip(true);
|
||||
header.set_chunked(true);
|
||||
|
||||
acl::http_client* client = res.get_client();
|
||||
header.set_keep_alive(client->keep_alive());
|
||||
const char* ptr = client->header_value("Accept-Encoding");
|
||||
if (ptr && strstr(ptr, "gzip") != NULL)
|
||||
header.set_transfer_gzip(true);
|
||||
header.set_chunked(client->keep_alive() ? true : false);
|
||||
// header.set_content_length(buf.length());
|
||||
|
||||
acl::string hdr;
|
||||
@ -57,6 +61,9 @@ static void handle_request(acl::socket_stream* conn)
|
||||
printf("===============================================\r\n");
|
||||
|
||||
n++;
|
||||
|
||||
if (!client->keep_alive())
|
||||
break;
|
||||
}
|
||||
|
||||
conn->close();
|
||||
|
@ -1,4 +1,14 @@
|
||||
base_path = ../../..
|
||||
PROG = http_servlet
|
||||
EXTLIBS = -lz
|
||||
include ../../Makefile.in
|
||||
#Path for SunOS
|
||||
ifeq ($(findstring SunOS, $(UNIXNAME)), SunOS)
|
||||
EXTLIBS = -liconv
|
||||
endif
|
||||
ifeq ($(findstring FreeBSD, $(UNIXNAME)), FreeBSD)
|
||||
EXTLIBS = -L/usr/local/lib -liconv
|
||||
endif
|
||||
ifeq ($(findstring Darwin, $(UNIXNAME)), Darwin)
|
||||
EXTLIBS += -L/usr/lib -liconv
|
||||
endif
|
||||
EXTLIBS += -lz
|
||||
|
@ -39,7 +39,7 @@ static void get_url(const char* url, const char* host,
|
||||
return;
|
||||
}
|
||||
|
||||
if (client.write_head(header) == -1)
|
||||
if (client.write_head(header) == false)
|
||||
{
|
||||
printf("write request header error\r\n");
|
||||
return;
|
||||
|
@ -360,7 +360,7 @@ static bool test_setbit(acl::redis_string& redis, int n)
|
||||
key.format("bit_%s_%d", __keypre.c_str(), i);
|
||||
|
||||
redis.clear();
|
||||
if (redis.setbit(key.c_str(), off, 1) == false)
|
||||
if (redis.setbit_(key.c_str(), off, 1) == false)
|
||||
{
|
||||
printf("setbit error: %s, key: %s, off: %u\r\n",
|
||||
redis.result_error(), key.c_str(), off);
|
||||
|
@ -19,7 +19,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\..\lib_acl_cpp\include"
|
||||
AdditionalIncludeDirectories="..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include;..\"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -69,7 +69,7 @@
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\..\..\lib_acl_cpp\include"
|
||||
AdditionalIncludeDirectories="..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include;..\"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="3"
|
||||
@ -119,7 +119,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\..\lib_acl_cpp\include"
|
||||
AdditionalIncludeDirectories="..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include;..\"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -168,7 +168,7 @@
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\..\..\lib_acl_cpp\include"
|
||||
AdditionalIncludeDirectories="..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include;..\"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="3"
|
||||
@ -216,15 +216,15 @@
|
||||
Name="Ô´Îļþ"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\session.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\memcache_session.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\redis_session.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\session.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.cpp">
|
||||
<FileConfiguration
|
||||
@ -252,6 +252,9 @@
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\util.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Í·Îļþ"
|
||||
|
@ -11,15 +11,15 @@
|
||||
|
||||
#if defined(HAS_MYSQL) || defined(HAS_MYSQL_DLL)
|
||||
|
||||
#if defined(ACL_CPP_DLL) || defined(HAS_MYSQL_DLL)
|
||||
# if defined(ACL_CPP_DLL) || defined(HAS_MYSQL_DLL)
|
||||
|
||||
#ifndef STDCALL
|
||||
# ifdef ACL_WINDOWS
|
||||
# define STDCALL __stdcall
|
||||
# else
|
||||
# define STDCALL
|
||||
# endif // ACL_WINDOWS
|
||||
#endif // STDCALL
|
||||
# ifndef STDCALL
|
||||
# ifdef ACL_WINDOWS
|
||||
# define STDCALL __stdcall
|
||||
# else
|
||||
# define STDCALL
|
||||
# endif // ACL_WINDOWS
|
||||
# endif // STDCALL
|
||||
|
||||
typedef unsigned long (STDCALL *mysql_libversion_fn)(void);
|
||||
typedef const char* (STDCALL *mysql_client_info_fn)(void);
|
||||
@ -67,6 +67,7 @@ static mysql_character_set_name_fn __mysql_character_set_name = NULL;
|
||||
static acl_pthread_once_t __mysql_once = ACL_PTHREAD_ONCE_INIT;
|
||||
static ACL_DLL_HANDLE __mysql_dll = NULL;
|
||||
|
||||
// 记录动态加载库的全路径
|
||||
static acl::string __mysql_path;
|
||||
|
||||
// 程序退出释放动态加载的库
|
||||
@ -103,6 +104,7 @@ static void __mysql_dll_load(void)
|
||||
if (__mysql_dll == NULL)
|
||||
logger_fatal("load %s error: %s", path, acl_last_serror());
|
||||
|
||||
// 记录动态库路径,以便于在动态库卸载时输出库路径名
|
||||
__mysql_path = path;
|
||||
|
||||
__mysql_libversion = (mysql_libversion_fn)
|
||||
@ -221,29 +223,29 @@ static void __mysql_dll_load(void)
|
||||
logger("%s loaded!", path);
|
||||
atexit(__mysql_dll_unload);
|
||||
}
|
||||
#else
|
||||
# else
|
||||
|
||||
# define __mysql_libversion mysql_get_client_version
|
||||
# define __mysql_client_info mysql_get_client_info
|
||||
# define __mysql_init mysql_init
|
||||
# define __mysql_open mysql_real_connect
|
||||
# define __mysql_close mysql_close
|
||||
# define __mysql_options mysql_options
|
||||
# define __mysql_autocommit mysql_autocommit
|
||||
# define __mysql_errno mysql_errno
|
||||
# define __mysql_error mysql_error
|
||||
# define __mysql_query mysql_query
|
||||
# define __mysql_num_fields mysql_num_fields
|
||||
# define __mysql_fetch_fields mysql_fetch_fields
|
||||
# define __mysql_fetch_row mysql_fetch_row
|
||||
# define __mysql_store_result mysql_store_result
|
||||
# define __mysql_num_rows mysql_num_rows
|
||||
# define __mysql_free_result mysql_free_result
|
||||
# define __mysql_affected_rows mysql_affected_rows
|
||||
# define __mysql_set_character_set mysql_set_character_set
|
||||
# define __mysql_character_set_name mysql_character_set_name
|
||||
# define __mysql_libversion mysql_get_client_version
|
||||
# define __mysql_client_info mysql_get_client_info
|
||||
# define __mysql_init mysql_init
|
||||
# define __mysql_open mysql_real_connect
|
||||
# define __mysql_close mysql_close
|
||||
# define __mysql_options mysql_options
|
||||
# define __mysql_autocommit mysql_autocommit
|
||||
# define __mysql_errno mysql_errno
|
||||
# define __mysql_error mysql_error
|
||||
# define __mysql_query mysql_query
|
||||
# define __mysql_num_fields mysql_num_fields
|
||||
# define __mysql_fetch_fields mysql_fetch_fields
|
||||
# define __mysql_fetch_row mysql_fetch_row
|
||||
# define __mysql_store_result mysql_store_result
|
||||
# define __mysql_num_rows mysql_num_rows
|
||||
# define __mysql_free_result mysql_free_result
|
||||
# define __mysql_affected_rows mysql_affected_rows
|
||||
# define __mysql_set_character_set mysql_set_character_set
|
||||
# define __mysql_character_set_name mysql_character_set_name
|
||||
|
||||
#endif
|
||||
# endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -225,9 +225,9 @@ bool http_client::write_gzip(ostream& out, const void* data, size_t len)
|
||||
gzip_total_in_ += len;
|
||||
|
||||
// 计算 crc32 数据校验和
|
||||
gzip_crc32_ = crc32(gzip_crc32_, (const Bytef*) data,
|
||||
(unsigned) len);
|
||||
gzip_crc32_ = zstream_->crc32_update(gzip_crc32_, data, len);
|
||||
|
||||
// 对该段数据进行压缩处理
|
||||
if (!zstream_->zip_update((const char*) data, len, buf_))
|
||||
{
|
||||
logger_error("zip_update error!");
|
||||
@ -356,7 +356,7 @@ bool http_client::write_head(const http_header& header)
|
||||
}
|
||||
|
||||
// 初始化 crc32 校验和
|
||||
gzip_crc32_ = crc32(0, Z_NULL, 0);
|
||||
gzip_crc32_ = zstream_->crc32_update(0, Z_NULL, 0);
|
||||
// 初始化非压缩数据总长度
|
||||
gzip_total_in_ = 0;
|
||||
}
|
||||
|
@ -324,12 +324,12 @@ bool redis_string::getrange(const char* key, size_t key_len,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool redis_string::setbit(const char* key, unsigned offset, bool bit)
|
||||
bool redis_string::setbit_(const char* key, unsigned offset, bool bit)
|
||||
{
|
||||
return setbit(key, strlen(key), offset, bit);
|
||||
return setbit_(key, strlen(key), offset, bit);
|
||||
}
|
||||
|
||||
bool redis_string::setbit(const char* key, size_t len,
|
||||
bool redis_string::setbit_(const char* key, size_t len,
|
||||
unsigned offset, bool bit)
|
||||
{
|
||||
const char* argv[4];
|
||||
|
@ -4,22 +4,25 @@
|
||||
#include "acl_cpp/stdlib/string.hpp"
|
||||
#include "acl_cpp/stdlib/zlib_stream.hpp"
|
||||
|
||||
#define HAVE_H_ZLIB
|
||||
#ifndef HAS_ZLIB
|
||||
# define HAS_ZLIB
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_H_ZLIB
|
||||
# if defined(ACL_WINDOWS) || defined(USE_DYNAMIC)
|
||||
#if defined(HAS_ZLIB) || defined(HAS_ZLIB_DLL)
|
||||
# if defined(ACL_CPP_DLL) || defined(HAS_ZLIB_DLL)
|
||||
|
||||
typedef int (*deflateInit_fn)(z_stream*, int, const char*, int);
|
||||
typedef int (*deflateInit2_fn)(z_stream*, int, int, int, int, int);
|
||||
typedef int (*deflate_fn)(z_stream*, int);
|
||||
typedef int (*deflateReset_fn)(z_stream*);
|
||||
typedef int (*deflateEnd_fn)(z_stream*);
|
||||
typedef int (*deflateInit_fn)(z_stream*, int, const char*, int);
|
||||
typedef int (*deflateInit2_fn)(z_stream*, int, int, int, int, int);
|
||||
typedef int (*deflate_fn)(z_stream*, int);
|
||||
typedef int (*deflateReset_fn)(z_stream*);
|
||||
typedef int (*deflateEnd_fn)(z_stream*);
|
||||
|
||||
typedef int (*inflateInit_fn)(z_stream*, int, const char*, int);
|
||||
typedef int (*inflateInit2_fn)(z_stream*, int, int, int, int, int);
|
||||
typedef int (*inflate_fn)(z_stream*, int);
|
||||
typedef int (*inflateReset_fn)(z_stream*);
|
||||
typedef int (*inflateEnd_fn)(z_stream*);
|
||||
typedef int (*inflateInit_fn)(z_stream*, int, const char*, int);
|
||||
typedef int (*inflateInit2_fn)(z_stream*, int, int, int, int, int);
|
||||
typedef int (*inflate_fn)(z_stream*, int);
|
||||
typedef int (*inflateReset_fn)(z_stream*);
|
||||
typedef int (*inflateEnd_fn)(z_stream*);
|
||||
typedef unsigned long (*crc32_fn)(unsigned long, const Bytef*, unsigned);
|
||||
|
||||
static deflateInit_fn __deflateInit = NULL;
|
||||
static deflateInit2_fn __deflateInit2 = NULL;
|
||||
@ -30,9 +33,11 @@ static inflateInit_fn __inflateInit = NULL;
|
||||
static inflate_fn __inflate = NULL;
|
||||
static inflateReset_fn __inflateReset = NULL;
|
||||
static inflateEnd_fn __inflateEnd = NULL;
|
||||
static crc32_fn __crc32 = NULL;
|
||||
|
||||
static acl_pthread_once_t __zlib_once = ACL_PTHREAD_ONCE_INIT;
|
||||
static ACL_DLL_HANDLE __zlib_dll = NULL;
|
||||
static acl::string __zlib_path;
|
||||
|
||||
// 程序退出时释放动态加载的 zlib.dll 库
|
||||
static void __zlib_dll_unload(void)
|
||||
@ -41,7 +46,7 @@ static void __zlib_dll_unload(void)
|
||||
{
|
||||
acl_dlclose(__zlib_dll);
|
||||
__zlib_dll = NULL;
|
||||
logger("zlib.dll unload ok");
|
||||
logger("%s unload ok", __zlib_path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,62 +56,79 @@ static void __zlib_dll_load(void)
|
||||
if (__zlib_dll != NULL)
|
||||
logger_fatal("__zlib_dll not null");
|
||||
|
||||
const char* path;
|
||||
const char* ptr = acl::zlib_stream::get_loadpath();
|
||||
if (ptr)
|
||||
path = ptr;
|
||||
else
|
||||
#ifdef ACL_WINDOWS
|
||||
__zlib_dll = acl_dlopen("zlib.dll");
|
||||
path = "zlib.dll";
|
||||
#else
|
||||
__zlib_dll = acl_dlopen("libz.so");
|
||||
path = "/usr/lib/libz.so";
|
||||
#endif
|
||||
|
||||
__zlib_dll = acl_dlopen(path);
|
||||
|
||||
if (__zlib_dll == NULL)
|
||||
logger_fatal("load zlib.dll error: %s", acl_last_serror());
|
||||
logger_fatal("load %s error: %s", path, acl_last_serror());
|
||||
|
||||
// 记录动态库路径,以便于在动态库卸载时输出库路径名
|
||||
__zlib_path = path;
|
||||
|
||||
__deflateInit = (deflateInit_fn) acl_dlsym(__zlib_dll, "deflateInit_");
|
||||
if (__deflateInit == NULL)
|
||||
logger_fatal("load deflateInit from zlib.dll error: %s",
|
||||
acl_last_serror());
|
||||
logger_fatal("load deflateInit from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
__deflateInit2 = (deflateInit2_fn) acl_dlsym(__zlib_dll, "deflateInit2");
|
||||
if (__deflateInit2 == NULL)
|
||||
logger_fatal("load deflateInit from zlib.dll error: %s",
|
||||
acl_last_serror());
|
||||
logger_fatal("load deflateInit from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
__deflate = (deflate_fn) acl_dlsym(__zlib_dll, "deflate");
|
||||
if (__deflate == NULL)
|
||||
logger_fatal("load deflate from zlib.dll error: %s",
|
||||
acl_last_serror());
|
||||
logger_fatal("load deflate from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
__deflateReset = (deflateReset_fn) acl_dlsym(__zlib_dll, "deflateReset");
|
||||
if (__deflateReset == NULL)
|
||||
logger_fatal("load deflateReset from zlib.dll error: %s",
|
||||
acl_last_serror());
|
||||
logger_fatal("load deflateReset from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
__deflateEnd = (deflateEnd_fn) acl_dlsym(__zlib_dll, "deflateEnd");
|
||||
if (__deflateEnd == NULL)
|
||||
logger_fatal("load deflateEnd from zlib.dll error: %s",
|
||||
acl_last_serror());
|
||||
logger_fatal("load deflateEnd from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
__inflateInit = (inflateInit_fn) acl_dlsym(__zlib_dll, "inflateInit2_");
|
||||
if (__inflateInit == NULL)
|
||||
logger_fatal("load inflateInit from zlib.dll error: %s",
|
||||
acl_last_serror());
|
||||
logger_fatal("load inflateInit from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
__inflate = (inflate_fn) acl_dlsym(__zlib_dll, "inflate");
|
||||
if (__inflate == NULL)
|
||||
logger_fatal("load inflate from zlib.dll error: %s",
|
||||
acl_last_serror());
|
||||
logger_fatal("load inflate from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
__inflateReset = (inflateReset_fn) acl_dlsym(__zlib_dll, "inflateReset");
|
||||
if (__inflateReset == NULL)
|
||||
logger_fatal("load inflateReset from zlib.dll error: %s",
|
||||
acl_last_serror());
|
||||
logger_fatal("load inflateReset from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
__inflateEnd = (inflateEnd_fn) acl_dlsym(__zlib_dll, "inflateEnd");
|
||||
if (__inflateEnd == NULL)
|
||||
logger_fatal("load inflateEnd from zlib.dll error: %s",
|
||||
acl_last_serror());
|
||||
logger_fatal("load inflateEnd from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
logger("zlib.dll loaded");
|
||||
__crc32 = (crc32_fn) acl_dlsym(__zlib_dll, "__crc32");
|
||||
if (__crc32 == NULL)
|
||||
logger_fatal("load __crc32 from %s error: %s",
|
||||
path, acl_last_serror());
|
||||
|
||||
logger("%s loaded", path);
|
||||
atexit(__zlib_dll_unload);
|
||||
}
|
||||
|
||||
# else
|
||||
# define __deflateInit deflateInit_
|
||||
# define __deflateInit2 deflateInit2
|
||||
@ -117,8 +139,8 @@ static void __zlib_dll_load(void)
|
||||
# define __inflate inflate
|
||||
# define __inflateReset inflateReset
|
||||
# define __inflateEnd inflateEnd
|
||||
# define __crc32 crc32
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace acl
|
||||
{
|
||||
@ -134,6 +156,19 @@ static void __zlib_free(void* ctx acl_unused, void* ptr)
|
||||
acl_myfree(ptr);
|
||||
}
|
||||
|
||||
static string __loadpath;
|
||||
|
||||
void zlib_stream::set_loadpath(const char* path)
|
||||
{
|
||||
if (path && *path)
|
||||
__loadpath = path;
|
||||
}
|
||||
|
||||
const char* zlib_stream::get_loadpath()
|
||||
{
|
||||
return __loadpath.empty() ? NULL : __loadpath.c_str();
|
||||
}
|
||||
|
||||
zlib_stream::zlib_stream()
|
||||
{
|
||||
finished_ = false;
|
||||
@ -145,8 +180,8 @@ zlib_stream::zlib_stream()
|
||||
is_compress_ = true; // 默认为压缩状态
|
||||
flush_ = zlib_flush_off;
|
||||
|
||||
#ifdef HAVE_H_ZLIB
|
||||
#if defined(ACL_WINDOWS) || defined(USE_DYNAMIC)
|
||||
#ifdef HAS_ZLIB
|
||||
# if defined(ACL_CPP_DLL) || defined(HAS_ZLIB_DLL)
|
||||
acl_pthread_once(&__zlib_once, __zlib_dll_load);
|
||||
# endif
|
||||
#endif
|
||||
@ -400,6 +435,11 @@ bool zlib_stream::zip_reset()
|
||||
return (__deflateEnd(zstream_) == Z_OK ? true : false);
|
||||
}
|
||||
|
||||
unsigned zlib_stream::crc32_update(unsigned n, const void* buf, size_t dlen)
|
||||
{
|
||||
return __crc32(n, (const Bytef*) buf, (unsigned) dlen);
|
||||
}
|
||||
|
||||
bool zlib_stream::unzip_begin(bool have_zlib_header /* = true */,
|
||||
int wsize /* = 15 */)
|
||||
{
|
||||
@ -498,3 +538,7 @@ void zlib_stream::clear()
|
||||
}
|
||||
|
||||
} // namespace acl
|
||||
|
||||
#else // !HAS_ZLIB && !HAS_ZLIB_DLL
|
||||
# error "You should define HAS_ZLIB or HAS_ZLIB_DLL first!"
|
||||
#endif
|
||||
|
@ -10,7 +10,8 @@ CFLAGS = -c -g -W \
|
||||
-Wpointer-arith \
|
||||
-D_REENTRANT \
|
||||
-D_POSIX_PTHREAD_SEMANTICS \
|
||||
-D_USE_FAST_MACRO
|
||||
-D_USE_FAST_MACRO \
|
||||
-Wno-unused-parameter -Wno-sign-compare
|
||||
#-Wshadow
|
||||
#-Waggregate-return
|
||||
###########################################################
|
||||
|
Loading…
Reference in New Issue
Block a user