fix a c99 compile bug
[citadel.git] / citadel / modules / listdeliver / serv_listdeliver.c
index 4ceb75a657d8824be0e2ff83de526471d4c4ec7a..265acee3a77ed89c7e46401945dccbacf4ec935e 100644 (file)
@@ -57,6 +57,7 @@ void listdeliver_do_msg(long msgnum, void *userdata) {
        char buf[SIZ];
        char *ch;
        char bounce_to[256];
+       int i = 0;
 
        ld->msgnum = msgnum;
        if (msgnum <= 0) return;
@@ -83,7 +84,7 @@ void listdeliver_do_msg(long msgnum, void *userdata) {
                recipients[0] = 0;
 
                int config_lines = num_tokens(ld->netconf, '\n');
-               for (int i=0; i<config_lines; ++i) {
+               for (i=0; i<config_lines; ++i) {
                        extract_token(buf, ld->netconf, i, '\n', sizeof buf);
                        if (!strncasecmp(buf, "listrecp|", 9)) {
                                if (recipients[0] != 0) {
@@ -161,6 +162,7 @@ void listdeliver_sweep_room(char *roomname) {
                        syslog(LOG_DEBUG, "listdeliver: new lastsent is %ld", ld.msgnum);
 
                        // Update this room's netconfig with the updated lastsent
+                       begin_critical_section(S_NETCONFIGS);
                        netconfig = LoadRoomNetConfigFile(CC->room.QRnumber);
                        if (!netconfig) {
                                netconfig = strdup("");
@@ -181,6 +183,7 @@ void listdeliver_sweep_room(char *roomname) {
 
                        // Write the new netconfig back to disk
                        SaveRoomNetConfigFile(CC->room.QRnumber, newnetconfig);
+                       end_critical_section(S_NETCONFIGS);
                        free(newnetconfig);     // this was the new netconfig, free it because we're done with it
                }
        }