]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Made InspSocket::Read return an empty but non-NULL string when it receives EAGAIN...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 15 Jan 2006 12:59:45 +0000 (12:59 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 15 Jan 2006 12:59:45 +0000 (12:59 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2792 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_spanningtree.cpp
src/socket.cpp

index 8071f8828e2efc962080c693af09a9a75f86bea6..292c927564a34c39a33959944033d60112a82880 100644 (file)
@@ -1246,7 +1246,8 @@ class TreeSocket : public InspSocket
         virtual bool OnDataReady()
        {
                char* data = this->Read();
-               if (data)
+               /* Check that the data read is a valid pointer and it has some content */
+               if (data && *data)
                {
                        this->in_buffer += data;
                        /* While there is at least one new line in the buffer,
@@ -1295,6 +1296,9 @@ class TreeSocket : public InspSocket
                                }
                        }
                }
+               /* EAGAIN returns an empty but non-NULL string, so this
+                * evaluates to TRUE for EAGAIN but to FALSE for EOF.
+                */
                return (data != NULL);
        }
 
index 7147c263c2f8532e0b39124b5cd0dc406fe7909d..c202914539f8d772a40e63e56496750fec8cd03a 100644 (file)
@@ -162,8 +162,15 @@ char* InspSocket::Read()
        }
        else
        {
-               log(DEBUG,"EOF or error on socket");
-               return NULL;
+               if (n == EAGAIN)
+               {
+                       return "";
+               }
+               else
+               {
+                       log(DEBUG,"EOF or error on socket");
+                       return NULL;
+               }
        }
 }