diff options
author | dane dane@31f1291d-b8d6-0310-a050-a5561fc1590b <dane dane@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2006-08-21 17:48:23 +0000 |
---|---|---|
committer | dane dane@31f1291d-b8d6-0310-a050-a5561fc1590b <dane dane@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2006-08-21 17:48:23 +0000 |
commit | d222e75a6dc2a6eb5c48ce6f7a121286b5da7142 (patch) | |
tree | 5c668e5b7f94272053ebace774dc628eba3e4d43 /src/mysql.c | |
parent | fee55f45163a9ea75e29187a4d3dd25e1e6c37bb (diff) |
BUILD : 1.7.15 (1138) BUGS : 585 NOTES : Another attempt at fixing db_mysql_query()
git-svn-id: svn://svn.anope.org/anope/trunk@1138 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@861 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/mysql.c')
-rw-r--r-- | src/mysql.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/src/mysql.c b/src/mysql.c index c96f1de14..c7dfc8fbe 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -121,11 +121,12 @@ int db_mysql_open() int db_mysql_query(char *sql) { - int result, lcv; + int lcv; char *s; if (!do_mysql) { - return -1; + /* Error is 1 */ + return 1; } if (debug) { @@ -138,43 +139,26 @@ int db_mysql_query(char *sql) /* Try as many times as configured in MysqlRetries */ for (lcv = 0; lcv < MysqlRetries; lcv++) { - if (db_mysql_open()) { - - /* Attempt to run query */ - result = mysql_query(mysql, sql); - if (result) { - switch (mysql_errno(mysql)) { - case CR_COMMANDS_OUT_OF_SYNC: - case CR_SERVER_GONE_ERROR: - case CR_UNKNOWN_ERROR: - case CR_SERVER_LOST: - - /* If we get here, we could not run the query */ - log_perror("Unable to run query: %s\n", - mysql_error(mysql)); - - break; - - default: - - /* Success... return result */ - return (result); + if (db_mysql_open() && (!mysql_query(mysql, sql))) { + + /* Success is 0 */ + return 0; - } - } else { - /* Non-error */ - return (result); - } } + /* If we get here, we could not run the query */ + log_perror("Unable to run query: %s\n", mysql_error(mysql)); + /* Wait for MysqlRetryGap seconds and try again */ sleep(MysqlRetryGap); } + /* Unable to run the query */ db_mysql_error(MYSQL_ERROR, "query"); - return (0); + /* Error is 1 */ + return 1; } @@ -255,7 +239,7 @@ char *db_mysql_secure(char *pass) } #else - if (!pass) { + if (pass) { snprintf(epass, sizeof(epass), "''"); } else if ((!MysqlSecure) || (strcmp(MysqlSecure, "") == 0)) { snprintf(epass, sizeof(epass), "'%s'", pass); |