Skip to content

Commit

Permalink
fixed bugs in db pool for setting charset.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuxin committed Nov 3, 2016
1 parent d236842 commit 3bf64fa
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ endif
##############################################################################

.PHONY = check help all_lib all samples all clean install uninstall uninstall_all build_bin build_src build_one
VERSION = 3.2.2
VERSION = 3.2.2_2

help:
@(echo "usage: make help|all|all_lib|all_samples|clean|install|uninstall|uninstall_all|build_bin|build_src|build_one")
Expand Down
1 change: 1 addition & 0 deletions changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
�޸���ʷ�б���
------------------------------------------------------------------------
101) 2016.11.3 --- acl 3.2.2.2 �汾������
100) 2016.11.2 --- acl 3.2.2.1 �汾������
99) 2016.11.1 --- acl 3.2.2 �汾������
98) 2016.9.7 --- acl 3.2.1 �汾������
Expand Down
2 changes: 1 addition & 1 deletion lib_acl/src/init/acl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "init.h"

static char *version = "acl_3.2.2";
static char *version = "acl_3.2.2_2";

const char *acl_version(void)
{
Expand Down
5 changes: 5 additions & 0 deletions lib_acl_cpp/changes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
�޸���ʷ�б���

-----------------------------------------------------------------------
449) 2016.11.2
449.1) bugfix: db_pool.cpp �еķ��� peek_open ��ֹ��̬�����ַ�������Ϊ���ܻ�����
�̳߳�ͻ���⣬�����Ҫ�����ַ����������� db_mysql/db_sqlite �Ĺ�����ָ�������� db_mysql
�࣬��ʹ�� mysql_conf ����г�ʼ�� db_mysql ����ʱ���� mysql_conf ��ǰ�趨�ַ���

448) 2016.11.2
448.1) bugfix: db_mysql.cpp ���� db_mysql �Ĺ��캯��û����� charset_ ��ʼ��
�п��ܻ���ɱ���
Expand Down
8 changes: 1 addition & 7 deletions lib_acl_cpp/include/acl_cpp/db/db_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ class ACL_CPP_API db_pool : public connect_pool
* 显式地再调用 db_handle::open 过程;
* 用完后必须调用 db_pool->put(db_handle*) 将连接归还至数据库连接池,
* 由该函数获得的连接句柄不能 delete,否则会造成连接池的内部计数器出错
* @param charset {const char*} 打开数据库时采用的字符集
* @return {db_handle*} 数据库连接对象,返回空表示出错
*/
db_handle* peek_open(const char* charset = NULL);
db_handle* peek_open();

/**
* 获得当前数据库连接池的最大连接数限制
Expand Down Expand Up @@ -57,11 +56,6 @@ class ACL_CPP_API db_pool : public connect_pool
{
set_idle_ttl(ttl);
}

protected:
// 虚函数,子类根据需要设置字符集,当 peek_open 被调用时,此函数
// 会先被调用用来设置数据库连接的字符集
virtual void set_charset(const char*) {}
};

class ACL_CPP_API db_guard : public connect_guard
Expand Down
3 changes: 0 additions & 3 deletions lib_acl_cpp/include/acl_cpp/db/mysql_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ class ACL_CPP_API mysql_pool : public db_pool
// 基类 connect_pool 纯虚函数:创建数据库连接句柄
connect_client* create_connect();

//@override
void set_charset(const char* charset);

private:
mysql_conf* conf_;
};
Expand Down
3 changes: 0 additions & 3 deletions lib_acl_cpp/include/acl_cpp/db/sqlite_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ class ACL_CPP_API sqlite_pool : public db_pool
// 基类 connect_pool 纯虚函数:创建数据库连接句柄
connect_client* create_connect();

//@override
void set_charset(const char* charset);

private:
// sqlite 数据文件名
char* dbfile_;
Expand Down
2 changes: 0 additions & 2 deletions lib_acl_cpp/src/db/db_mysql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,6 @@ void db_mysql::sane_mysql_init(const char* dbaddr, const char* dbname,

if (charset && *charset)
charset_ = charset;
else
charset_ = NULL;

dbflags_ = dbflags;
auto_commit_ = auto_commit;
Expand Down
5 changes: 1 addition & 4 deletions lib_acl_cpp/src/db/db_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ db_pool::db_pool(const char* dbaddr, size_t count, size_t idx /* = 0 */)
{
}

db_handle* db_pool::peek_open(const char* charset /* = NULL */)
db_handle* db_pool::peek_open(void)
{
if (charset)
set_charset(charset);

db_handle* conn = (db_handle*) peek();
if (conn == NULL)
logger_error("peek NULL");
Expand Down
6 changes: 0 additions & 6 deletions lib_acl_cpp/src/db/mysql_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,4 @@ connect_client* mysql_pool::create_connect()
return NEW db_mysql(*conf_);
}

void mysql_pool::set_charset(const char* charset)
{
if (charset)
conf_->set_charset(charset);
}

} // namespace acl
10 changes: 0 additions & 10 deletions lib_acl_cpp/src/db/sqlite_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,4 @@ connect_client* sqlite_pool::create_connect()
return NEW db_sqlite(dbfile_, charset_);
}

void sqlite_pool::set_charset(const char* charset)
{
if (charset == NULL || *charset == 0)
return;

if (charset_)
acl_myfree(charset_);
charset_ = acl_mystrdup(charset);
}

} // namespace acl

0 comments on commit 3bf64fa

Please sign in to comment.