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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:1172:    if(objectp(portal))    portal->_releasesession();    portal=0;    if(!waitforauthready)    continue; // Only continue if authentication did not fail    }    break;    }    PD("Closing database processloop %O\n",err);    _delayederror=err; -  for(; objectp(portal); portal = qportals->read()) -  if(objectp(portal)) { +  if (objectp(portal)) {   #ifdef PG_DEBUG    showportal(0);   #endif    portal->_purgeportal();    }    if(!terminating && _options.reconnect)    _connectfail();    else    destruct(waitforauthready);    termlock=0;
pike.git/lib/modules/Sql.pmod/pgsql.pike:1221:    destruct(waitforauthready);   }      protected void destroy() {    catch(close());    .pgsql_util.unregister_backend();   }      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;    break;    default:    if(err)    _delayederror=err; -  if(_options.reconnect!=-1) +  if (_options.reconnect!=-1) { +  destruct(waitforauthready); +  destruct(c);    return; -  +  }    reconnectdelay=RECONNECTBACKOFF;    break;    }    Thread.MutexKey lock=_shortmux->lock();    if(!waitforauthready)    waitforauthready=Thread.Condition();    lock=0;    PD("Schedule reconnect in %ds\n",tdelay);    _delayederror=0;    callout(reconnect,tdelay,1);    } else if(err)    _delayederror=err;   }      private int reconnect() {    int recon=0;    PD("(Re)connect\n");    {    Thread.MutexKey lock=_shortmux->lock(); -  if(waitforauthready) { -  lock=0; -  return 1; // Connect still in progress in other thread -  } +  if (!waitforauthready)    waitforauthready=Thread.Condition();    lock=0;    }    if(c) {    PD("Close old connection\n");    reconnected++;recon=1;   #ifdef PG_STATS    prepstmtused=0;   #endif    termlock=unnamedstatement->lock(1); -  c->close(); -  Thread.MutexKey lock = unnamedstatement->lock(1); +  catch(c->close()); +  unnamedstatement = 0; +  termlock = 0;    destruct(c); -  lock = 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();    _readyforquerycount=1;