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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:736:       final void _openportal() {    pgsqlsess->_portalsinflight++;    Thread.MutexKey lock=closemux->lock();    _state=bound;    lock=0;    _statuscmdcomplete=UNDEFINED;    }       final void _purgeportal() { -  _unnamedportalkey=0; +  _unnamedportalkey=_unnamedstatementkey=0;    Thread.MutexKey lock=closemux->lock();    _fetchlimit=0; // disables further Executes    switch(_state) {    case copyinprogress:    case bound:    _datarows->write(1); // Signal EOF    --pgsqlsess->_portalsinflight;    }    _state=closed;    lock=0; -  +  releaseconditions();    }       final sctype _closeportal(PGplugbuffer plugbuffer) {    sctype retval=keep;    PD("%O Try Closeportal %d\n",_portalname,_state);    Thread.MutexKey lock=closemux->lock();    _fetchlimit=0; // disables further Executes    int alreadyfilled=sizeof(plugbuffer);    /* alreadyfilled will be non-zero if a parse request has been queued    * before the close was initiated.    * It's a bit of a tricky race, but this check should be sufficient.    */    switch(_state) {    case portalinit: -  +  _unnamedstatementkey=0;    _state=closed;    break;    case copyinprogress:    PD("CopyDone\n");    plugbuffer->add("c\0\0\0\4");    case bound:    _state=closed;    lock=0;    PD("Close portal %O\n",_portalname);    if(sizeof(_portalname)) {
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:811:    Thread.MutexKey lock=closemux->lock();    if(_fetchlimit && _inflight<=_fetchlimit-1)    _sendexecute(_fetchlimit);    else if(!_fetchlimit)    PD("<%O _fetchlimit %d, _inflight %d, skip execute\n",    _portalname,_fetchlimit,_inflight);    lock=0;    }    }    -  final void _releasesession() { -  _inflight=0; -  _datarows->write(1); // Signal EOF -  PGassist plugbuffer=c->start(1); -  plugbuffer->sendcmd(_closeportal(plugbuffer)); -  pgsqlsess=UNDEFINED; +  private void releaseconditions() { +  pgsqlsess=0;    Thread.MutexKey lock;    if(prepbuffermux) {    Thread.MutexKey lock=prepbuffermux->lock();    prepbufferready->signal();    }    if(!_datarowdesc) {    lock=_ddescribemux->lock();    _ddescribe->broadcast(); -  +  _datarowdesc=({});    }    lock=0;    }    -  +  final void _releasesession() { +  _inflight=0; +  _datarows->write(1); // Signal EOF +  PGassist plugbuffer=c->start(1); +  plugbuffer->sendcmd(_closeportal(plugbuffer)); +  releaseconditions(); +  } +     protected void destroy() {    catch { // inside destructors, exceptions don't work    _releasesession();    };    }       final void _sendexecute(int fetchlimit,void|PGplugbuffer plugbuffer) {    int flushmode;    PD("Execute portal %O fetchlimit %d\n",_portalname,fetchlimit);    if(!plugbuffer)