Fixed logging bug in filterread.
[doldaconnect.git] / daemon / transfer.c
index db43f34..1d4bd21 100644 (file)
@@ -40,6 +40,8 @@
 
 static void killfilter(struct transfer *transfer);
 
+unsigned long long bytesupload = 0;
+unsigned long long bytesdownload = 0;
 struct transfer *transfers = NULL;
 int numtransfers = 0;
 GCBCHAIN(newtransfercb, struct transfer *);
@@ -240,6 +242,7 @@ void transferputdata(struct transfer *transfer, void *buf, size_t size)
     time(&transfer->activity);
     sockqueue(transfer->localend, buf, size);
     transfer->curpos += size;
+    bytesdownload += size;
     CBCHAINDOCB(transfer, trans_p, transfer);
 }
 
@@ -279,6 +282,7 @@ void *transfergetdata(struct transfer *transfer, size_t *size)
        buf = srealloc(buf, *size);
     }
     transfer->curpos += *size;
+    bytesupload += *size;
     CBCHAINDOCB(transfer, trans_p, transfer);
     return(buf);
 }
@@ -572,7 +576,7 @@ static void filterread(struct socket *sk, struct transfer *transfer)
        return;
     bufcat(transfer->filterbuf, buf, bufsize);
     free(buf);
-    if((p = memchr(transfer->filterbuf, '\n', transfer->filterbufdata)) != NULL)
+    while((p = memchr(transfer->filterbuf, '\n', transfer->filterbufdata)) != NULL)
     {
        *(p++) = 0;
        if((p2 = strchr(transfer->filterbuf, ' ')) != NULL)
@@ -583,7 +587,7 @@ static void filterread(struct socket *sk, struct transfer *transfer)
            if(p2 != NULL)
            {
                if((arg = icmbstowcs(p2, NULL)) == NULL)
-                   flog(LOG_WARNING, "filter sent a string which could not be converted into the local charset: %s: %s", transfer->filterbuf, strerror(errno));
+                   flog(LOG_WARNING, "filter sent a string which could not be converted into the local charset: %s: %s", p2, strerror(errno));
            }
            CBCHAINDOCB(transfer, trans_filterout, transfer, cmd, arg);
            if(arg != NULL)