Check return value of pool_flush().
authorYoshiyuki Asaba <y-asaba at pgfoundry.org>
Fri, 26 Oct 2007 03:02:19 +0000 (03:02 +0000)
committerYoshiyuki Asaba <y-asaba at pgfoundry.org>
Fri, 26 Oct 2007 03:02:19 +0000 (03:02 +0000)
pool_process_query.c

index fcf7ee238fe0b7d1c35e564eb2753fa930f14faa..d174c353b43db46f9c193d8982ad9e51fce6e338 100644 (file)
@@ -98,7 +98,8 @@ static POOL_STATUS EmptyQueryResponse(POOL_CONNECTION *frontend,
                                                                          POOL_CONNECTION_POOL *backend);
 
 static int RowDescription(POOL_CONNECTION *frontend, 
-                                                 POOL_CONNECTION_POOL *backend);
+                                                 POOL_CONNECTION_POOL *backend,
+                                                 short *result);
 
 static POOL_STATUS AsciiRow(POOL_CONNECTION *frontend, 
                                                        POOL_CONNECTION_POOL *backend,
@@ -493,12 +494,7 @@ POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
 
                                case 'T':
                                        /* RowDescription */
-                                       status = RowDescription(frontend, backend);
-                                       if (status < 0)
-                                               return POOL_ERROR;
-
-                                       num_fields = status;
-                                       status = POOL_CONTINUE;
+                                       status = RowDescription(frontend, backend, &num_fields);
                                        break;
 
                                case 'V':
@@ -941,12 +937,14 @@ static POOL_STATUS Execute(POOL_CONNECTION *frontend,
                status = SimpleForwardToFrontend(kind, frontend, backend);
                if (status != POOL_CONTINUE)
                        return status;
-               pool_flush(frontend);
+               if (pool_flush(frontend))
+                       return POOL_END;
        }
        status = SimpleForwardToFrontend(kind, frontend, backend);
        if (status != POOL_CONTINUE)
                return status;
-       pool_flush(frontend);
+       if (pool_flush(frontend))
+               return POOL_END;
 
        /* end load balance mode */
        if (in_load_balance)
@@ -1217,7 +1215,8 @@ static POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend,
                internal_transaction_started = 0;
        }
 
-       pool_flush(frontend);
+       if (pool_flush(frontend))
+               return POOL_END;
 
        if (send_ready)
        {
@@ -1322,7 +1321,8 @@ static POOL_STATUS CompleteCommandResponse(POOL_CONNECTION *frontend,
 }
 
 static int RowDescription(POOL_CONNECTION *frontend, 
-                                                 POOL_CONNECTION_POOL *backend)
+                                                 POOL_CONNECTION_POOL *backend,
+                                                 short *result)
 {
        short num_fields, num_fields1;
        int oid, mod;
@@ -1422,7 +1422,12 @@ static int RowDescription(POOL_CONNECTION *frontend,
                pool_write(frontend, &mod, sizeof(int));
        }
 
-       return num_fields;
+       if (pool_flush(frontend))
+               return POOL_END;
+
+       *result = num_fields;
+
+       return POOL_CONTINUE;
 }
 
 static POOL_STATUS AsciiRow(POOL_CONNECTION *frontend, 
@@ -1531,6 +1536,9 @@ static POOL_STATUS AsciiRow(POOL_CONNECTION *frontend,
                mask >>= 1;
        }
 
+       if (pool_flush(frontend))
+               return POOL_END;
+
        return POOL_CONTINUE;
 }
 
@@ -1634,6 +1642,10 @@ static POOL_STATUS BinaryRow(POOL_CONNECTION *frontend,
 
                mask >>= 1;
        }
+
+       if (pool_flush(frontend))
+               return POOL_END;
+
        return POOL_CONTINUE;
 }
 
@@ -1663,7 +1675,7 @@ static POOL_STATUS CursorResponse(POOL_CONNECTION *frontend,
 
        /* forward to the frontend */
        pool_write(frontend, "P", 1);
-       if (pool_write(frontend, string, len) < 0)
+       if (pool_write_and_flush(frontend, string, len) < 0)
        {
                return POOL_END;
        }
@@ -2876,7 +2888,8 @@ POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_C
                        ret = SimpleForwardToFrontend(k, frontend, backend);
                        if (ret != POOL_CONTINUE)
                                return ret;
-                       pool_flush(frontend);
+                       if (pool_flush(frontend) != 0)
+                               return POOL_END;
                }
 
                status = pool_read(MASTER(backend), &res1, sizeof(res1));
@@ -3058,7 +3071,8 @@ POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CO
                                return POOL_ERROR;
                        }
                        SimpleForwardToFrontend(kind1, frontend, backend);
-                       pool_flush(frontend);
+                       if (pool_flush(frontend))
+                               return POOL_END;
                }
 
                for (;;)