Fix locking of netcnofigs
[citadel.git] / citadel / modules / network / serv_netspool.c
index 3dfec6375a9c379d4accf83812f327ae54ac2a0a..714bb0471918db577cc597c25e9b5d7e05313f45 100644 (file)
@@ -168,7 +168,7 @@ void Netmap_AddMe(struct CtdlMessage *msg, const char *defl, long defllen)
        if (CM_IsEmpty(msg, eMessagePath)) {
                CM_SetField(msg, eMessagePath, defl, defllen);
        }
-       node_len = strlen(config.c_nodename);
+       node_len = configlen.c_nodename;
        if (node_len >= SIZ) 
                node_len = SIZ - 1;
        memcpy(buf, config.c_nodename, node_len);
@@ -209,11 +209,13 @@ void InspectQueuedRoom(SpoolControl **pSC,
                return;
        }
 
+       begin_critical_section(S_NETCONFIGS);
        if (sc->RNCfg == NULL)
                sc->RNCfg = CtdlGetNetCfgForRoom(sc->room.QRnumber);
 
        if (!HaveSpoolConfig(sc->RNCfg))
        {
+               end_critical_section(S_NETCONFIGS);
                free(sc);
                /* nothing to do for this room... */
                return;
@@ -231,6 +233,7 @@ void InspectQueuedRoom(SpoolControl **pSC,
        
        if (StrLength(sc->RNCfg->Sender) > 0)
                sc->Users[roommailalias] = NewStrBufDup(sc->RNCfg->Sender);
+       end_critical_section(S_NETCONFIGS);
 
        sc->next = *pSC;
        *pSC = sc;
@@ -400,12 +403,13 @@ void network_spoolout_room(SpoolControl *sc)
        /* Now rewrite the config file */
        if (sc->lastsent != lastsent)
        {
+               begin_critical_section(S_NETCONFIGS);
                sc->RNCfg = CtdlGetNetCfgForRoom(sc->room.QRnumber);
 
                sc->RNCfg->lastsent = sc->lastsent;
                sc->RNCfg->changed = 1;
+               end_critical_section(S_NETCONFIGS);
        }
-       end_critical_section(S_NETCONFIGS);
 }
 
 /*
@@ -720,7 +724,7 @@ void network_do_spoolin(HashList *working_ignetcfg, HashList *the_netmap, int *n
               (filedir_entry != NULL))
        {
 #ifdef _DIRENT_HAVE_D_NAMLEN
-               d_namelen = filedir_entry->d_namelen;
+               d_namelen = filedir_entry->d_namlen;
 
 #else
                d_namelen = strlen(filedir_entry->d_name);
@@ -824,7 +828,7 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm
               (filedir_entry != NULL))
        {
 #ifdef _DIRENT_HAVE_D_NAMLEN
-               d_namelen = filedir_entry->d_namelen;
+               d_namelen = filedir_entry->d_namlen;
 
 #else
                d_namelen = strlen(filedir_entry->d_name);
@@ -978,7 +982,7 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm
               (filedir_entry != NULL))
        {
 #ifdef _DIRENT_HAVE_D_NAMLEN
-               d_namelen = filedir_entry->d_namelen;
+               d_namelen = filedir_entry->d_namlen;
 
 #else
                d_namelen = strlen(filedir_entry->d_name);