From ad7334129a563b0bd72fef9e6b6a7cb8b19b0c5c Mon Sep 17 00:00:00 2001 From: "Stephen R. van den Berg" <srb@cuci.nl> Date: Mon, 22 Jun 2020 14:02:00 +0200 Subject: [PATCH] pgsql: Terminate early if the processloop has already folded. --- lib/modules/Sql.pmod/pgsql_util.pmod | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/modules/Sql.pmod/pgsql_util.pmod b/lib/modules/Sql.pmod/pgsql_util.pmod index 9cede304cf..57b9f6ccd7 100644 --- a/lib/modules/Sql.pmod/pgsql_util.pmod +++ b/lib/modules/Sql.pmod/pgsql_util.pmod @@ -1784,7 +1784,7 @@ class proxy { final int _fetchlimit = FETCHLIMIT; final MUTEX unnamedportalmux; final MUTEX unnamedstatement; - private Thread.MutexKey termlock; + private Thread.MutexKey|int termlock; final Thread.ResourceCount portalsinflight, statementsinflight; final int(0..1) wasparallelisable; final int(0..1) intransaction; @@ -1960,7 +1960,7 @@ class proxy { if (catch(cs = ci->start())) { destruct(waitforauthready); unnamedstatement = 0; - termlock = 0; + termlock = 1; return; } else { CHAIN(cs)->add_hstring(plugbuffer, 4, 4); @@ -2668,13 +2668,13 @@ class proxy { portal->_purgeportal(); } destruct(waitforauthready); - termlock = 0; + termlock = 1; if (err && !stringp(err)) throw(err); }; catch { - unnamedstatement = 0; - termlock = 0; + unnamedstatement = 0; + termlock = 1; if (err) { PD("Terminating processloop due to %s\n", describe_backtrace(err)); delayederror = err; @@ -2688,7 +2688,7 @@ class proxy { throwdelayederror(this); { Thread.MutexKey lock; - if (unnamedstatement) + if (unnamedstatement && !termlock) termlock = unnamedstatement->lock(1); foreach (c->runningportals; sql_result result; ) if (result->_state < CLOSED) -- GitLab