aboutsummaryrefslogtreecommitdiff
path: root/src/sql.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-08-25 13:29:33 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-08-25 13:29:33 +0000
commite4b5d37def5023905e98bc0b6c6f81c2d56ba362 (patch)
tree76dbdd53079e4f05529c002284467820c8d5d0ef /src/sql.c
parent1107c4341552ecb568b43292fc219a73e0d49a0f (diff)
downloadwydawca-e4b5d37def5023905e98bc0b6c6f81c2d56ba362.tar.gz
wydawca-e4b5d37def5023905e98bc0b6c6f81c2d56ba362.tar.bz2
* configure.ac: Require mailutils for wydawca
* bootstrap: Require inttostr and strftime * wydawca/mail.h: New file * wydawca/mail.c: New file * wydawca/Makefile.am: Add mail.c and mail.h * wydawca/wydawca.c: Include mail.h (stat_mask_p, make_stat_expansion): New functions (logstats): Call mail_stats (main): Call initialize mailer subsystem * wydawca/sql.c, wydawca/sql.h: Keep usage reference count. Do not deinitialize unless it falls to 0. Do not initialize if it is > 0. * wydawca/verify.c (expand_param): Rewrite to allow long keywords All callers updated. * wydawca/wydawca.h (struct access_method): Keep reference count (struct directory_pair): verify_method and gpg_key_method are pointers to structs. (struct kw_expansion): kw is char* (count_collected_triplets): New function (method_new): New function * wydawca/config.c: reimplement verify-user and gpg-key New keywords mailer, admin-address, from-address, mail-admin-stat and admin-stat-message * wydawca/process.c: Close methods only when their reference count is 0. * wydawca/method.c: Likewise. (method_new): New function * wydawca/wydawca.rc: Update * wydawca/diskio.c: Minor changes * wydawca/triplet.c (count_collected_triplets): New function * jabberd/main.c: Minor change git-svn-id: file:///svnroot/wydawca/trunk@295 6bb4bd81-ecc2-4fd4-a2d4-9571d19c0d33
Diffstat (limited to 'src/sql.c')
-rw-r--r--src/sql.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/sql.c b/src/sql.c
index 95c601a..c1de81d 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -67,14 +67,17 @@ sql_init_method (struct access_method *method)
abort ();
}
- mysql_init (&conn->mysql);
- if (!mysql_real_connect (&conn->mysql, conn->host, conn->user,
- conn->password, conn->database, conn->port,
- conn->socket, 0))
+ if (conn->initcount++ == 0)
{
- logmsg (LOG_ERR, "Failed to connect to database %s: Error: %s\n",
- method->param[0], mysql_error (&conn->mysql));
- return 1;
+ mysql_init (&conn->mysql);
+ if (!mysql_real_connect (&conn->mysql, conn->host, conn->user,
+ conn->password, conn->database, conn->port,
+ conn->socket, 0))
+ {
+ logmsg (LOG_ERR, "Failed to connect to database %s: Error: %s\n",
+ method->param[0], mysql_error (&conn->mysql));
+ return 1;
+ }
}
method->v.sqlconn = conn;
return 0;
@@ -84,6 +87,11 @@ sql_init_method (struct access_method *method)
int
sql_done_method (struct access_method *method)
{
+ struct sqlconn *conn = method->v.sqlconn;
+ if (!conn || conn->initcount == 0)
+ return 0;
+ if (--conn->initcount)
+ return 0;
mysql_close (&method->v.sqlconn->mysql);
return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.