Skip to content
Snippets Groups Projects
Commit ad733412 authored by Stephen R. van den Berg's avatar Stephen R. van den Berg
Browse files

pgsql: Terminate early if the processloop has already folded.

parent 8ab1c35b
No related branches found
No related tags found
No related merge requests found
...@@ -1784,7 +1784,7 @@ class proxy { ...@@ -1784,7 +1784,7 @@ class proxy {
final int _fetchlimit = FETCHLIMIT; final int _fetchlimit = FETCHLIMIT;
final MUTEX unnamedportalmux; final MUTEX unnamedportalmux;
final MUTEX unnamedstatement; final MUTEX unnamedstatement;
private Thread.MutexKey termlock; private Thread.MutexKey|int termlock;
final Thread.ResourceCount portalsinflight, statementsinflight; final Thread.ResourceCount portalsinflight, statementsinflight;
final int(0..1) wasparallelisable; final int(0..1) wasparallelisable;
final int(0..1) intransaction; final int(0..1) intransaction;
...@@ -1960,7 +1960,7 @@ class proxy { ...@@ -1960,7 +1960,7 @@ class proxy {
if (catch(cs = ci->start())) { if (catch(cs = ci->start())) {
destruct(waitforauthready); destruct(waitforauthready);
unnamedstatement = 0; unnamedstatement = 0;
termlock = 0; termlock = 1;
return; return;
} else { } else {
CHAIN(cs)->add_hstring(plugbuffer, 4, 4); CHAIN(cs)->add_hstring(plugbuffer, 4, 4);
...@@ -2668,13 +2668,13 @@ class proxy { ...@@ -2668,13 +2668,13 @@ class proxy {
portal->_purgeportal(); portal->_purgeportal();
} }
destruct(waitforauthready); destruct(waitforauthready);
termlock = 0; termlock = 1;
if (err && !stringp(err)) if (err && !stringp(err))
throw(err); throw(err);
}; };
catch { catch {
unnamedstatement = 0; unnamedstatement = 0;
termlock = 0; termlock = 1;
if (err) { if (err) {
PD("Terminating processloop due to %s\n", describe_backtrace(err)); PD("Terminating processloop due to %s\n", describe_backtrace(err));
delayederror = err; delayederror = err;
...@@ -2688,7 +2688,7 @@ class proxy { ...@@ -2688,7 +2688,7 @@ class proxy {
throwdelayederror(this); throwdelayederror(this);
{ {
Thread.MutexKey lock; Thread.MutexKey lock;
if (unnamedstatement) if (unnamedstatement && !termlock)
termlock = unnamedstatement->lock(1); termlock = unnamedstatement->lock(1);
foreach (c->runningportals; sql_result result; ) foreach (c->runningportals; sql_result result; )
if (result->_state < CLOSED) if (result->_state < CLOSED)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment