mirror of
https://bitbucket.org/jsuto/piler.git
synced 2026-04-05 17:39:20 +02:00
preparing for database consolidation
This commit is contained in:
14
src/retr.c
14
src/retr.c
@@ -110,7 +110,6 @@ int handle_pilerget_request(int new_sd, struct __data *data, struct __config *cf
|
||||
char *q, buf[MAXBUFSIZE], puf[MAXBUFSIZE], muf[TINYBUFSIZE], resp[MAXBUFSIZE];
|
||||
struct session_data sdata;
|
||||
int db_conn=0;
|
||||
int rc;
|
||||
struct __counters counters;
|
||||
|
||||
struct timezone tz;
|
||||
@@ -140,15 +139,8 @@ int handle_pilerget_request(int new_sd, struct __data *data, struct __config *cf
|
||||
db_conn = 0;
|
||||
|
||||
#ifdef NEED_MYSQL
|
||||
rc = 1;
|
||||
mysql_init(&(sdata.mysql));
|
||||
mysql_options(&(sdata.mysql), MYSQL_OPT_CONNECT_TIMEOUT, (const char*)&cfg->mysql_connect_timeout);
|
||||
mysql_options(&(sdata.mysql), MYSQL_OPT_RECONNECT, (const char*)&rc);
|
||||
|
||||
if(mysql_real_connect(&(sdata.mysql), cfg->mysqlhost, cfg->mysqluser, cfg->mysqlpwd, cfg->mysqldb, cfg->mysqlport, cfg->mysqlsocket, 0)){
|
||||
if(open_database(&sdata, cfg) == OK){
|
||||
db_conn = 1;
|
||||
mysql_real_query(&(sdata.mysql), "SET NAMES utf8", strlen("SET NAMES utf8"));
|
||||
mysql_real_query(&(sdata.mysql), "SET CHARACTER SET utf8", strlen("SET CHARACTER SET utf8"));
|
||||
}
|
||||
else
|
||||
syslog(LOG_PRIORITY, "%s", ERR_MYSQL_CONNECT);
|
||||
@@ -156,7 +148,7 @@ int handle_pilerget_request(int new_sd, struct __data *data, struct __config *cf
|
||||
|
||||
if(db_conn == 1 && create_prepared_statements(&sdata, data) == ERR){
|
||||
close_prepared_statements(data);
|
||||
mysql_close(&(sdata.mysql));
|
||||
close_database(&sdata);
|
||||
db_conn = 0;
|
||||
}
|
||||
|
||||
@@ -273,7 +265,7 @@ QUITTING:
|
||||
|
||||
#ifdef NEED_MYSQL
|
||||
close_prepared_statements(data);
|
||||
mysql_close(&(sdata.mysql));
|
||||
close_database(&sdata);
|
||||
#endif
|
||||
|
||||
SSL_shutdown(data->ssl);
|
||||
|
||||
Reference in New Issue
Block a user