]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/networkclient/serv_networkclient.c
updated serv_networkclient.c to new logging standard
[citadel.git] / citadel / modules / networkclient / serv_networkclient.c
index 4c1afa883f6a56a3de089c4f2b2e079a4508b7dc..9daddd48694646f0a7d8ecdb1cf2899a1604cb1d 100644 (file)
@@ -2,15 +2,15 @@
  * This module handles shared rooms, inter-Citadel mail, and outbound
  * mailing list processing.
  *
- * Copyright (c) 2000-2012 by the citadel.org team
+ * Copyright (c) 2000-2017 by the citadel.org team
  *
- *  This program is open source software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License, version 3.
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 3.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
  * ** NOTE **   A word on the S_NETCONFIGS semaphore:
  * This is a fairly high-level type of critical section.  It ensures that no
@@ -66,7 +66,6 @@
 #include "msgbase.h"
 #include "internet_addressing.h"
 #include "clientsocket.h"
-#include "file_ops.h"
 #include "citadel_dirs.h"
 #include "threads.h"
 #include "context.h"
@@ -77,29 +76,6 @@ struct CitContext networker_client_CC;
 #define NODE ChrPtr(((AsyncNetworker*)IO->Data)->node)
 #define N ((AsyncNetworker*)IO->Data)->n
 
-int NetworkClientDebugEnabled = 0;
-
-#define NCDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (NetworkClientDebugEnabled != 0))
-
-#define EVN_syslog(LEVEL, FORMAT, ...)                                 \
-       NCDBGLOG(LEVEL) syslog(LEVEL,                                   \
-                              "IO[%ld]CC[%d]NW[%s][%ld]" FORMAT,       \
-                              IO->ID, CCID, NODE, N, __VA_ARGS__)
-
-#define EVNM_syslog(LEVEL, FORMAT)                                     \
-       NCDBGLOG(LEVEL) syslog(LEVEL,                                   \
-                              "IO[%ld]CC[%d]NW[%s][%ld]" FORMAT,       \
-                              IO->ID, CCID, NODE, N)
-
-#define EVNCS_syslog(LEVEL, FORMAT, ...) \
-       NCDBGLOG(LEVEL) syslog(LEVEL, "IO[%ld]NW[%s][%ld]" FORMAT,      \
-                              IO->ID, NODE, N, __VA_ARGS__)
-
-#define EVNCSM_syslog(LEVEL, FORMAT) \
-       NCDBGLOG(LEVEL) syslog(LEVEL, "IO[%ld]NW[%s][%ld]" FORMAT,      \
-                              IO->ID, NODE, N)
-
-
 typedef enum _eNWCState {
        eGreating,
        eAuth,
@@ -191,26 +167,13 @@ void DeleteNetworker(void *vptr)
        free(NW);
 }
 
-#define NWC_DBG_SEND() EVN_syslog(LOG_DEBUG, ": > %s", ChrPtr(NW->IO.SendBuf.Buf))
-#define NWC_DBG_READ() EVN_syslog(LOG_DEBUG, ": < %s\n", ChrPtr(NW->IO.IOBuf))
-#define NWC_OK (strncasecmp(ChrPtr(NW->IO.IOBuf), "+OK", 3) == 0)
-
-eNextState SendFailureMessage(AsyncIO *IO)
+eNextState NWC_SendFailureMessage(AsyncIO *IO)
 {
        AsyncNetworker *NW = IO->Data;
-       long lens[2];
-       const char *strs[2];
 
-       strs[0] = ChrPtr(NW->node);
-       lens[0] = StrLength(NW->node);
-       
-       strs[1] = ChrPtr(NW->IO.ErrMsg);
-       lens[1] = StrLength(NW->IO.ErrMsg);
-       CtdlAideFPMessage(
-               ChrPtr(NW->IO.ErrMsg),
-               "Networker error",
-               2, strs, (long*) &lens);
-       
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
+
+       CtdlAideMessage(ChrPtr(NW->IO.ErrMsg), "Networker error");
        return eAbort;
 }
 
@@ -229,7 +192,6 @@ eNextState NWC_ReadGreeting(AsyncNetworker *NW)
        char connected_to[SIZ];
        AsyncIO *IO = &NW->IO;
        SetNWCState(IO, eNWCVSGreating);
