pike.git/lib/modules/Sql.pmod/pgsql.pike:590:
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) {
+ if(c && (!ci || c!=ci)) // If we are switching or dropping connections
+ c->close(); // force a close on the old socket
+ if(!this) // Oops, current object already destructed
+ return;
(c=ci)->socket->set_id(procmessage);
cancelsecret=0;
portal=0;
{
Stdio.Buffer plugbuffer=Stdio.Buffer()->add_int32(PG_PROTOCOL(3,0));
if(user)
plugbuffer->add("user\0",user,0);
if(database)
plugbuffer->add("database\0",database,0);
_options.reconnect=undefinedp(_options.reconnect) || _options.reconnect;
pike.git/lib/modules/Sql.pmod/pgsql.pike:644: Inside #if defined(PG_DEBUG)
err=catch {
#ifdef PG_DEBUG
if(!portal && datarowdebug) {
PD("%s rows %d\n",datarowdebug,datarowdebugcount);
datarowdebug=0; datarowdebugcount=0;
}
#endif
if(!sizeof(cr)) { // Preliminary check, fast path
Thread.MutexKey lock=cr->fillreadmux->lock();
if(!sizeof(cr)) { // Check for real
+ if(!cr->fillread) {
+ lock=0;
+ throw(MAGICTERMINATE); // Force proper termination
+ }
cr->procmsg=1;
lock=0;
return; // Terminate thread, wait for callback
}
lock=0;
}
int msgtype=cr->read_int8();
if(!portal) {
portal=qportals->try_read();
#ifdef PG_DEBUG
pike.git/lib/modules/Sql.pmod/pgsql.pike:1189:
throw(err);
}
//! Closes the connection to the database, any running queries are
//! terminated instantly.
//!
//! @note
//! This function is PostgreSQL-specific, and thus it is not available
//! through the generic SQL-interface.
/*semi*/final void close() {
+ if(qportals && qportals->size())
catch(cancelquery());
- catch(c->sendterminate());
+ catch(c->close());
c=0;
destruct(waitforauthready);
}
protected void destroy() {
catch(close());
.pgsql_util.unregister_backend();
}
final void _connectfail(void|mixed err) {
pike.git/lib/modules/Sql.pmod/pgsql.pike:1246:
}
waitforauthready=Thread.Condition();
lock=0;
}
if(c) {
PD("Close old connection\n");
reconnected++;recon=1;
#ifdef PG_STATS
prepstmtused=0;
#endif
- c->sendterminate();
+ c->close();
c=0;
PD("Flushing old cache\n");
foreach(_prepareds;;mapping tp)
m_delete(tp,"preparedname");
if(!_options.reconnect)
ERROR("Lost connection to database %s:%d\n",_host,_port);
}
PD("Actually start to connect\n");
qportals=Thread.Queue();
_readyforcommit=Thread.Condition();