mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 00:31:58 +01:00
added missing mysql_stmt_close functions
This commit is contained in:
parent
b4d13833b8
commit
b0be982ca2
@ -18,7 +18,7 @@
|
||||
|
||||
int store_attachments(struct session_data *sdata, struct _state *state, struct __config *cfg){
|
||||
uint64 id=0;
|
||||
int i, found, affected_rows;
|
||||
int i, rc=1, found, affected_rows;
|
||||
char s[SMALLBUFSIZE];
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
@ -31,14 +31,14 @@ int store_attachments(struct session_data *sdata, struct _state *state, struct _
|
||||
stmt = mysql_stmt_init(&(sdata->mysql));
|
||||
if(!stmt){
|
||||
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_init() error", sdata->ttmpfile, SQL_ATTACHMENT_TABLE);
|
||||
return 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
snprintf(s, sizeof(s)-1, "INSERT INTO %s (`piler_id`,`attachment_id`,`sig`,`name`,`type`,`size`,`ptr`) VALUES(?,?,?,?,?,?,?)", SQL_ATTACHMENT_TABLE);
|
||||
|
||||
if(mysql_stmt_prepare(stmt, s, strlen(s))){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_prepare() error: %s", sdata->ttmpfile, SQL_ATTACHMENT_TABLE, mysql_stmt_error(stmt));
|
||||
return 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ int store_attachments(struct session_data *sdata, struct _state *state, struct _
|
||||
if(found == 0){
|
||||
if(store_file(sdata, state->attachments[i].internalname, 0, 0, cfg) == 0){
|
||||
syslog(LOG_PRIORITY, "%s: error storing attachment: %s", sdata->ttmpfile, state->attachments[i].internalname);
|
||||
return 1;
|
||||
goto CLOSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,19 +113,19 @@ int store_attachments(struct session_data *sdata, struct _state *state, struct _
|
||||
|
||||
if(mysql_stmt_bind_param(stmt, bind)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_bind_param() error: %s", sdata->ttmpfile, SQL_ATTACHMENT_TABLE, mysql_stmt_error(stmt));
|
||||
return 1;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
if(mysql_stmt_execute(stmt)){
|
||||
syslog(LOG_PRIORITY, "%s attachment sql error: *%s*", sdata->ttmpfile, mysql_error(&(sdata->mysql)));
|
||||
return 1;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
affected_rows = mysql_stmt_affected_rows(stmt);
|
||||
if(affected_rows != 1){
|
||||
syslog(LOG_PRIORITY, "%s attachment sql error: affected rows: %d", sdata->ttmpfile, affected_rows);
|
||||
return 1;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
}
|
||||
@ -135,7 +135,12 @@ int store_attachments(struct session_data *sdata, struct _state *state, struct _
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
rc = 0;
|
||||
|
||||
CLOSE:
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@ -169,12 +174,12 @@ int query_attachment_pointers(struct session_data *sdata, uint64 ptr, char *pile
|
||||
|
||||
|
||||
if(mysql_stmt_bind_param(stmt, bind)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
if(mysql_stmt_execute(stmt)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
@ -193,21 +198,21 @@ int query_attachment_pointers(struct session_data *sdata, uint64 ptr, char *pile
|
||||
|
||||
|
||||
if(mysql_stmt_bind_result(stmt, bind)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
if(mysql_stmt_store_result(stmt)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
if(!mysql_stmt_fetch(stmt)){
|
||||
if(is_null[0] == 0){
|
||||
//printf("piler id: *%s*, id: %d\n", piler_id, *id);
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
CLOSE:
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
ENDE:
|
||||
@ -249,12 +254,12 @@ int query_attachments(struct session_data *sdata, struct ptr_array *ptr_arr, str
|
||||
len = strlen(sdata->ttmpfile); bind[0].length = &len;
|
||||
|
||||
if(mysql_stmt_bind_param(stmt, bind)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
if(mysql_stmt_execute(stmt)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
@ -274,13 +279,13 @@ int query_attachments(struct session_data *sdata, struct ptr_array *ptr_arr, str
|
||||
|
||||
if(mysql_stmt_bind_result(stmt, bind)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_bind_result() error: %s", sdata->ttmpfile, SQL_METADATA_TABLE, mysql_stmt_error(stmt));
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
if(mysql_stmt_store_result(stmt)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_store_result() error: %s", sdata->ttmpfile, SQL_METADATA_TABLE, mysql_stmt_error(stmt));
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
while(!mysql_stmt_fetch(stmt)){
|
||||
@ -291,7 +296,7 @@ int query_attachments(struct session_data *sdata, struct ptr_array *ptr_arr, str
|
||||
rc = query_attachment_pointers(sdata, ptr, &(ptr_arr[id].piler_id[0]), &(ptr_arr[id].attachment_id), cfg);
|
||||
if(!rc){
|
||||
attachments = -1;
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -303,6 +308,7 @@ int query_attachments(struct session_data *sdata, struct ptr_array *ptr_arr, str
|
||||
}
|
||||
}
|
||||
|
||||
CLOSE:
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
ENDE:
|
||||
|
@ -144,7 +144,7 @@ struct _state {
|
||||
int n_attachments;
|
||||
struct attachment attachments[MAX_ATTACHMENTS];
|
||||
|
||||
char b_from[SMALLBUFSIZE], b_from_domain[SMALLBUFSIZE], b_to[SMALLBUFSIZE], b_to_domain[SMALLBUFSIZE], b_subject[MAXBUFSIZE], b_body[BIGBUFSIZE];
|
||||
char b_from[SMALLBUFSIZE], b_from_domain[SMALLBUFSIZE], b_to[MAXBUFSIZE], b_to_domain[SMALLBUFSIZE], b_subject[MAXBUFSIZE], b_body[BIGBUFSIZE];
|
||||
};
|
||||
|
||||
|
||||
|
@ -48,13 +48,13 @@ int is_existing_message_id(struct session_data *sdata, struct _state *state, str
|
||||
|
||||
if(mysql_stmt_bind_param(stmt, bind)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_bind_param() error: %s", sdata->ttmpfile, SQL_METADATA_TABLE, mysql_stmt_error(stmt));
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
if(mysql_stmt_execute(stmt)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_execute() error: %s", sdata->ttmpfile, SQL_METADATA_TABLE, mysql_stmt_error(stmt));
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
@ -69,13 +69,13 @@ int is_existing_message_id(struct session_data *sdata, struct _state *state, str
|
||||
|
||||
if(mysql_stmt_bind_result(stmt, bind)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_bind_result() error: %s", sdata->ttmpfile, SQL_METADATA_TABLE, mysql_stmt_error(stmt));
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
if(mysql_stmt_store_result(stmt)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_store_result() error: %s", sdata->ttmpfile, SQL_METADATA_TABLE, mysql_stmt_error(stmt));
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
if(!mysql_stmt_fetch(stmt)){
|
||||
@ -83,6 +83,7 @@ int is_existing_message_id(struct session_data *sdata, struct _state *state, str
|
||||
if(is_null[0] == 0) rc = 1;
|
||||
}
|
||||
|
||||
CLOSE:
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
ENDE:
|
||||
@ -113,7 +114,7 @@ int is_body_digest_already_stored(struct session_data *sdata, struct _state *sta
|
||||
|
||||
|
||||
int store_index_data(struct session_data *sdata, struct _state *state, uint64 id, struct __config *cfg){
|
||||
int rc;
|
||||
int rc=ERR;
|
||||
char *subj, s[SMALLBUFSIZE];
|
||||
|
||||
MYSQL_STMT *stmt;
|
||||
@ -127,7 +128,7 @@ int store_index_data(struct session_data *sdata, struct _state *state, uint64 id
|
||||
stmt = mysql_stmt_init(&(sdata->mysql));
|
||||
if(!stmt){
|
||||
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_init() error", sdata->ttmpfile, SQL_SPHINX_TABLE);
|
||||
return ERR;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@ -136,7 +137,7 @@ int store_index_data(struct session_data *sdata, struct _state *state, uint64 id
|
||||
|
||||
if(mysql_stmt_prepare(stmt, s, strlen(s))){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_prepare() error: %s", sdata->ttmpfile, SQL_SPHINX_TABLE, mysql_stmt_error(stmt));
|
||||
return ERR;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@ -187,24 +188,27 @@ int store_index_data(struct session_data *sdata, struct _state *state, uint64 id
|
||||
|
||||
if(mysql_stmt_bind_param(stmt, bind)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_bind_param() error: %s", sdata->ttmpfile, SQL_SPHINX_TABLE, mysql_stmt_error(stmt));
|
||||
return ERR;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
rc = mysql_stmt_execute(stmt);
|
||||
|
||||
if(rc){
|
||||
if(mysql_stmt_execute(stmt)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_execute error: *%s*", sdata->ttmpfile, SQL_SPHINX_TABLE, mysql_error(&(sdata->mysql)));
|
||||
return ERR;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
rc = OK;
|
||||
|
||||
return OK;
|
||||
CLOSE:
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int store_recipients(struct session_data *sdata, char *to, uint64 id, struct __config *cfg){
|
||||
int rc, ret=OK;
|
||||
int ret=OK;
|
||||
char *p, *q, s[SMALLBUFSIZE], puf[SMALLBUFSIZE];
|
||||
|
||||
MYSQL_STMT *stmt;
|
||||
@ -247,13 +251,12 @@ int store_recipients(struct session_data *sdata, char *to, uint64 id, struct __c
|
||||
|
||||
if(mysql_stmt_bind_param(stmt, bind)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_bind_param() error: %s", sdata->ttmpfile, SQL_RECIPIENT_TABLE, mysql_stmt_error(stmt));
|
||||
return ERR;
|
||||
ret = ERR;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
rc = mysql_stmt_execute(stmt);
|
||||
|
||||
if(rc){
|
||||
if(mysql_stmt_execute(stmt)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_execute error: *%s*", sdata->ttmpfile, SQL_RECIPIENT_TABLE, mysql_error(&(sdata->mysql)));
|
||||
ret = ERR;
|
||||
}
|
||||
@ -265,6 +268,10 @@ int store_recipients(struct session_data *sdata, char *to, uint64 id, struct __c
|
||||
|
||||
} while(p);
|
||||
|
||||
|
||||
CLOSE:
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -336,7 +343,7 @@ int store_meta_data(struct session_data *sdata, struct _state *state, struct __c
|
||||
|
||||
if(mysql_stmt_bind_param(stmt, bind)){
|
||||
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_bind_param() error: %s", sdata->ttmpfile, SQL_METADATA_TABLE, mysql_stmt_error(stmt));
|
||||
return ERR;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
@ -366,6 +373,9 @@ int store_meta_data(struct session_data *sdata, struct _state *state, struct __c
|
||||
}
|
||||
}
|
||||
|
||||
CLOSE:
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, stru
|
||||
|
||||
if(is_email_address_on_my_domains(puf, cfg) == 1) sdata->internal_sender = 1;
|
||||
}
|
||||
else if((state->message_state == MSG_TO || state->message_state == MSG_CC) && state->is_1st_header == 1 && does_it_seem_like_an_email_address(puf) == 1 && strlen(state->b_to) < SMALLBUFSIZE-len-1){
|
||||
else if((state->message_state == MSG_TO || state->message_state == MSG_CC) && state->is_1st_header == 1 && does_it_seem_like_an_email_address(puf) == 1 && strlen(state->b_to) < MAXBUFSIZE-len-1){
|
||||
|
||||
if(is_string_on_list(state->rcpt, puf) == 0){
|
||||
append_list(&(state->rcpt), puf);
|
||||
|
@ -76,7 +76,7 @@ void init_state(struct _state *state){
|
||||
|
||||
memset(state->b_from, 0, SMALLBUFSIZE);
|
||||
memset(state->b_from_domain, 0, SMALLBUFSIZE);
|
||||
memset(state->b_to, 0, SMALLBUFSIZE);
|
||||
memset(state->b_to, 0, MAXBUFSIZE);
|
||||
memset(state->b_to_domain, 0, SMALLBUFSIZE);
|
||||
memset(state->b_subject, 0, MAXBUFSIZE);
|
||||
memset(state->b_body, 0, BIGBUFSIZE);
|
||||
|
@ -48,12 +48,12 @@ uint64 get_id_by_piler_id(struct session_data *sdata, char *digest, char *bodydi
|
||||
|
||||
|
||||
if(mysql_stmt_bind_param(stmt, bind)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
if(mysql_stmt_execute(stmt)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
@ -77,16 +77,18 @@ uint64 get_id_by_piler_id(struct session_data *sdata, char *digest, char *bodydi
|
||||
bind[2].length = &len;
|
||||
|
||||
if(mysql_stmt_bind_result(stmt, bind)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
|
||||
if(mysql_stmt_store_result(stmt)){
|
||||
goto ENDE;
|
||||
goto CLOSE;
|
||||
}
|
||||
|
||||
mysql_stmt_fetch(stmt);
|
||||
|
||||
|
||||
CLOSE:
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
ENDE:
|
||||
|
Loading…
Reference in New Issue
Block a user