From afb6d55cc032817d25d32a1979a2a3eea4bf93d4 Mon Sep 17 00:00:00 2001 From: "geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b" Date: Sun, 10 Sep 2006 17:10:24 +0000 Subject: BUILD : 1.7.15 (1150) BUGS : 595 NOTES : Fixed MySQL making a new connection for each query (bit TOO enthousiastic?) git-svn-id: svn://svn.anope.org/anope/trunk@1150 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@873 5417fbe8-f217-4b02-8779-1006273d7864 --- src/mysql.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/mysql.c') diff --git a/src/mysql.c b/src/mysql.c index c7dfc8fbe..0dcdf95df 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -22,6 +22,8 @@ MYSQL_RES *mysql_res; /* MySQL Result */ MYSQL_FIELD *mysql_fields; /* MySQL Fields */ MYSQL_ROW mysql_row; /* MySQL Row */ +int mysql_is_connected = 0; /* Are we currently connected? */ + /*************************************************************************/ void db_mysql_error(int severity, char *msg) @@ -87,7 +89,11 @@ int db_mysql_open() /* If MySQL is disabled, return 0 */ if (!do_mysql) return 0; - + + /* If we're already connected, return 1 */ + if (mysql_is_connected) + return 1; + mysql = mysql_init(NULL); if (mysql == NULL) db_mysql_error(MYSQL_WARNING, "Unable to create mysql object"); @@ -112,7 +118,9 @@ int db_mysql_open() return 0; } } - + + mysql_is_connected = 1; + return 1; } @@ -190,6 +198,9 @@ int db_mysql_close() if (mysql_res) mysql_free_result(mysql_res); mysql_close(mysql); + + mysql_is_connected = 0; + return 1; } -- cgit