rework the networking locking facility using the hashlist.
[citadel.git] / citadel / modules / network / serv_netspool.c
index c014026458964f927ea1b0c82f25626dbcc3b629..5dd1eafb2be0350e47f81570fdf7832c74ec85b7 100644 (file)
@@ -380,7 +380,10 @@ int is_recipient(SpoolControl *sc, const char *Name)
 /*
  * Batch up and send all outbound traffic from the current room
  */
-void network_spoolout_room(char *room_to_spool) {
+void network_spoolout_room(char *room_to_spool,                       
+                          char *working_ignetcfg,
+                          NetMap *the_netmap)
+{
        char buf[SIZ];
        char filename[PATH_MAX];
        SpoolControl *sc;
@@ -407,6 +410,9 @@ void network_spoolout_room(char *room_to_spool) {
        }
        syslog(LOG_INFO, "Networking started for <%s>\n", CC->room.QRname);
 
+       sc->working_ignetcfg = working_ignetcfg;
+       sc->the_netmap = the_netmap;
+
        /* If there are digest recipients, we have to build a digest */
        if (sc->digestrecps != NULL) {
                sc->digestfp = tmpfile();
@@ -772,6 +778,7 @@ void network_consolidate_spoolout(char *working_ignetcfg, NetMap *the_netmap)
        char filename[PATH_MAX];
        char cmd[PATH_MAX];
        char nexthop[256];
+       long nexthoplen;
        int i;
        char *ptr;
 
@@ -784,9 +791,12 @@ void network_consolidate_spoolout(char *working_ignetcfg, NetMap *the_netmap)
                        && (strcmp(d->d_name, ".."))
                        && (strchr(d->d_name, '@') != NULL)
                ) {
-                       safestrncpy(nexthop, d->d_name, sizeof nexthop);
+                       nexthoplen = safestrncpy(nexthop, d->d_name, sizeof nexthop);
                        ptr = strchr(nexthop, '@');
-                       if (ptr) *ptr = 0;
+                       if (ptr) {
+                               *ptr = 0;
+                               nexthoplen = ptr - nexthop;
+                       }                               
        
                        snprintf(filename, 
                                sizeof filename,
@@ -796,21 +806,21 @@ void network_consolidate_spoolout(char *working_ignetcfg, NetMap *the_netmap)
                        );
        
                        syslog(LOG_DEBUG, "Consolidate %s to %s\n", filename, nexthop);
-                       if (network_talking_to(nexthop, NTT_CHECK)) {
+                       if (network_talking_to(nexthop, nexthoplen, NTT_CHECK)) {
                                syslog(LOG_DEBUG,
                                        "Currently online with %s - skipping for now\n",
                                        nexthop
                                );
                        }
                        else {
-                               network_talking_to(nexthop, NTT_ADD);
+                               network_talking_to(nexthop, nexthoplen, NTT_ADD);
                                snprintf(cmd, sizeof cmd, "/bin/cat %s >>%s/%s && /bin/rm -f %s",
                                        filename,
                                        ctdl_netout_dir, nexthop,
                                        filename
                                );
                                system(cmd);
-                               network_talking_to(nexthop, NTT_REMOVE);
+                               network_talking_to(nexthop, nexthoplen, NTT_REMOVE);
                        }
                }
        }