-       NWC_DBG_READ();
        /* Read the server greeting */
        /* Check that the remote is who we think it is and warn the Aide if not */
        extract_token (connected_to, ChrPtr(NW->IO.IOBuf), 1, ' ', sizeof connected_to);
@@ -240,9 +202,9 @@ eNextState NWC_ReadGreeting(AsyncNetworker *NW)
                StrBufPrintf(NW->IO.ErrMsg,
                             "Connected to node \"%s\" but I was expecting to connect to node \"%s\".",
                             connected_to, ChrPtr(NW->node));
-               EVN_syslog(LOG_ERR, "%s\n", ChrPtr(NW->IO.ErrMsg));
-               StopClientWatchers(IO, 1);
-               return QueueDBOperation(IO, SendFailureMessage);
+               syslog(LOG_ERR, "netpoll: %s", ChrPtr(NW->IO.ErrMsg));
+
+               return EventQueueDBOperation(IO, NWC_SendFailureMessage, 1);
        }
        return eSendReply;
 }
@@ -253,16 +215,14 @@ eNextState NWC_SendAuth(AsyncNetworker *NW)
        SetNWCState(IO, eNWCVSAuth);
        /* We're talking to the correct node.  Now identify ourselves. */
        StrBufPrintf(NW->IO.SendBuf.Buf, "NETP %s|%s\n", 
-                    config.c_nodename
+                    CtdlGetConfigStr("c_nodename")
                     ChrPtr(NW->secret));
-       NWC_DBG_SEND();
        return eSendReply;
 }
 
 eNextState NWC_ReadAuthReply(AsyncNetworker *NW)
 {
        AsyncIO *IO = &NW->IO;
-       NWC_DBG_READ();
        if (ChrPtr(NW->IO.IOBuf)[0] == '2')
        {
                return eSendReply;
@@ -277,16 +237,13 @@ eNextState NWC_ReadAuthReply(AsyncNetworker *NW)
                             ChrPtr(NW->node), ChrPtr(NW->IO.IOBuf) + 4);
                if (Error == 552) {
                        SetNWCState(IO, eNWCVSAuthFailNTT);
-                       EVN_syslog(LOG_INFO,
-                                  "Already talking to %s; skipping this time.\n",
-                                  ChrPtr(NW->node));
+                       syslog(LOG_INFO, "netpoll: already talking to %s; skipping this time.", ChrPtr(NW->node));
                        
                }
                else {
                        SetNWCState(IO, eNWCVSAuthFailNTT);
-                       EVN_syslog(LOG_ERR, "%s\n", ChrPtr(NW->IO.ErrMsg));
-                       StopClientWatchers(IO, 1);
-                       return QueueDBOperation(IO, SendFailureMessage);
+                       syslog(LOG_ERR, "netpoll: %s", ChrPtr(NW->IO.ErrMsg));
+                       return EventQueueDBOperation(IO, NWC_SendFailureMessage, 1);
                }
                return eAbort;
        }
@@ -314,7 +271,6 @@ eNextState NWC_SendNDOP(AsyncNetworker *NW)
        StrBufStripSlashes(NW->tempFileName, 1);
        /* We're talking to the correct node.  Now identify ourselves. */
        StrBufPlain(NW->IO.SendBuf.Buf, HKEY("NDOP\n"));
-       NWC_DBG_SEND();
        return eSendReply;
 }
 
