From 294e9a5fefb618b018e47b6b48d00593e0ed735a Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Mon, 8 Jul 2013 18:00:52 +0300 Subject: [PATCH] remote_wait_for_cancel: move pending check before poll() Otherwise it can still hang. --- src/execute.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/execute.c b/src/execute.c index 00d5c91..f0f1cc1 100644 --- a/src/execute.c +++ b/src/execute.c @@ -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 */ -- 2.39.5