FDIO: don't set fd's to 0, -1 is better since its safe for abuse.
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 17 Aug 2013 10:14:57 +0000 (12:14 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sat, 17 Aug 2013 10:14:57 +0000 (12:14 +0200)
libcitadel/lib/stringbuf.c

index 9bc1c8eb04aa9015ab7f5d62abdd50fe5b2d0175..1b9ea072366221b9bea1f8cf1f438a229f795bb3 100644 (file)
@@ -3934,9 +3934,17 @@ long IOBufferStrLength(IOBuffer *FB)
        return StrLength(FB->Buf) - (FB->ReadWritePointer - FB->Buf->buf);
 }
 
-void FDIOBufferInit(FDIOBuffer *FDB, IOBuffer *IO, int FD, long TotalSendSize)
+inline static void FDIOBufferFlush(FDIOBuffer *FDB)
 {
        memset(FDB, 0, sizeof(FDIOBuffer));
+       FDB->OtherFD = -1;
+       FDB->SplicePipe[0] = -1;
+       FDB->SplicePipe[1] = -1;
+}
+
+void FDIOBufferInit(FDIOBuffer *FDB, IOBuffer *IO, int FD, long TotalSendSize)
+{
+       FDIOBufferFlush(FDB);
        FDB->ChunkSize = 
                FDB->TotalSendSize = TotalSendSize;
        FDB->IOB = IO;
@@ -3966,7 +3974,7 @@ void FDIOBufferDelete(FDIOBuffer *FDB)
        
        if (FDB->OtherFD > 0)
                close(FDB->OtherFD);
-       memset(FDB, 0, sizeof(FDIOBuffer));     
+       FDIOBufferFlush(FDB);
 }
 
 int FileSendChunked(FDIOBuffer *FDB, const char **Err)