]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Attempt to import clean unloading wrt. pqsql into Q9.
authorChris Porter <redacted>
Tue, 11 Mar 2008 01:58:53 +0000 (01:58 +0000)
committerChris Porter <redacted>
Tue, 11 Mar 2008 01:58:53 +0000 (01:58 +0000)
21 files changed:
chanserv/authcmds/Makefile
chanserv/authcmds/authhistory.c
chanserv/authcmds/commandlist.c
chanserv/authcmds/init.c [new file with mode: 0644]
chanserv/authtracker/authtracker.c
chanserv/authtracker/authtracker.h
chanserv/authtracker/authtracker_query.c
chanserv/chancmds/Makefile
chanserv/chancmds/chanlevhistory.c
chanserv/chancmds/commandlist.c
chanserv/chancmds/init.c [new file with mode: 0644]
chanserv/chancmds/rollbackchan.c
chanserv/chanserv.c
chanserv/chanserv.h
chanserv/chanservstdcmds.c
chanserv/mkcommandlist.pl
chanserv/usercmds/Makefile
chanserv/usercmds/accounthistory.c
chanserv/usercmds/commandlist.c
chanserv/usercmds/init.c [new file with mode: 0644]
chanserv/usercmds/rollbackaccount.c

index acedb2ad54d7325eec6f95aec6d40ba606cca041..ea4863a83a2d443d8b1146c75dd5c30c884bc38f 100644 (file)
@@ -6,5 +6,5 @@ all: Makefile chanserv_authcmds.so
 Makefile:
        ../mkcommandlist.pl chanserv_authcmds.so
 
-chanserv_authcmds.so: auth.o authhistory.o challenge.o challengeauth.o checkhashpass.o email.o getpassword.o hello.o login.o newpass.o requestpassword.o reset.o sendpassword.o setemail.o setpassword.o commandlist.o 
+chanserv_authcmds.so: auth.o authhistory.o challenge.o challengeauth.o checkhashpass.o email.o getpassword.o hello.o login.o newpass.o requestpassword.o reset.o sendpassword.o setemail.o setpassword.o commandlist.o init.o 
         ld -shared -Bdynamic -o $@ $^ 
