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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:796:    }       private void gotdatarowdesc(void|Stdio.Buffer plugbuffer) {    Thread.MutexKey lock=prepbuffermux->lock();    if(!plugbuffer) {    if(!prepbuffer)    catch(prepbufferready->wait(lock));    plugbuffer=prepbuffer;    prepbuffer=0; // Free memory when plugbuffer leaves scope    } -  if(!prepbufferready || _state==CLOSED) +  if(!prepbufferready || _state>=CLOSING)    lock=_unnamedstatementkey=0;    else {    destruct(prepbufferready); // Make sure we do this exactly once    lock=0;    plugbuffer->add_int16(sizeof(datarowdesc));    if(sizeof(datarowdesc))    foreach(datarowdesc;;mapping col)    plugbuffer->add_int16(oidformat(col.type));    else if(commitprefix->match(_query)) {    lock=pgsqlsess->_commitmux->lock();
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:841:    final void _openportal() {    pgsqlsess->_portalsinflight++;    Thread.MutexKey lock=closemux->lock();    _state=BOUND;    lock=0;    statuscmdcomplete=UNDEFINED;    }       final void _purgeportal() {    _unnamedportalkey=_unnamedstatementkey=0; +  datarows->write(1); // Signal EOF    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 int _closeportal(bufcon plugbuffer) {    int 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; +  _state=CLOSING;    break;    case COPYINPROGRESS:    PD("CopyDone\n");    plugbuffer->add("c\0\0\0\4");    case BOUND: -  _state=CLOSED; +  _state=CLOSING;    lock=0;    PD("Close portal %O\n",_portalname);    if(sizeof(_portalname)) {    plugbuffer->add_int8('C')->add_hstring(({'P',_portalname,0}),4,4);    retval=FLUSHSEND;    } else    _unnamedportalkey=0;    Thread.MutexKey lockc=pgsqlsess->_commitmux->lock();    if(!--pgsqlsess->_portalsinflight) {    if(pgsqlsess->_waittocommit) {
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:900:    }    lockc=0;    }    lock=0;    return retval;    }       final void _processdataready(array datarow,void|int msglen) {    bytesreceived+=msglen;    inflight--; +  if(_state<CLOSED)    datarows->write(datarow);    if(++rowsreceived==1)    PD("<%O _fetchlimit %d=min(%d||1,%d), inflight %d\n",_portalname,    _fetchlimit,(portalbuffersize>>1)*rowsreceived/bytesreceived,    pgsqlsess._fetchlimit,inflight);    if(_fetchlimit) {    _fetchlimit=    min((portalbuffersize>>1)*rowsreceived/bytesreceived||1,    pgsqlsess._fetchlimit);    Thread.MutexKey lock=closemux->lock();
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:938:    datarowdesc=({});    _ddescribe->broadcast();    }    lock=0;    }       final void _releasesession(void|string statusccomplete) {    if(statusccomplete && !statuscmdcomplete)    statuscmdcomplete=statusccomplete;    inflight=0; -  datarows->write(1); // Signal EOF +     conxion plugbuffer=c->start(1);    plugbuffer->sendcmd(_closeportal(plugbuffer)); -  +  _state=CLOSED; +  datarows->write(1); // Signal EOF    releaseconditions();    }       protected void destroy() {    catch { // inside destructors, exceptions don't work    _releasesession();    };    }       final void _sendexecute(int fetchlimit,void|bufcon plugbuffer) {