2015-12-05
2015-12-05 21:47:28 by Stephen R. van den Berg <srb@cuci.nl>
-
7f73f414447a141597e3cdbd4473d23fdf01c92e
(39 lines)
(+29/-10)
[
Show
| Annotate
]
Branch: 8.1
pgsql: Terminate threads when connections are idle.
587:
return .pgsql_util.local_backend->call_out(f,delay,@args);
}
+ private int|.pgsql_util.sql_result portal; // state information procmessage
+ #ifdef PG_DEBUG
+ private string datarowdebug;
+ private int datarowdebugcount;
+ #endif
+
final void _processloop(.pgsql_util.conxion ci) {
- int terminating=0;
- .pgsql_util.conxiin cr=ci->i;
- int|.pgsql_util.sql_result portal;
- mixed err;
+ (c=ci)->socket->set_id(procmessage);
+ cancelsecret=0;
+ portal=0;
{
Stdio.Buffer plugbuffer=Stdio.Buffer()->add_int32(PG_PROTOCOL(3,0));
if(user)
612:
_connectfail();
else
destruct(waitforauthready);
- return;
+ } else // Do not flush at this point, PostgreSQL 9.4 disapproves
+ procmessage();
}
- } // Do not flush at this point, PostgreSQL 9.4 disapproves
- cancelsecret=0;
+ }
+
+ private void procmessage() {
+ int terminating=0;
+ .pgsql_util.conxion ci=c; // cache value FIXME sensible?
+ .pgsql_util.conxiin cr=ci->i; // cache value FIXME sensible?
+ mixed err;
#ifdef PG_DEBUG
PD("Processloop\n");
- string datarowdebug;
- int datarowdebugcount;
+
void showportal(int msgtype) {
if(objectp(portal))
638: Inside #if defined(PG_DEBUG)
datarowdebug=0; datarowdebugcount=0;
}
#endif
+ if(!sizeof(cr)) { // Preliminary check, fast path
+ Thread.MutexKey lock=cr->fillreadmux->lock();
+ if(!sizeof(cr)) { // Check for real
+ cr->procmsg=1;
+ lock=0;
+ return; // Terminate thread, wait for callback
+ }
+ lock=0;
+ }
int msgtype=cr->read_int8();
if(!portal) {
portal=qportals->try_read();