diff --git a/bot.c b/bot.c index f0cdec4..7b39f6d 100644 --- a/bot.c +++ b/bot.c @@ -304,6 +304,7 @@ row = mysql_fetch_row(res); sWriteSocket("MSG %s:.tv mode +O %s",row[0],nick); } + mysql_free_result(res); return(0x0); } @@ -328,6 +329,7 @@ if (res != 0x0) { if (mysql_num_rows(res) > 0) sWriteSocket("MSG %s:.tv mode +O %s",chan,nick); + mysql_free_result(res); } nick = strtok_r(NULL,":",&str_tok); ident = strtok_r(NULL,":",&str_tok); diff --git a/mysql.c b/mysql.c index 5b5052e..0c89b90 100644 --- a/mysql.c +++ b/mysql.c @@ -4,7 +4,7 @@ MYSQL *conn = 0x0; -//pthread_mutex_t mysqlMutex = PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t mysqlMutex = PTHREAD_MUTEX_INITIALIZER; int dbInit() { @@ -24,35 +24,35 @@ writeLog(0,"mysql_options() failed: To Set Reconnect\n"); } - //pthread_mutex_init(&mysqlMutex, NULL); + pthread_mutex_init(&mysqlMutex, NULL); writeLog(0,"Sucessful connection to the MySQL Database.\n"); return(0x0); } -MYSQL_RES *dbQuery(const char *query,short type) { +MYSQL_RES *dbQuery(const char *query,short store) { MYSQL_RES *res_set = 0x0; - //pthread_mutex_lock(&mysqlMutex); + pthread_mutex_lock(&mysqlMutex); writeLog(0,"Query: %s\n",query); if (mysql_query(conn,query) != 0x0) { writeLog(0,"mysql_query() failed: Error %u (%s)\n.", mysql_errno(conn), mysql_error(conn)); - //pthread_mutex_unlock(&mysqlMutex); + pthread_mutex_unlock(&mysqlMutex); return(0x0); } - if (type == 1) { - res_set = mysql_store_result(conn); + if (store == 1) { + res_set = mysql_store_result(conn); if (res_set == 0x0) { writeLog(0,"mysql_store_result() failed: Error %u (%s)\n.", mysql_errno(conn), mysql_error(conn)); - //pthread_mutex_unlock(&mysqlMutex); + pthread_mutex_unlock(&mysqlMutex); return(0x0); } } - //pthread_mutex_unlock(&mysqlMutex); + pthread_mutex_unlock(&mysqlMutex); return(res_set); }