From: Wilfried Goesgens Date: Wed, 31 Aug 2011 08:01:45 +0000 (+0000) Subject: StrBufChunkSipLine(): compact buffer if we have a remaining snippet at the end of... X-Git-Tag: v8.11~996 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=1acf8374638d36926c5ecd37eb15bd01811720ba StrBufChunkSipLine(): compact buffer if we have a remaining snippet at the end of the buffer --- diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 2ee3a2534..044cecf0a 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -3705,7 +3705,18 @@ eReadState StrBufChunkSipLine(StrBuf *LineBuf, IOBuffer *FB) optr --; if ((*(ptr - 1) != '\r') && (*(ptr - 1) != '\n')) { LineBuf->BufUsed = optr - LineBuf->buf; - *optr = '\0'; + *optr = '\0'; + if ((FB->ReadWritePointer != NULL) && + (FB->ReadWritePointer != FB->Buf->buf)) + { + /* Ok, the client application read all the data + it was interested in so far. Since there is more to read, + we now shrink the buffer, and move the rest over. + */ + StrBufCutLeft(FB->Buf, + FB->ReadWritePointer - FB->Buf->buf); + FB->ReadWritePointer = NULL; + } return eMustReadMore; } }