Mod aaa-12 用户认证模块释放数据库句柄

RCA:
SOL:
修改人:zhouzian
检视人:zhouzian
This commit is contained in:
zhouzian 2019-09-12 16:21:42 +08:00
parent c454de6c7b
commit 436ded6cf4
1 changed files with 8 additions and 8 deletions

View File

@ -17,6 +17,8 @@
#define UDESIZE (63) #define UDESIZE (63)
#define UPWDSIZE (63) #define UPWDSIZE (63)
void * g_auth_hdbc = NULL; //用户认证连接句柄
typedef struct user_auth typedef struct user_auth
{ {
unsigned short ID; //用户id unsigned short ID; //用户id
@ -36,7 +38,7 @@ typedef struct user_auth
#define AUTH_STRING2TIME_T(time_char,time_int) \ #define AUTH_STRING2TIME_T(time_char,time_int) \
do { \ do { \
struct tm tm_time; \ struct tm tm_time; \
int res = sscanf(time_char, "%4d-%2d-%2d %2d:%2d:%2d", \ sscanf(time_char, "%4d-%2d-%2d %2d:%2d:%2d", \
&tm_time.tm_year, &tm_time.tm_mon, &tm_time.tm_mday, \ &tm_time.tm_year, &tm_time.tm_mon, &tm_time.tm_mday, \
&tm_time.tm_hour, &tm_time.tm_min, &tm_time.tm_sec); \ &tm_time.tm_hour, &tm_time.tm_min, &tm_time.tm_sec); \
tm_time.tm_year -= 1900; \ tm_time.tm_year -= 1900; \
@ -484,17 +486,15 @@ void user_auth_login(char* username, char* password, USER_AUTH_RET *auth_result)
} }
/* 连接数据库 */ /* 连接数据库 */
auth_hdbc = connect_database(20); if(NULL == g_auth_hdbc)
if(NULL == auth_hdbc)
{ {
auth_result->ret = AUTH_FAIL_DATABASE; g_auth_hdbc = connect_database(20);
return;
} }
//2、数据库查询配置数据 //2、数据库查询配置数据
int config_data[3] = {0,0,0}; int config_data[3] = {0,0,0};
bool ret_getconfig = get_config_data(auth_hdbc, config_data); bool ret_getconfig = get_config_data(g_auth_hdbc, config_data);
if (!ret_getconfig) if (!ret_getconfig)
{ {
auth_result->ret = AUTH_FAIL_LACKINFO; auth_result->ret = AUTH_FAIL_LACKINFO;
@ -509,7 +509,7 @@ void user_auth_login(char* username, char* password, USER_AUTH_RET *auth_result)
//3、根据用户名查询用户信息-用户id和用户组id //3、根据用户名查询用户信息-用户id和用户组id
/* 数据库查询 */ /* 数据库查询 */
bool ret_getuser = get_user_from_database(username, auth_hdbc, &user_info, &sql_num); bool ret_getuser = get_user_from_database(username, g_auth_hdbc, &user_info, &sql_num);
if(!ret_getuser) if(!ret_getuser)
{ {
auth_result->ret = AUTH_FAIL_DATABASE; auth_result->ret = AUTH_FAIL_DATABASE;
@ -633,7 +633,7 @@ void user_auth_login(char* username, char* password, USER_AUTH_RET *auth_result)
auth_result->user_id = user_id; auth_result->user_id = user_id;
auth_result->group_id = group_id; auth_result->group_id = group_id;
disconnect_database(20, auth_hdbc); //disconnect_database(20, auth_hdbc);
return; return;
} }