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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:96:   private int warningsdropcount; // Number of uncollected warnings   private int warningscollected;   private int invalidatecache;   private Thread.Queue qportals;   final mixed _delayederror;   private function (:void) readyforquery_cb;      final string _host;   final int _port;   private string database, user, pass; - private Thread.Mutex waitforauth; +    private Thread.Condition waitforauthready; - final Thread.Mutex _commitmux; + final Thread.Mutex _shortmux;   final Thread.Condition _readyforcommit;   final int _waittocommit, _readyforquerycount;      private string _sprintf(int type, void|mapping flags) {    string res=UNDEFINED;    switch(type) {    case 'O':    res=sprintf(DRIVERNAME"(%s@%s:%d/%s,%d,%d)",    user,_host,_port,database,c?->socket?->query_fd(),backendpid);    break;
pike.git/lib/modules/Sql.pmod/pgsql.pike:213:    _options = options || ([]);       if(!host) host = PGSQL_DEFAULT_HOST;    if(has_value(host,":") && sscanf(host,"%s:%d",host,_port)!=2)    ERROR("Error in parsing the hostname argument\n");    this::_host = host;       if(!_port)    _port = PGSQL_DEFAULT_PORT;    .pgsql_util.register_backend(); -  waitforauth=Thread.Mutex(); +  _shortmux=Thread.Mutex();    reconnect();   }      //! @returns   //! The textual description of the last   //! server-related error. Returns @expr{0@} if no error has occurred   //! yet. It is not cleared upon reading (can be invoked multiple   //! times, will return the same result until a new error occurs).   //!   //! During the execution of a statement, this function accumulates all
pike.git/lib/modules/Sql.pmod/pgsql.pike:297:   //! @endint   //!   //! @seealso   //! @[is_open()]   int ping() {    return is_open() && !catch(c->start()->sendcmd(FLUSHSEND))    ? !!reconnected : -1;   }      private .pgsql_util.conxion getsocket(void|int nossl) { -  return .pgsql_util.conxion(this,qportals,(int)nossl); +  return .pgsql_util.conxion(this,qportals,(int)nossl,_shortmux);   }      //! Cancels all currently running queries in this session.   //!   //! @seealso   //! @[reload()], @[resync()]   //!   //! @note   //! This function is PostgreSQL-specific, and thus it is not available   //! through the generic SQL-interface.
pike.git/lib/modules/Sql.pmod/pgsql.pike:576:    lastmessage=({    sprintf("%s %s:%s %s\n (%s:%s:%s)",    msgresponse.S,msgresponse.C,msgresponse.P||"",    msgresponse.M,msgresponse.F||"",msgresponse.R||"",    msgresponse.L||"")});   }      private void waitauthready() {    if(waitforauthready) {    PD("%d Wait for auth ready %O\n",c?->socket?->query_fd(),backtrace()[-2]); -  Thread.MutexKey lock=waitforauth->lock(); +  Thread.MutexKey lock=_shortmux->lock();    catch(waitforauthready->wait(lock));    lock=0;    PD("%d Wait for auth ready released.\n",c?->socket?->query_fd());    }   }      private inline mixed callout(function(mixed ...:void) f,    float|int delay,mixed ... args) {    return .pgsql_util.local_backend->call_out(f,delay,@args);   }
pike.git/lib/modules/Sql.pmod/pgsql.pike:1204:    reconnectdelay=RECONNECTDELAY;    break;    default:    if(err)    _delayederror=err;    if(_options.reconnect!=-1)    return;    reconnectdelay=RECONNECTBACKOFF;    break;    } -  Thread.MutexKey lock=waitforauth->lock(); +  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(void|int force) {    PD("(Re)connect\n");    if(!force) { -  Thread.MutexKey lock=waitforauth->lock(); +  Thread.MutexKey lock=_shortmux->lock();    if(waitforauthready) {    lock=0;    return 0; // Connect still in progress in other thread    }    waitforauthready=Thread.Condition();    lock=0;    }    if(c) {    PD("Close old connection\n");    reconnected++;
pike.git/lib/modules/Sql.pmod/pgsql.pike:1245:    c->close();    c=0;    PD("Flushing old cache\n");    foreach(_prepareds;;mapping tp)    m_delete(tp,"preparedname");    if(!_options.reconnect)    return 0;    }    PD("Actually start to connect\n");    qportals=Thread.Queue(); -  _commitmux=Thread.Mutex(); +     _readyforcommit=Thread.Condition();    _readyforquerycount=1;    _waittocommit=0;    qportals->write(1);    if(!(c=getsocket())) {    string msg=sprintf("Couldn't connect to database on %s:%d",_host,_port);    if(force) {    if(!sizeof(lastmessage) || lastmessage[sizeof(lastmessage)-1]!=msg)    lastmessage+=({msg});    return 0;