Networkclient: opend spoolfile with proper flags for splice(); fix some minor stabili...
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 10 Jun 2012 15:16:14 +0000 (17:16 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 10 Jun 2012 15:16:14 +0000 (17:16 +0200)
citadel/modules/network/serv_networkclient.c

index fbce060ebf22416f6968c91b0858e21de37fbae9..174bf9daeadfd1d280f406ae2477e9a3a8f3c5c3 100644 (file)
@@ -274,7 +274,7 @@ eNextState NWC_ReadNDOPReply(AsyncNetworker *NW)
 
                NW->IO.IOB.TotalSentAlready = 0;
                TotalSendSize = atol (ChrPtr(NW->IO.IOBuf) + 4);
-               EVN_syslog(LOG_DEBUG, "Expecting to transfer %ld bytes\n", TotalSendSize);
+               EVN_syslog(LOG_DEBUG, "Expecting to transfer %d bytes\n", TotalSendSize);
                if (TotalSendSize <= 0) {
                        NW->State = eNUOP - 1;
                }
@@ -391,7 +391,7 @@ 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.TotalSendSize == NW->IO.IOB.TotalSentAlready)
+       if (NW->IO.IOB.TotalSentAlready >= NW->IO.IOB.TotalSendSize)
        {
                NW->State ++;
 
@@ -448,7 +448,7 @@ eNextState NWC_SendNUOP(AsyncNetworker *NW)
                     ChrPtr(NW->node));
        StrBufStripSlashes(NW->SpoolFileName, 1);
 
-       fd = open(ChrPtr(NW->SpoolFileName), O_RDONLY);
+       fd = open(ChrPtr(NW->SpoolFileName), O_EXCL|O_NONBLOCK|O_RDONLY);
        if (fd < 0) {
                if (errno != ENOENT) {
                        EVN_syslog(LOG_CRIT,
@@ -520,7 +520,7 @@ eNextState NWC_SendBlobDone(AsyncNetworker *NW)
 {
        AsyncIO *IO = &NW->IO;
        eNextState rc;
-       if (IO->IOB.TotalSendSize == NW->IO.IOB.TotalSentAlready)
+       if (NW->IO.IOB.TotalSentAlready >= IO->IOB.TotalSendSize)
        {
                NW->State ++;