From bfa255e5d5833de3fccccabbcb4a764e74ca470a Mon Sep 17 00:00:00 2001 From: "Stephen R. van den Berg" <srb@cuci.nl> Date: Sat, 15 Oct 2016 02:18:39 +0200 Subject: [PATCH] pgsql: Eliminate hanging selects. --- lib/modules/Sql.pmod/pgsql_util.pmod | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/modules/Sql.pmod/pgsql_util.pmod b/lib/modules/Sql.pmod/pgsql_util.pmod index fff0261f78..74d872aa4f 100644 --- a/lib/modules/Sql.pmod/pgsql_util.pmod +++ b/lib/modules/Sql.pmod/pgsql_util.pmod @@ -156,6 +156,10 @@ class bufcon { realbuffer=_realbuffer; } + final int `stashcount() { + return realbuffer->stashcount; + } + final bufcon start(void|int waitforreal) { realbuffer->stashcount++; #ifdef PG_DEBUG @@ -930,11 +934,6 @@ class sql_result { PD("%O Try Closeportal %d\n",_portalname,_state); Thread.MutexKey lock=closemux->lock(); _fetchlimit=0; // disables further Executes - int alreadyfilled=sizeof(plugbuffer); - /* alreadyfilled will be non-zero if a parse request has been queued - * before the close was initiated. - * It's a bit of a tricky race, but this check should be sufficient. - */ switch(_state) { case PORTALINIT: _unnamedstatementkey=0; @@ -958,7 +957,12 @@ class sql_result { PD("Signal no portals in flight\n"); catch(pgsqlsess->_readyforcommit->signal()); lockc=0; - } else if(!alreadyfilled) + /* + * stashcount will be non-zero if a parse request has been queued + * before the close was initiated. + * It's a bit of a tricky race, but this check should be sufficient. + */ + } else if (!plugbuffer->stashcount) pgsqlsess->_readyforquerycount++, retval=SYNCSEND; pgsqlsess->_pportalcount=0; } -- GitLab