More work on replace deprecated readdir_r()
[citadel.git] / citadel / modules / network / serv_netspool.c
index 5c20e0a923d8da22e23f4a476e547b7caf2f25a3..a792601b34f29a8539554d5d664902d771f78150 100644 (file)
@@ -293,7 +293,7 @@ void InspectQueuedRoom(SpoolControl **pSC,
        if ( (!HaveSpoolConfig(sc->RNCfg)) || (sc->room.QRhighest <= sc->RNCfg->lastsent) ) 
        {
                // There is nothing to send from this room.
-               MARK_syslog(LOG_DEBUG, "netspool: nothing to do for <%s>", room_to_spool->name);
+               syslog(LOG_DEBUG, "netspool: nothing to do for <%s>", room_to_spool->name);
                FreeRoomNetworkStruct(&sc->RNCfg);
                sc->RNCfg = NULL;
                free(sc);
@@ -808,11 +808,11 @@ void network_do_spoolin(HashList *working_ignetcfg, HashList *the_netmap, int *n
         */
        if (stat(ctdl_netin_dir, &statbuf)) return;
        if (statbuf.st_mtime == last_spoolin_mtime) {
-               MARKM_syslog(LOG_DEBUG, "netspool: nothing in inbound queue");
+               syslog(LOG_DEBUG, "netspool: nothing in inbound queue");
                return;
        }
        last_spoolin_mtime = statbuf.st_mtime;
-       MARKM_syslog(LOG_DEBUG, "netspool: processing inbound queue");
+       syslog(LOG_DEBUG, "netspool: processing inbound queue");
 
        /*
         * Ok, there's something interesting in there, so scan it.
@@ -826,8 +826,7 @@ void network_do_spoolin(HashList *working_ignetcfg, HashList *the_netmap, int *n
                return;
        }
 
-       while ((readdir_r(dp, d, &filedir_entry) == 0) &&
-              (filedir_entry != NULL))
+       while ( (filedir_entry = readdir(dp)) , (filedir_entry != NULL))
        {
 #ifdef _DIRENT_HAVE_D_NAMLEN
                d_namelen = filedir_entry->d_namlen;
@@ -901,7 +900,6 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm
        FDIOBuffer FDIO;
         int d_namelen;
        DIR *dp;
-       struct dirent *d;
        struct dirent *filedir_entry;
        const char *pch;
        char spooloutfilename[PATH_MAX];
@@ -913,14 +911,10 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm
        int nFailed = 0;
        int d_type = 0;
 
-
        /* Step 1: consolidate files in the outbound queue into one file per neighbor node */
-       d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
-       if (d == NULL)  return;
 
        dp = opendir(ctdl_netout_dir);
        if (dp == NULL) {
-               free(d);
                return;
        }
 
@@ -929,8 +923,7 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm
        memset(&FDIO, 0, sizeof(FDIOBuffer));
        FDIO.IOB = &IOB;
 
-       while ((readdir_r(dp, d, &filedir_entry) == 0) &&
-              (filedir_entry != NULL))
+       while ( (filedir_entry = readdir(dp)) , (filedir_entry != NULL))
        {
 #ifdef _DIRENT_HAVE_D_NAMLEN
                d_namelen = filedir_entry->d_namlen;
@@ -982,7 +975,7 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm
                syslog(LOG_DEBUG, "netspool: consolidate %s to %s", filename, ChrPtr(NextHop));
                if (CtdlNetworkTalkingTo(SKEY(NextHop), NTT_CHECK)) {
                        nFailed++;
-                       syslog(LOG_DEBUG, "netspool: urrently online with %s - skipping for now", ChrPtr(NextHop));
+                       syslog(LOG_DEBUG, "netspool: currently online with %s - skipping for now", ChrPtr(NextHop));
                }
                else {
                        size_t dsize;
@@ -1049,7 +1042,6 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm
        if (nFailed > 0) {
                FreeStrBuf(&NextHop);
                syslog(LOG_INFO, "netspool: skipping Spoolcleanup because of %d files unprocessed.", nFailed);
-
                return;
        }
 
@@ -1057,12 +1049,10 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm
        dp = opendir(ctdl_netout_dir);
        if (dp == NULL) {
                FreeStrBuf(&NextHop);
-               free(d);
                return;
        }
 
-       while ((readdir_r(dp, d, &filedir_entry) == 0) &&
-              (filedir_entry != NULL))
+       while ( (filedir_entry = readdir(dp)) , (filedir_entry != NULL))
        {
 #ifdef _DIRENT_HAVE_D_NAMLEN
                d_namelen = filedir_entry->d_namlen;
@@ -1114,7 +1104,6 @@ void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netm
                }
        }
        FreeStrBuf(&NextHop);
-       free(d);
        closedir(dp);
 }
 
@@ -1135,7 +1124,6 @@ void free_spoolcontrol_struct_members(SpoolControl *sc)
 }
 
 
-
 /*
  * It's ok if these directories already exist.  Just fail silently.
  */