Truncate the calculated transfer curpos when reading local file data.
authorFredrik Tolf <fredrik@dolda2000.com>
Thu, 5 Nov 2009 15:59:08 +0000 (16:59 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Thu, 5 Nov 2009 15:59:08 +0000 (16:59 +0100)
With command-stream text left unsent in the socket pipe, curpos would
become negative, which messes things up.

daemon/transfer.c

index 62e81d6..1863e74 100644 (file)
@@ -142,7 +142,8 @@ static void localread(struct socket *sk, struct transfer *transfer)
        transfer->localpos += blen;
        bytesupload += blen;
     }
-    curpos = transfer->localpos - socktqueuesize(transfer->datapipe);
+    if((curpos = transfer->localpos - socktqueuesize(transfer->datapipe)) < 0)
+       curpos = 0;
     if(curpos != transfer->curpos) {
        transfer->curpos = curpos;
        CBCHAINDOCB(transfer, trans_p, transfer);