index e8c09d5e5f0c4bc73d4a24fa9cc79f3b9d3ce5fa..13e149839d9b2d185c45af2e02d32c2e9a34a206 100644 (file)
@@ -37,6 +37,11 @@ void csdb_doauthhistory_real(PGconn *dbconn, void *arg) {
   struct tm *tmp;
   char tbuf1[15], tbuf2[15], uhbuf[51];
 
+  if(!dbconn) {
+    free(ahi);
+    return;
+  }
+
   pgres=PQgetResult(dbconn);
 
   if (PQresultStatus(pgres) != PGRES_TUPLES_OK) {
@@ -98,7 +103,7 @@ void csdb_retreiveauthhistory(nick *np, reguser *rup, int limit) {
   ahi=(struct authhistoryinfo *)malloc(sizeof(struct authhistoryinfo));
   ahi->numeric=np->numeric;
   ahi->userID=rup->ID;
-  pqasyncquery(csdb_doauthhistory_real, (void *)ahi,
+  q9a_asyncquery(csdb_doauthhistory_real, (void *)ahi,
     "SELECT userID, nick, username, host, authtime, disconnecttime, quitreason from authhistory where "
     "userID=%u order by authtime desc limit %d", rup->ID, limit);
 }
index 259c848b511ab4a5144099b58a8ac2cd0b77dfb7..6b105b08ee35bf9581155112bcc68c5398c9da21 100644 (file)
@@ -18,8 +18,12 @@ int csa_doreset(void *source, int cargc, char **cargv);
 int csa_dosendpw(void *source, int cargc, char **cargv);
 int csa_dosetmail(void *source, int cargc, char **cargv);
 int csa_dosetpw(void *source, int cargc, char **cargv);
+void authcmds_init(void);
+void authcmds_fini(void);
+
 
 void _init() {
+  authcmds_init();
   chanservaddcommand("auth", QCMD_SECURE | QCMD_NOTAUTHED, 2, csa_doauth, "Authenticates you on the bot.", "Usage: AUTH <username> <password>\nAuthenticates you on the bot, where:\nusername - your username\npassword - your password\nIf you do not have a username and password, see HELLO.\nNote: due to the sensitive nature of this command, you must send the message\nto Q@CServe.quakenet.org when using it.\nNote: the preferred way to authenticate is to use the /AUTH command.\n");
   chanservaddcommand("authhistory", QCMD_AUTHED, 1, csa_doauthhistory, "View auth history for an account.", "Usage: AUTHHISTORY\nDisplays details of the last 10 logins with your account.  Details include\nhostmask, login time, disconnect time and reason.\n");
   chanservaddcommand("challenge", QCMD_SECURE | QCMD_NOTAUTHED, 0, csa_dochallenge, "Returns a challenge for use in challengeauth.", "Usage: challenge\nSupplies you with a challenge and a list of algorithms accepted\nfor challenge response authentication, see CHALLENGEAUTH help\nfor more details.\n");
@@ -38,6 +42,7 @@ void _init() {
 }
 
 void _fini() {
+  authcmds_fini();
   chanservremovecommand("auth", csa_doauth);
   chanservremovecommand("authhistory", csa_doauthhistory);
   chanservremovecommand("challenge", csa_dochallenge);
diff --git a/chanserv/authcmds/init.c b/chanserv/authcmds/init.c
new file mode 100644 (file)
index 0000000..a98de09
--- /dev/null
@@ -0,0 +1,11 @@
+#include "../../pqsql/pqsql.h"
+
+PQModuleIdentifier q9apqid;
+
+void authcmds_init(void) {
+  q9apqid = pqgetid();
+}
+
+void authcmds_fini(void) {
+  pqfreeid(q9apqid);
+}
index 574e7c8f8a2194e807217b9c6d79b497616d745e..a8d1f378285f911136907eed6ac3d203f122272d 100644 (file)
@@ -6,14 +6,19 @@
 #include "../../core/error.h"
 
 void at_newnick(int, void *);
+PQModuleIdentifier authtrackerpq;
 
 void _init() {
+  authtrackerpq = pqgetid();
+
   at_finddanglingsessions();
 }
 
 void _fini() {
   at_hookfini();
   nsfreeall(POOL_AUTHTRACKER);
+
+  pqfreeid(authtrackerpq);
 }
 
 void at_dbloaded(int hooknum, void *arg) {
index 2d4665959cc4cd0eb8e822b84bb8fe5f083ec948..9f2b2c1f9a1b435fc71254210703a447696b2f10 100644 (file)
@@ -2,9 +2,12 @@
 #define AUTHTRACKER_H
 
 #include "../../nick/nick.h"
+#include "../../pqsql/pqsql.h"
 
 #include <time.h>
 
+extern PQModuleIdentifier authtrackerpq;
+
 #define AT_NETSPLIT    0       /* User lost in netsplit */
 #define AT_RESTART     1       /* Dangling session found at restart */
 
index e42344177ac7040d702bd2ffcc28d0f2812fb8bb..cc492cd457e4498a593a9c09870b20ff88cdcb94 100644 (file)
@@ -39,7 +39,10 @@ void at_lognewsession(unsigned int userid, nick *np) {
 static void real_at_finddanglingsessions(PGconn *dbconn, void *arg) {
   PGresult *pgres;
   unsigned int i,num;
-  
+
+  if(!dbconn)
+    return;
+
   pgres=PQgetResult(dbconn);
 
   if (PQresultStatus(pgres) != PGRES_TUPLES_OK) {
@@ -49,6 +52,7 @@ static void real_at_finddanglingsessions(PGconn *dbconn, void *arg) {
 
   if (PQnfields(pgres)!=3) {
     Error("authtracker",ERR_ERROR,"Dangling sessions format error");
+    PQclear(pgres);
     return;
   }
   
@@ -70,7 +74,7 @@ static void real_at_finddanglingsessions(PGconn *dbconn, void *arg) {
 }
 
 void at_finddanglingsessions() {
-  pqasyncquery(real_at_finddanglingsessions, NULL, 
+  pqasyncqueryi(authtrackerpq, real_at_finddanglingsessions, NULL, 
        "SELECT numeric,userID,authtime FROM authhistory WHERE disconnecttime=0");
 
 }
index 868eec7d890325ebd6c81814d128fb33e04a586d..9fcfa60f83615ca0826690553234e05bb9181c4a 100644 (file)
@@ -6,5 +6,5 @@ all: Makefile chanserv_chancmds.so
 Makefile:
        ../mkcommandlist.pl chanserv_chancmds.so
 
-chanserv_chancmds.so: addchan.o adduser.o autolimit.o ban.o banclear.o bandel.o banlist.o bantimer.o chanflags.o chanlev.o chanlevhistory.o chanmode.o channelcomment.o chanophistory.o chanstat.o chantype.o clearchan.o delchan.o deopall.o devoiceall.o giveowner.o invite.o op.o permban.o recover.o rejoin.o removeuser.o renchan.o requestowner.o rollbackchan.o settopic.o suspendchan.o suspendchanlist.o tempban.o unban.o unbanall.o unbanmask.o unbanme.o unsuspendchan.o voice.o welcome.o commandlist.o 
+chanserv_chancmds.so: addchan.o adduser.o autolimit.o ban.o banclear.o bandel.o banlist.o bantimer.o chanflags.o chanlev.o chanlevhistory.o chanmode.o channelcomment.o chanophistory.o chanstat.o chantype.o clearchan.o delchan.o deopall.o devoiceall.o giveowner.o invite.o op.o permban.o recover.o rejoin.o removeuser.o renchan.o requestowner.o rollbackchan.o settopic.o suspendchan.o suspendchanlist.o tempban.o unban.o unbanall.o unbanmask.o unbanme.o unsuspendchan.o voice.o welcome.o commandlist.o init.o 
         ld -shared -Bdynamic -o $@ $^ 
index 1f28ab3d7e6da9ed138a30548760a7aff93941ea..0694c41d1166dfaa58d544112521de6fc974229d 100644 (file)
@@ -34,6 +34,11 @@ void csdb_dochanlevhistory_real(PGconn *dbconn, void *arg) {
   struct tm *tmp;
   char tbuf[15], fbuf[18];
 
+  if(!dbconn) {
+    PQclear(pgres);
+    return;
+  }
+
   pgres=PQgetResult(dbconn);
 
   if (PQresultStatus(pgres) != PGRES_TUPLES_OK) {
@@ -81,7 +86,7 @@ void csdb_dochanlevhistory_real(PGconn *dbconn, void *arg) {
 }
 
 void csdb_retreivechanlevhistory(nick *np, regchan *rcp, time_t starttime) {
-  pqasyncquery(csdb_dochanlevhistory_real, (void *)np->numeric,
+  q9c_asyncquery(csdb_dochanlevhistory_real, (void *)np->numeric,
     "SELECT userID, channelID, targetID, changetime, authtime, oldflags, newflags from chanlevhistory where "
     "channelID=%u and changetime>%lu order by changetime desc limit 1000", rcp->ID, starttime);
 }
index 1db43b55262912e115f1737b7b2042a0469ed86f..6329e6419ba722da6cd0b203ac75c37f84f737da 100644 (file)
@@ -44,8 +44,12 @@ int csc_dounbanme(void *source, int cargc, char **cargv);
 int csc_dounsuspendchan(void *source, int cargc, char **cargv);
 int csc_dovoice(void *source, int cargc, char **cargv);
 int csc_dowelcome(void *source, int cargc, char **cargv);
+void chancmds_init(void);
+void chancmds_fini(void);
+
 
 void _init() {
+  chancmds_init();
   chanservaddcommand("addchan", QCMD_OPER, 4, csc_doaddchan, "Adds a new channel to the bot.", "Usage: addchan <channel> [<owner> [<flags> [<type>]]]\nAdds the given channel to the bot, where:\nowner - can be either nickname on the network or #authname.  If not supplied,\n        the channel will belong to the user issuing the ADDCHAN command.\nflags - can be any valid chanflags (see CHANFLAGS).  If not specified this \n        defaults to +j.\ntype  - is a channel type as per old Q and is now obsolete.\n");
   chanservaddcommand("adduser", QCMD_AUTHED, 20, csc_doadduser, "Adds one or more users to a channel as +aot.", "Usage: ADDUSER <channel> [<flags>] <user1> [<user2> [<user3> [...]]]\nAdds the named user(s) to the channel, where:\nchannel - the channel to use\nflags   - the list of flags to add for each user, introduced by + (for example\n          +gv).  See CHANLEV for valid flags.  If no flags are specified, \n          +aot is used.  This command cannot be used to add masters (+m) or\n          owners (+n).\nuser<n> - either a user's current nickname on the network or #accountname. Up to\n          18 users can be specified.\nADDUSER requires master (+m) access on the named channel.\n");
   chanservaddcommand("autolimit", QCMD_AUTHED, 2, csc_doautolimit, "Shows or changes the autolimit threshold on a channel.", "Usage: AUTOLIMIT <channel> [<threshold>]\nThe autolimit feature maintains a user limit (+l) on the channel which is\nregularly updated to keep a fixed number of spaces free on the channel for\npeople to join.  This is useful since it prevents a large number of \"clones\"\njoining at the same time.  However, if the number of free spaces is too small\nit's possible that legitimate users won't be able to join.  This command allows\nyou to adjust the number of free spaces to maintain when autolimit is enabled.  \nTo actually turn the autolimit feature on or off, see CHANFLAGS.  Where:\nchannel   - the channel to use.\nthreshold - specifies the new threshold.  If not specified, the current threshold \n            is displayed.\nViewing the current threshold requires operator (+o) access on the named channel.\nUpdating the threshold requires master (+m) access on the named channel.\n");
@@ -90,6 +94,7 @@ void _init() {
 }
 
 void _fini() {
+  chancmds_fini();
   chanservremovecommand("addchan", csc_doaddchan);
   chanservremovecommand("adduser", csc_doadduser);
   chanservremovecommand("autolimit", csc_doautolimit);
diff --git a/chanserv/chancmds/init.c b/chanserv/chancmds/init.c
new file mode 100644 (file)
index 0000000..c5d4d56
--- /dev/null
@@ -0,0 +1,12 @@
+#include "../../pqsql/pqsql.h"
+
+PQModuleIdentifier q9cpqid;
+
+void chancmds_init(void) {
+  q9cpqid = pqgetid();
+}
+
+void chancmds_fini(void) {
+  pqfreeid(q9cpqid);
+}
+
index 3452cbd7e4783377f83873f061cf9a51a22232d6..214289945ee8fb10d6d94f5949dcdb6059e24d5c 100644 (file)
@@ -36,6 +36,9 @@ void csc_dorollbackchan_real(PGconn *dbconn, void *arg) {
   int i, j, num, newuser;
   char fbuf[18];
 
+  if(!dbconn)
+    return;
+
   pgres=PQgetResult(dbconn);
 
   if (PQresultStatus(pgres) != PGRES_TUPLES_OK) {
@@ -155,11 +158,11 @@ void csc_dorollbackchan_real(PGconn *dbconn, void *arg) {
 
 void csdb_rollbackchanlevhistory(nick *np, regchan *rcp, reguser* rup, time_t starttime) {
   if (rup)
-    pqasyncquery(csc_dorollbackchan_real, (void *)np->numeric,
+    q9c_asyncquery(csc_dorollbackchan_real, (void *)np->numeric,
       "SELECT userID, channelID, targetID, changetime, authtime, oldflags, newflags from chanlevhistory where "
       "userID=%u and channelID=%u and changetime>%lu order by changetime desc limit 1000", rup->ID, rcp->ID, starttime);
   else
-    pqasyncquery(csc_dorollbackchan_real, (void *)np->numeric,
+    q9c_asyncquery(csc_dorollbackchan_real, (void *)np->numeric,
       "SELECT userID, channelID, targetID, changetime, authtime, oldflags, newflags from chanlevhistory where "
       "channelID=%u and changetime>%lu order by changetime desc limit 1000", rcp->ID, starttime);
 }
index 1a56dbdf68e6a8e7f283c509f2a7cfa97556ea90..4d8b0971385b874ff1df5f57d52f1b17dbafe97c 100644 (file)
@@ -78,6 +78,8 @@ const flag mdflags[] = {
 void chanservfreestuff();
 void chanservfinishinit(int hooknum, void *arg);
 
+PQModuleIdentifier q9pqid;
+
 void chanservdumpstuff(void *arg) {
   dumplastjoindata("lastjoin.dump");
 }
@@ -89,6 +91,8 @@ void _init() {
   chanservcryptoinit();
   csa_initregex();
 
+  q9pqid = pqgetid();
+
   if (chanservext!=-1 && chanservnext!=-1 && chanservaext!=-1) {
     /* Set up the chantypes */
     chantypes=(sstring **)malloc(CHANTYPES*sizeof(sstring *));
@@ -171,6 +175,8 @@ void chanserv_finalinit() {
 }
 
 void _fini() {
+  pqfreeid(q9pqid);
+
   deleteallschedules(cs_timerfunc);
   deleteallschedules(chanservreguser);
   deleteallschedules(chanservdumpstuff);
index 388143dccdf85f667f90248580764283338abfc5..936a3766690eaf970b2c694d06004ae9a86736f3 100644 (file)
@@ -17,6 +17,7 @@
 #include "../channel/channel.h"
 #include "../parser/parser.h"
 #include "../localuser/localuserchannel.h"
+#include "../pqsql/pqsql.h"
 
 #define CS_PARANOID
 
@@ -808,6 +809,7 @@ extern unsigned int lastmaillockID;
 
 extern int chanserv_init_status;
 extern int chanservdb_ready;
+extern PQModuleIdentifier q9pqid, q9apqid, q9cpqid, q9upqid;
 
 extern maildomain *maildomainnametable[MAILDOMAINHASHSIZE];
 extern maildomain *maildomainIDtable[MAILDOMAINHASHSIZE];
@@ -911,6 +913,11 @@ char *csdb_gethelpstr(char *command, int language);
 void csdb_createmail(reguser *rup, int type);
 void csdb_dohelp(nick *np, Command *cmd);
 
+#define q9asyncquery(handler, tag, format, ...) pqasyncqueryi(q9pqid, handler, tag, format , ##__VA_ARGS__)
+#define q9a_asyncquery(handler, tag, format, ...) pqasyncqueryi(q9apqid, handler, tag, format , ##__VA_ARGS__)
+#define q9u_asyncquery(handler, tag, format, ...) pqasyncqueryi(q9upqid, handler, tag, format , ##__VA_ARGS__)
+#define q9c_asyncquery(handler, tag, format, ...) pqasyncqueryi(q9cpqid, handler, tag, format , ##__VA_ARGS__)
+
 /* chanservcrypto.c */
 typedef int (*CRAlgorithm)(char *, const char *, const char *, const char *);
 void chanservcryptoinit(void);
index b09f302cb684df23760a28405a4994ccf18c99e0..58fdcd99fec2c64fdd274c8a261a3b4546b9b0c3 100644 (file)
@@ -227,7 +227,7 @@ void csdb_dohelp(nick *np, Command *cmd) {
   hip->commandname=getsstring(cmd->command->content, cmd->command->length);
   hip->cmd=cmd;
 
-  pqasyncquery(csdb_dohelp_real, (void *)hip, 
+  q9asyncquery(csdb_dohelp_real, (void *)hip, 
                  "SELECT languageID, fullinfo from help where lower(command)=lower('%s')",cmd->command->content);
 }
 
@@ -239,6 +239,12 @@ void csdb_dohelp_real(PGconn *dbconn, void *arg) {
   PGresult *pgres;
   int i,j,num,lang=0;
   
+  if(!dbconn) {
+    freesstring(hip->commandname);
+    free(hip);
+    return; 
+  }
+
   pgres=PQgetResult(dbconn);
 
   if (PQresultStatus(pgres) != PGRES_TUPLES_OK) {
index 224ded30c4224bfad0d52f985f718be7c48f3023..c57d19e8929540985d289086b6b1012bc0304973 100755 (executable)
@@ -22,8 +22,14 @@ unless (@ARGV) {
   $modname=$ARGV[0];
 }
 
+my $smallname;
+$smallname=$modname;
+$smallname=~s/^chanserv_//;
+$smallname=~s/\.so$//;
+
 for (@filelist) {
   next if (/commandlist.c/);
+  next if (/init.c/);
   
   my $fname = $_;
   my ($cn, $cl, $ca, $cd, $cf, $cp, $ch);
@@ -99,7 +105,11 @@ foreach (@protos) {
 my @names2 = @cmdnames;
 my @func2 = @cmdfunc;
 
+print CL "void ".$smallname."_init(void);\n";
+print CL "void ".$smallname."_fini(void);\n\n";
+
 print CL "\nvoid _init() {\n";
+print CL "  ".$smallname."_init();\n";
 
 while (my $cn = shift @cmdnames) {
   print CL "  chanservaddcommand(\"".$cn."\", ".(shift @cmdlevels).", ".(shift @cmdargs).", ";
@@ -107,6 +117,7 @@ while (my $cn = shift @cmdnames) {
 }
 
 print CL "}\n\nvoid _fini() {\n";
+print CL "  ".$smallname."_fini();\n";
 
 while (my $cn = shift @names2) {
   print CL "  chanservremovecommand(\"".$cn."\", ".(shift @func2).");\n";
@@ -130,6 +141,7 @@ print MF "\t../mkcommandlist.pl $modname\n";
 print MF "\n$modname: ";
 
 push @files,"commandlist.c";
+push @files,"init.c";
 
 foreach (@files) {
   s/.c$/.o/;
index c524172dd723457f26a7ec4cff144d070dc98664..26d8ab38977bae0f1e9e9bfa595edc2cbcc51fd4 100644 (file)
@@ -6,5 +6,5 @@ all: Makefile chanserv_usercmds.so
 Makefile:
        ../mkcommandlist.pl chanserv_usercmds.so
 
-chanserv_usercmds.so: accounthistory.o cleanupdb.o deluser.o domainmode.o info.o language.o listflags.o maillock.o rollbackaccount.o spewdb.o spewdomain.o spewemail.o spewpass.o suspenduser.o suspenduserlist.o unsuspenduser.o usercomment.o userflags.o whoami.o whois.o commandlist.o 
+chanserv_usercmds.so: accounthistory.o cleanupdb.o deluser.o domainmode.o info.o language.o listflags.o maillock.o rollbackaccount.o spewdb.o spewdomain.o spewemail.o spewpass.o suspenduser.o suspenduserlist.o unsuspenduser.o usercomment.o userflags.o whoami.o whois.o commandlist.o init.o 
         ld -shared -Bdynamic -o $@ $^ 
index e20ee8ca5504d0a1b41ce7bc9af2a841f20c039e..7ad5418101659d182eb243d65946f63ba8578aa1 100644 (file)
@@ -30,6 +30,9 @@ void csdb_doaccounthistory_real(PGconn *dbconn, void *arg) {
   struct tm *tmp;
   char tbuf[15];
 
+  if(!dbconn)
+    return;
+
   pgres=PQgetResult(dbconn);
 
   if (PQresultStatus(pgres) != PGRES_TUPLES_OK) {
@@ -75,7 +78,7 @@ void csdb_doaccounthistory_real(PGconn *dbconn, void *arg) {
 }
 
 void csdb_retreiveaccounthistory(nick *np, reguser *rup, int limit) {
-  pqasyncquery(csdb_doaccounthistory_real, (void *)np->numeric,
+  q9u_asyncquery(csdb_doaccounthistory_real, (void *)np->numeric,
     "SELECT userID, changetime, authtime, oldpassword, newpassword, oldemail, newemail from accounthistory where "
     "userID=%u order by changetime desc limit %d", rup->ID, limit);
 }
index 0bd1147c97a94a2399f20ab92d8ee7cb1bde874a..b1fc1f497b2ae5a043dfcc08a74cc7856112c625 100644 (file)
@@ -23,8 +23,12 @@ int csu_dousercomment(void *source, int cargc, char **cargv);
 int csu_douserflags(void *source, int cargc, char **cargv);
 int csu_dowhoami(void *source, int cargc, char **cargv);
 int csu_dowhois(void *source, int cargc, char **cargv);
+void usercmds_init(void);
+void usercmds_fini(void);
+
 
 void _init() {
+  usercmds_init();
   chanservaddcommand("accounthistory", QCMD_OPER, 1, csa_doaccounthistory, "View password/email history for an account.", "Usage: accounthistory <account>\nShows password/email history for the specified account.\n");
   chanservaddcommand("cleanupdb", QCMD_DEV, 0, csu_docleanupdb, "Clean up database.", "Usage: cleanupdb\nRemoves unused and never used accounts that exceed the idleness\nthresholds.\n");
   chanservaddcommand("deluser", QCMD_OPER, 2, csu_dodeluser, "Removes a user from the bot.", "Usage: deluser <username>\nRemoves the specified username from the bot.\n");
@@ -48,6 +52,7 @@ void _init() {
 }
 
 void _fini() {
+  usercmds_fini();
   chanservremovecommand("accounthistory", csa_doaccounthistory);
   chanservremovecommand("cleanupdb", csu_docleanupdb);
   chanservremovecommand("deluser", csu_dodeluser);
diff --git a/chanserv/usercmds/init.c b/chanserv/usercmds/init.c
new file mode 100644 (file)
index 0000000..f53c9fd
--- /dev/null
@@ -0,0 +1,12 @@
+#include "../../pqsql/pqsql.h"
+
+PQModuleIdentifier q9upqid;
+
+void usercmds_init(void) {
+  q9upqid = pqgetid();
+}
+
+void usercmds_fini(void) {
+  pqfreeid(q9upqid);
+}
+
index 3cf44c23839de69b656346d98954c905854735d9..b903f9da01356f9d638fec3261707fd8e29920d2 100644 (file)
@@ -26,6 +26,9 @@ void csdb_dorollbackaccount_real(PGconn *dbconn, void *arg) {
   PGresult *pgres;
   int i, num;
 
+  if(!dbconn)
+    return;
+
   pgres=PQgetResult(dbconn);
 
   if (PQresultStatus(pgres) != PGRES_TUPLES_OK) {
@@ -80,7 +83,7 @@ void csdb_dorollbackaccount_real(PGconn *dbconn, void *arg) {
 }
 
 void csdb_rollbackaccounthistory(nick *np, reguser* rup, time_t starttime) {
-  pqasyncquery(csdb_dorollbackaccount_real, (void *)np->numeric,
+  q9u_asyncquery(csdb_dorollbackaccount_real, (void *)np->numeric,
     "SELECT userID, changetime, authtime, oldpassword, newpassword, oldemail, newemail from accounthistory where "
     "userID=%u and changetime>%lu order by changetime desc limit 10", rup->ID, starttime);
 }