pike.git / lib / modules / Sql.pmod / pgsql.pike

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:309:   //! @[reload()], @[resync()]   //!   //! @note   //! This function is PostgreSQL-specific, and thus it is not available   //! through the generic SQL-interface.   /*semi*/final void cancelquery() {    PD("CancelRequest\n");    .pgsql_util.conxion lcon=getsocket(1);    lcon->add_int32(16)->add_int32(PG_PROTOCOL(1234,5678))    ->add_int32(backendpid)->add(cancelsecret)->sendcmd(FLUSHSEND); -  lcon->close(); +  lcon=0;   #ifdef PG_DEBUGMORE    PD("Closetrace %O\n",backtrace());   #endif    if(c) {    .pgsql_util.conxion plugbuffer;    if(!catch(plugbuffer=c->start(1))) {    foreach(qportals->peek_array();;int|.pgsql_util.sql_result portal)    if(objectp(portal))    portal->_closeportal(plugbuffer);    plugbuffer->sendcmd(SENDOUT);
pike.git/lib/modules/Sql.pmod/pgsql.pike:591:    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 +     (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:1178:    }    PD("Closing database processloop %O\n",err);    _delayederror=err;    for(;objectp(portal);portal=qportals->read())    if(objectp(portal)) {   #ifdef PG_DEBUG    showportal(0);   #endif    portal->_purgeportal();    } -  if(!ci->close() && !terminating && _options.reconnect) +  c=ci=0; +  if(!terminating && _options.reconnect)    _connectfail();    else    destruct(waitforauthready);    termlock=0;    if(err && !stringp(err))    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()); -  +  termlock=(termthread=Thread.Mutex())->lock();    c->close(); -  +  termthread->lock(1);    c=0;    destruct(waitforauthready);   }      protected void destroy() { -  termlock=(termthread=Thread.Mutex())->lock(); +     catch(close());    .pgsql_util.unregister_backend(); -  termthread->lock(1); +    }      final void _connectfail(void|mixed err) {    PD("Connect failed %O reconnectdelay %d\n",err,reconnectdelay);    destruct(waitforauthready);    if(!err || reconnectdelay) {    int tdelay;    switch(tdelay=reconnectdelay) {    case 0:    reconnectdelay=RECONNECTDELAY;
pike.git/lib/modules/Sql.pmod/pgsql.pike:1254:    }    waitforauthready=Thread.Condition();    lock=0;    }    if(c) {    PD("Close old connection\n");    reconnected++;recon=1;   #ifdef PG_STATS    prepstmtused=0;   #endif +  termlock=(termthread=Thread.Mutex())->lock();    c->close(); -  +  termthread->lock(1);    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();