@@ -322,13 +278,19 @@ eNextState NWC_ReadNDOPReply(AsyncNetworker *NW)
 {
        AsyncIO *IO = &NW->IO;
        int TotalSendSize;
-       NWC_DBG_READ();
        if (ChrPtr(NW->IO.IOBuf)[0] == '2')
        {
+               int LogLevel = LOG_DEBUG;
 
                NW->IO.IOB.TotalSentAlready = 0;
+
                TotalSendSize = atol (ChrPtr(NW->IO.IOBuf) + 4);
-               EVN_syslog(LOG_DEBUG, "Expecting to transfer %d bytes\n", TotalSendSize);
+
+               if (TotalSendSize > 0)
+                       LogLevel = LOG_INFO;
+
+               syslog(LogLevel, "netpoll: expecting to transfer %d bytes to %s", TotalSendSize, ChrPtr(NW->tempFileName));
+
                if (TotalSendSize <= 0) {
                        NW->State = eNUOP - 1;
                }
@@ -340,10 +302,7 @@ eNextState NWC_ReadNDOPReply(AsyncNetworker *NW)
                        if (fd < 0)
                        {
                                SetNWCState(IO, eNWCVSFail);
-                               EVN_syslog(LOG_CRIT,
-                                      "cannot open %s: %s\n", 
-                                      ChrPtr(NW->tempFileName), 
-                                      strerror(errno));
+                               syslog(LOG_ERR, "%s: %s", ChrPtr(NW->tempFileName), strerror(errno));
 
                                NW->State = eQUIT - 1;
                                return eAbort;
@@ -378,23 +337,15 @@ eNextState NWC_SendREAD(AsyncNetworker *NW)
                        SetNWCState(IO, eNWCVSFail);
                        return eAbort;
                }
-               StrBufPrintf(NW->IO.SendBuf.Buf, "READ %ld|%ld\n",
+               StrBufPrintf(NW->IO.SendBuf.Buf, "READ "LOFF_T_FMT"|%ld\n",
                             NW->IO.IOB.TotalSentAlready,
                             NW->IO.IOB.TotalSendSize);
-/*
-                            ((NW->IO.IOB.TotalSendSize - NW->IO.IOB.TotalSentAlready > IGNET_PACKET_SIZE)
-                             ? IGNET_PACKET_SIZE : 
-                             (NW->IO.IOB.TotalSendSize - NW->IO.IOB.TotalSentAlready))
-                       );
-*/
-               NWC_DBG_SEND();
                return eSendReply;
        }
        else 
        {
                NW->State = eCLOS;
                rc = NWC_DispatchWriteDone(&NW->IO);
-               NWC_DBG_SEND();
 
                return rc;
        }
@@ -403,7 +354,6 @@ eNextState NWC_SendREAD(AsyncNetworker *NW)
 eNextState NWC_ReadREADState(AsyncNetworker *NW)
 {
        AsyncIO *IO = &NW->IO;
-       NWC_DBG_READ();
        if (ChrPtr(NW->IO.IOBuf)[0] == '6')
        {
                NW->IO.IOB.ChunkSendRemain = 
@@ -417,8 +367,6 @@ eNextState NWC_ReadREADBlobDone(AsyncNetworker *NW);
 eNextState NWC_ReadREADBlob(AsyncNetworker *NW)
 {
        eNextState rc;
-       AsyncIO *IO = &NW->IO;
-       NWC_DBG_READ();
        if (NW->IO.IOB.TotalSendSize == NW->IO.IOB.TotalSentAlready)
        {
                NW->State ++;
@@ -426,13 +374,12 @@ eNextState NWC_ReadREADBlob(AsyncNetworker *NW)
                FDIOBufferDelete(&NW->IO.IOB);
 
                if (link(ChrPtr(NW->tempFileName), ChrPtr(NW->SpoolFileName)) != 0) {
-                       EVN_syslog(LOG_ALERT, 
-                              "Could not link %s to %s: %s\n",
-                              ChrPtr(NW->tempFileName), 
-                              ChrPtr(NW->SpoolFileName), 
-                              strerror(errno));
+                       syslog(LOG_ERR, "netpoll: could not link %s to %s: %s", ChrPtr(NW->tempFileName), ChrPtr(NW->SpoolFileName), strerror(errno));
                }
-       
+               else {
+                       syslog(LOG_INFO, "netpoll: moved %s to %s", ChrPtr(NW->tempFileName), ChrPtr(NW->SpoolFileName));
+               }
+
                unlink(ChrPtr(NW->tempFileName));
                rc = NWC_DispatchWriteDone(&NW->IO);
                NW->State --;
@@ -448,7 +395,6 @@ eNextState NWC_ReadREADBlob(AsyncNetworker *NW)
 eNextState NWC_ReadREADBlobDone(AsyncNetworker *NW)
 {
        eNextState rc;
-       AsyncIO *IO = &NW->IO;
 /* we don't have any data to debug print here. */
        if (NW->IO.IOB.TotalSentAlready >= NW->IO.IOB.TotalSendSize)
        {
@@ -456,11 +402,10 @@ eNextState NWC_ReadREADBlobDone(AsyncNetworker *NW)
 
                FDIOBufferDelete(&NW->IO.IOB);
                if (link(ChrPtr(NW->tempFileName), ChrPtr(NW->SpoolFileName)) != 0) {
-                       EVN_syslog(LOG_ALERT, 
-                              "Could not link %s to %s: %s\n",
-                              ChrPtr(NW->tempFileName), 
-                              ChrPtr(NW->SpoolFileName), 
-                              strerror(errno));
+                       syslog(LOG_ERR, "netpoll: could not link %s to %s: %s", ChrPtr(NW->tempFileName), ChrPtr(NW->SpoolFileName), strerror(errno));
+               }
+               else {
+                       syslog(LOG_INFO, "netpoll: moved %s to %s", ChrPtr(NW->tempFileName), ChrPtr(NW->SpoolFileName));
                }
        
                unlink(ChrPtr(NW->tempFileName));
@@ -479,14 +424,12 @@ eNextState NWC_SendCLOS(AsyncNetworker *NW)
        AsyncIO *IO = &NW->IO;
        SetNWCState(IO, eNWCVSNDOPDone);
        StrBufPlain(NW->IO.SendBuf.Buf, HKEY("CLOS\n"));
-       NWC_DBG_SEND();
        return eSendReply;
 }
 
 eNextState NWC_ReadCLOSReply(AsyncNetworker *NW)
 {
        AsyncIO *IO = &NW->IO;
-       NWC_DBG_READ();
        FDIOBufferDelete(&IO->IOB);
        if (ChrPtr(NW->IO.IOBuf)[0] != '2')
                return eTerminateConnection;
@@ -512,45 +455,40 @@ eNextState NWC_SendNUOP(AsyncNetworker *NW)
        fd = open(ChrPtr(NW->SpoolFileName), O_EXCL|O_NONBLOCK|O_RDONLY);
        if (fd < 0) {
                if (errno != ENOENT) {
-                       EVN_syslog(LOG_CRIT,
-                              "cannot open %s: %s\n", 
-                              ChrPtr(NW->SpoolFileName), 
-                              strerror(errno));
+                       syslog(LOG_ERR, "%s: %s", ChrPtr(NW->SpoolFileName), strerror(errno));
                }
                NW->State = eQUIT;
                rc = NWC_SendQUIT(NW);
-               NWC_DBG_SEND();
                return rc;
        }
 
        if (fstat(fd, &statbuf) == -1) {
-               EVN_syslog(LOG_CRIT, "FSTAT FAILED %s [%s]--\n", 
-                          ChrPtr(NW->SpoolFileName), 
-                          strerror(errno));
+               syslog(LOG_ERR, "%s: %s", ChrPtr(NW->SpoolFileName), strerror(errno));
                if (fd > 0) close(fd);
                return eAbort;
        }
        TotalSendSize = statbuf.st_size;
        if (TotalSendSize == 0) {
-               EVNM_syslog(LOG_DEBUG,
-                      "Nothing to send.\n");
+               syslog(LOG_DEBUG, "netpoll: nothing to send.");
                NW->State = eQUIT;
                rc = NWC_SendQUIT(NW);
-               NWC_DBG_SEND();
                if (fd > 0) close(fd);
                return rc;
        }
+       else
+               {
+               syslog(LOG_INFO, "netpoll: sending %s to %s", ChrPtr(NW->SpoolFileName), ChrPtr(NW->node));
+       }
+
        FDIOBufferInit(&NW->IO.IOB, &NW->IO.SendBuf, fd, TotalSendSize);
 
        StrBufPlain(NW->IO.SendBuf.Buf, HKEY("NUOP\n"));
-       NWC_DBG_SEND();
        return eSendReply;
 
 }
 eNextState NWC_ReadNUOPReply(AsyncNetworker *NW)
 {
        AsyncIO *IO = &NW->IO;
-       NWC_DBG_READ();
        if (ChrPtr(NW->IO.IOBuf)[0] != '2') {
                FDIOBufferDelete(&IO->IOB);
                return eAbort;
@@ -560,16 +498,13 @@ eNextState NWC_ReadNUOPReply(AsyncNetworker *NW)
 
 eNextState NWC_SendWRIT(AsyncNetworker *NW)
 {
-       AsyncIO *IO = &NW->IO;
-       StrBufPrintf(NW->IO.SendBuf.Buf, "WRIT %ld\n", 
+       StrBufPrintf(NW->IO.SendBuf.Buf, "WRIT "LOFF_T_FMT"\n", 
                     NW->IO.IOB.TotalSendSize - NW->IO.IOB.TotalSentAlready);
-       NWC_DBG_SEND();
        return eSendReply;
 }
 eNextState NWC_ReadWRITReply(AsyncNetworker *NW)
 {
        AsyncIO *IO = &NW->IO;
-       NWC_DBG_READ();
        if (ChrPtr(NW->IO.IOBuf)[0] != '7')
        {
                FDIOBufferDelete(&IO->IOB);
@@ -605,20 +540,18 @@ eNextState NWC_SendBlobDone(AsyncNetworker *NW)
 
 eNextState NWC_SendUCLS(AsyncNetworker *NW)
 {
-       AsyncIO *IO = &NW->IO;
        StrBufPlain(NW->IO.SendBuf.Buf, HKEY("UCLS 1\n"));
-       NWC_DBG_SEND();
        return eSendReply;
 
 }
 eNextState NWC_ReadUCLS(AsyncNetworker *NW)
 {
        AsyncIO *IO = &NW->IO;
-       NWC_DBG_READ();
 
-       EVN_syslog(LOG_NOTICE, "Sent %ld octets to <%s>\n", NW->IO.IOB.ChunkSize, ChrPtr(NW->node));
+       syslog(LOG_INFO, "netpoll: sent %s (%ld octets) to <%s>", ChrPtr(NW->SpoolFileName), NW->IO.IOB.ChunkSize, ChrPtr(NW->node));
+
        if (ChrPtr(NW->IO.IOBuf)[0] == '2') {
-               EVN_syslog(LOG_DEBUG, "Removing <%s>\n", ChrPtr(NW->SpoolFileName));
+               syslog(LOG_DEBUG, "Removing <%s>\n", ChrPtr(NW->SpoolFileName));
                unlink(ChrPtr(NW->SpoolFileName));
        }
        FDIOBufferDelete(&IO->IOB);
@@ -628,18 +561,13 @@ eNextState NWC_ReadUCLS(AsyncNetworker *NW)
 
 eNextState NWC_SendQUIT(AsyncNetworker *NW)
 {
-       AsyncIO *IO = &NW->IO;
        StrBufPlain(NW->IO.SendBuf.Buf, HKEY("QUIT\n"));
 
-       NWC_DBG_SEND();
        return eSendReply;
 }
 
 eNextState NWC_ReadQUIT(AsyncNetworker *NW)
 {
-       AsyncIO *IO = &NW->IO;
-       NWC_DBG_READ();
-
        return eAbort;
 }
 
@@ -708,8 +636,6 @@ const long NWC_ReadTimeouts[] = {
 };
 
 
-
-
 eNextState nwc_get_one_host_ip_done(AsyncIO *IO)
 {
        AsyncNetworker *NW = IO->Data;
@@ -755,10 +681,10 @@ eNextState nwc_get_one_host_ip(AsyncIO *IO)
         * here we start with the lookup of one host.
         */ 
 
-       EVN_syslog(LOG_DEBUG, "NWC: %s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
 
-       EVN_syslog(LOG_DEBUG, 
-                  "NWC client[%ld]: looking up %s-Record %s : %d ...\n", 
+       syslog(LOG_DEBUG, 
+                  "netpoll: [%ld]: looking up %s-Record %s : %d ...", 
                   NW->n, 
                   (NW->IO.ConnectMe->IPv6)? "aaaa": "a",
                   NW->IO.ConnectMe->Host, 
@@ -808,46 +734,35 @@ eReadState NWC_ReadServerStatus(AsyncIO *IO)
 eNextState NWC_FailNetworkConnection(AsyncIO *IO)
 {
        SetNWCState(IO, eNWCVSConnFail);
-       StopClientWatchers(IO, 1);
-       return QueueDBOperation(IO, SendFailureMessage);
+       return EventQueueDBOperation(IO, NWC_SendFailureMessage, 1);
 }
 
 void NWC_SetTimeout(eNextState NextTCPState, AsyncNetworker *NW)
 {
-       AsyncIO *IO = &NW->IO;
        double Timeout = 0.0;
 
-       EVN_syslog(LOG_DEBUG, "%s - %d\n", __FUNCTION__, NextTCPState);
-
        switch (NextTCPState) {
-       case eSendReply:
        case eSendMore:
-               break;
-       case eReadFile:
+       case eSendReply:
        case eReadMessage:
                Timeout = NWC_ReadTimeouts[NW->State];
                break;
+       case eReadFile:
+       case eSendFile:
        case eReadPayload:
                Timeout = 100000;
-               /* TODO!!! */
                break;
        case eSendDNSQuery:
        case eReadDNSReply:
+       case eDBQuery:
+       case eReadMore:
        case eConnect:
-       case eSendFile:
-//TODO
        case eTerminateConnection:
-       case eDBQuery:
        case eAbort:
-       case eReadMore://// TODO
                return;
        }
        if (Timeout > 0) {
-               EVN_syslog(LOG_DEBUG, 
-                          "%s - %d %f\n",
-                          __FUNCTION__,
-                          NextTCPState,
-                          Timeout);
+               syslog(LOG_DEBUG, "netpoll: %s - %d %f", __FUNCTION__, NextTCPState, Timeout);
                SetNextTimeout(&NW->IO, Timeout*100);
        }
 }
@@ -855,19 +770,25 @@ void NWC_SetTimeout(eNextState NextTCPState, AsyncNetworker *NW)
 
 eNextState NWC_DispatchReadDone(AsyncIO *IO)
 {
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
        AsyncNetworker *NW = IO->Data;
        eNextState rc;
 
        rc = NWC_ReadHandlers[NW->State](NW);
-       if (rc != eReadMore)
+
+       if ((rc != eReadMore) &&
+           (rc != eAbort) && 
+           (rc != eDBQuery)) {
                NW->State++;
+       }
+
        NWC_SetTimeout(rc, NW);
+
        return rc;
 }
 eNextState NWC_DispatchWriteDone(AsyncIO *IO)
 {
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
        AsyncNetworker *NW = IO->Data;
        eNextState rc;
 
@@ -881,14 +802,14 @@ eNextState NWC_DispatchWriteDone(AsyncIO *IO)
 /*****************************************************************************/
 eNextState NWC_Terminate(AsyncIO *IO)
 {
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
        FinalizeNetworker(IO);
        return eAbort;
 }
 
 eNextState NWC_TerminateDB(AsyncIO *IO)
 {
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
        FinalizeNetworker(IO);
        return eAbort;
 }
@@ -896,7 +817,7 @@ eNextState NWC_TerminateDB(AsyncIO *IO)
 eNextState NWC_Timeout(AsyncIO *IO)
 {
        AsyncNetworker *NW = IO->Data;
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
 
        if (NW->IO.ErrMsg == NULL)
                NW->IO.ErrMsg = NewStrBuf();
@@ -907,7 +828,7 @@ eNextState NWC_ConnFail(AsyncIO *IO)
 {
        AsyncNetworker *NW = IO->Data;
 
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
        if (NW->IO.ErrMsg == NULL)
                NW->IO.ErrMsg = NewStrBuf();
        StrBufPrintf(NW->IO.ErrMsg, "failed to connect %s \r\n", ChrPtr(NW->host));
@@ -918,7 +839,7 @@ eNextState NWC_DNSFail(AsyncIO *IO)
 {
        AsyncNetworker *NW = IO->Data;
 
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
        if (NW->IO.ErrMsg == NULL)
                NW->IO.ErrMsg = NewStrBuf();
        StrBufPrintf(NW->IO.ErrMsg, "failed to look up %s \r\n", ChrPtr(NW->host));
@@ -927,7 +848,7 @@ eNextState NWC_DNSFail(AsyncIO *IO)
 }
 eNextState NWC_Shutdown(AsyncIO *IO)
 {
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
 
        FinalizeNetworker(IO);
        return eAbort;
@@ -939,11 +860,8 @@ eNextState nwc_connect_ip(AsyncIO *IO)
        AsyncNetworker *NW = IO->Data;
 
        SetNWCState(&NW->IO, eNWCVSConnecting);
-       EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
-       EVN_syslog(LOG_NOTICE, "Connecting to <%s> at %s:%s\n", 
-                  ChrPtr(NW->node), 
-                  ChrPtr(NW->host),
-                  ChrPtr(NW->port));
+       syslog(LOG_DEBUG, "netpoll: %s", __FUNCTION__);
+       syslog(LOG_INFO, "netpoll: onnecting to <%s> at %s:%s", ChrPtr(NW->node), ChrPtr(NW->host), ChrPtr(NW->port));
        
        return EvConnectSock(IO,
                             NWC_ConnTimeout,
@@ -956,7 +874,7 @@ void RunNetworker(AsyncNetworker *NW)
 {
        NW->n = NetworkerCount++;
        CtdlNetworkTalkingTo(SKEY(NW->node), NTT_ADD);
-       syslog(LOG_DEBUG, "NW[%s][%ld]: polling\n", ChrPtr(NW->node), NW->n);
+       syslog(LOG_DEBUG, "netpoll: NW[%s][%ld]: polling", ChrPtr(NW->node), NW->n);
        ParseURL(&NW->IO.ConnectMe, NW->Url, 504);
 
        InitIOStruct(&NW->IO,
@@ -988,6 +906,7 @@ void RunNetworker(AsyncNetworker *NW)
        }
 }
 
+
 /*
  * Poll other Citadel nodes and transfer inbound/outbound network data.
  * Set "full" to nonzero to force a poll of every node, or to zero to poll
@@ -1005,7 +924,7 @@ void network_poll_other_citadel_nodes(int full_poll, HashList *ignetcfg)
        int poll = 0;
        
        if (GetCount(ignetcfg) ==0) {
-               syslog(LOG_DEBUG, "network: no neighbor nodes are configured - not polling.\n");
+               syslog(LOG_DEBUG, "netpoll: no neighbor nodes are configured - not polling");
                return;
        }
        become_session(&networker_client_CC);
@@ -1046,15 +965,10 @@ void network_poll_other_citadel_nodes(int full_poll, HashList *ignetcfg)
                                }
                        }
                }
-               if (poll && 
-                   (StrLength(NW->host) > 0) && 
-                   strcmp("0.0.0.0", ChrPtr(NW->host)))
+               if (poll && (StrLength(NW->host) > 0) && strcmp("0.0.0.0", ChrPtr(NW->host)))
                {
                        NW->Url = NewStrBuf();
-                       StrBufPrintf(NW->Url, "citadel://%s@%s:%s", 
-                                    ChrPtr(NW->secret),
-                                    ChrPtr(NW->host),
-                                    ChrPtr(NW->port));
+                       StrBufPrintf(NW->Url, "citadel://%s@%s:%s", ChrPtr(NW->secret), ChrPtr(NW->host), ChrPtr(NW->port));
                        if (!CtdlNetworkTalkingTo(SKEY(NW->node), NTT_CHECK))
                        {
                                RunNetworker(NW);
@@ -1078,10 +992,11 @@ void network_do_clientqueue(void)
         * Run the full set of processing tasks no more frequently
         * than once every n seconds
         */
-       if ( (time(NULL) - last_run) < config.c_net_freq ) {
+       if ( (time(NULL) - last_run) < CtdlGetConfigLong("c_net_freq") )
+       {
                full_processing = 0;
-               syslog(LOG_DEBUG, "Network full processing in %ld seconds.\n",
-                       config.c_net_freq - (time(NULL)- last_run)
+               syslog(LOG_DEBUG, "netpoll: full processing in %ld seconds.",
+                       CtdlGetConfigLong("c_net_freq") - (time(NULL)- last_run)
                );
        }
 
@@ -1095,10 +1010,6 @@ void network_do_clientqueue(void)
        DeleteHash(&working_ignetcfg);
 }
 
-void LogDebugEnableNetworkClient(const int n)
-{
-       NetworkClientDebugEnabled = n;
-}
 /*
  * Module entry point
  */
@@ -1107,9 +1018,7 @@ CTDL_MODULE_INIT(network_client)
        if (!threading)
        {
                CtdlFillSystemContext(&networker_client_CC, "CitNetworker");
-               
                CtdlRegisterSessionHook(network_do_clientqueue, EVT_TIMER, PRIO_SEND + 10);
-               CtdlRegisterDebugFlagHook(HKEY("networkclient"), LogDebugEnableNetworkClient, &NetworkClientDebugEnabled);
 
        }
        return "networkclient";