#include <stdio.h>
#include <sys/poll.h>
#include <stdarg.h>
+#include <assert.h>
void csdb_updateauthinfo(reguser *rup) {
char eschost[2*HOSTLEN+1];
escwelcome,esctopic,esckey,escreason,esccomment,(intmax_t)rcp->ltimestamp,rcp->ID);
}
+#define CHANNELCOUNTER_BUFSIZE 512
+#define CHANNELCOUNTER_MAX 512
+
+static int channelcounter_count = 0;
+static char channelcounter_bufs[CHANNELCOUNTER_MAX][CHANNELCOUNTER_BUFSIZE];
+
+void csdb_flushchannelcounters(void *arg) {
+ int i;
+
+ if(!channelcounter_count)
+ return;
+
+ dbquery("BEGIN TRANSACTION;");
+
+ for(i=0;i<channelcounter_count;i++)
+ dbquery("%s", channelcounter_bufs[i]);
+
+ dbquery("COMMIT;");
+
+ channelcounter_count = 0;
+}
+
void csdb_updatechannelcounters(regchan *rcp) {
- dbquery("UPDATE chanserv.channels SET "
+ if(channelcounter_count == CHANNELCOUNTER_MAX)
+ csdb_flushchannelcounters(NULL);
+
+ snprintf(channelcounter_bufs[channelcounter_count], CHANNELCOUNTER_BUFSIZE - 1, "UPDATE chanserv.channels SET "
"lastactive=%lu, totaljoins=%u,"
"tripjoins=%u, maxusers=%u, tripusers=%u "
"WHERE ID=%u",
rcp->totaljoins,rcp->tripjoins,
rcp->maxusers,rcp->tripusers,
rcp->ID);
+
+ channelcounter_count++;
}
void csdb_updatechanneltimestamp(regchan *rcp) {
void csdb_chanlevhistory_insert(regchan *rcp, nick *np, reguser *trup, flag_t oldflags, flag_t newflags) {
reguser *rup=getreguserfromnick(np);
+ assert(rup != NULL);
dbquery("INSERT INTO chanserv.chanlevhistory (userID, channelID, targetID, changetime, authtime, "
"oldflags, newflags) VALUES (%u, %u, %u, %lu, %lu, %u, %u)", rup->ID, rcp->ID, trup->ID, getnettime(), np->accountts,