* don't continue to read, if we don't have a valid FD
authorWilfried Göesgens <willi@citadel.org>
Sun, 4 Oct 2009 10:38:45 +0000 (10:38 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 4 Oct 2009 10:38:45 +0000 (10:38 +0000)
libcitadel/lib/stringbuf.c

index 463f978b5e8e44e505e7c969dd4379b05e49da54..5b4a2090778ac783c6e48da262794ca030eb4203 100644 (file)
@@ -1847,7 +1847,9 @@ int StrBufTCP_read_buffered_line_fast(StrBuf *Line,
        IsNonBlock = (fdflags & O_NONBLOCK) == O_NONBLOCK;
 
        pch = NULL;
-       while ((nSuccessLess < timeout) && (pch == NULL)) {
+       while ((nSuccessLess < timeout) && 
+              (pch == NULL) &&
+              (*fd != -1)) {
                if (IsNonBlock)
                {
                        tv.tv_sec = 1;
@@ -1943,7 +1945,9 @@ int StrBufReadBLOB(StrBuf *Buf, int *fd, int append, long nBytes, const char **E
        fdflags = fcntl(*fd, F_GETFL);
        IsNonBlock = (fdflags & O_NONBLOCK) == O_NONBLOCK;
        nSuccessLess = 0;
-       while (nRead < nBytes) {
+       while ((nRead < nBytes) && 
+              (*fd != -1)) 
+       {
                if (IsNonBlock)
                {
                        tv.tv_sec = 1;
@@ -2072,7 +2076,8 @@ int StrBufReadBLOBBuffered(StrBuf *Blob,
        SelRes = 1;
        nBytes -= nRead;
        nRead = 0;
-       while (nRead < nBytes) {
+       while ((nRead < nBytes) &&
+              (*fd != -1)) {
                if (IsNonBlock)
                {
                        tv.tv_sec = 1;