From: Wilfried Goesgens Date: Sat, 17 Aug 2013 10:14:57 +0000 (+0200) Subject: FDIO: don't set fd's to 0, -1 is better since its safe for abuse. X-Git-Tag: v8.22~24 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=3507fe14432a1ed1ca70c503fc4d2df026d51ade FDIO: don't set fd's to 0, -1 is better since its safe for abuse. --- diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 9bc1c8eb0..1b9ea0723 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -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)