diff --git a/libs/src/lighttpd-1.4.51/src/user_auth.c b/libs/src/lighttpd-1.4.51/src/user_auth.c index 5be36fb7b..83dad4d27 100644 --- a/libs/src/lighttpd-1.4.51/src/user_auth.c +++ b/libs/src/lighttpd-1.4.51/src/user_auth.c @@ -17,6 +17,8 @@ #define UDESIZE (63) #define UPWDSIZE (63) +void * g_auth_hdbc = NULL; //用户认证连接句柄 + typedef struct user_auth { unsigned short ID; //用户id @@ -36,7 +38,7 @@ typedef struct user_auth #define AUTH_STRING2TIME_T(time_char,time_int) \ do { \ 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_hour, &tm_time.tm_min, &tm_time.tm_sec); \ 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 == auth_hdbc) + if(NULL == g_auth_hdbc) { - auth_result->ret = AUTH_FAIL_DATABASE; - return; + g_auth_hdbc = connect_database(20); } //2、数据库查询配置数据 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) { 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 /* 数据库查询 */ - 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) { 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->group_id = group_id; - disconnect_database(20, auth_hdbc); + //disconnect_database(20, auth_hdbc); return; }