remote_wait_for_cancel: move pending check before poll()
authorMarko Kreen <markokr@gmail.com>
Mon, 8 Jul 2013 15:00:52 +0000 (18:00 +0300)
committerMarko Kreen <markokr@gmail.com>
Mon, 8 Jul 2013 15:01:59 +0000 (18:01 +0300)
Otherwise it can still hang.

src/execute.c

index 00d5c91456ee013c691fc10d7edc8cac73cee456..f0f1cc1db5861138fcc20dc2b127498f3616490a 100644 (file)
@@ -794,19 +794,15 @@ remote_wait_for_cancel(ProxyFunction *func)
        ProxyConnection *conn;
        ProxyCluster *cluster = func->cur_cluster;
        int                     i,
-                               pending = 1;
+                               pending;
        struct timeval now;
 
        /* now loop until all results are arrived */
-       while (pending)
+       while (1)
        {
                /* allow postgres to cancel processing */
                CHECK_FOR_INTERRUPTS();
 
-               /* wait for events */
-               if (poll_conns(func, cluster) == 0)
-                       continue;
-
                /* recheck */
                pending = 0;
                gettimeofday(&now, NULL);
@@ -820,6 +816,11 @@ remote_wait_for_cancel(ProxyFunction *func)
                                pending++;
                        check_timeouts(func, cluster, conn, now.tv_sec);
                }
+               if (!pending)
+                       break;
+
+               /* wait for events */
+               poll_conns(func, cluster);
        }
 
        /* review results, calculate total */