Add error checking.
authorYoshiyuki Asaba <y-asaba at pgfoundry.org>
Tue, 26 Feb 2008 02:21:15 +0000 (02:21 +0000)
committerYoshiyuki Asaba <y-asaba at pgfoundry.org>
Tue, 26 Feb 2008 02:21:15 +0000 (02:21 +0000)
pool_stream.c

index 0ac1057e630eaf6fb7bb0586f998c1a8acb0b2b4..99ae32146227907544af5a415db836c7d3a7781d 100644 (file)
@@ -335,15 +335,16 @@ int pool_write(POOL_CONNECTION *cp, void *buf, int len)
 
        while (len > 0)
        {
-               int remainder = cp->wbufsz - cp->wbufpo;
+               int remainder = WRITEBUFSZ - cp->wbufpo;
 
-               if (remainder <= 0)
+               if (cp->wbufpo >= WRITEBUFSZ)
                {
                        /*
                         * Write buffer is full. so flush buffer.
                         * wbufpo is reset in pool_flush_it().
                         */
-                       pool_flush_it(cp);
+                       if (pool_flush_it(cp) == -1)
+                               return -1;
                        remainder = WRITEBUFSZ;
                }