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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:224:      class conxion {    inherit Stdio.Buffer:o;    final conxiin i;       private Thread.Queue qportals;    final Thread.Mutex shortmux;    final Stdio.File socket;    private function(void|mixed:void) connectfail;    private int towrite; +  final multiset(function(void|mixed:void)) closecallbacks=(<>);       final Thread.Mutex nostash;    final Thread.MutexKey started;    final Thread.Queue stashqueue;    final Thread.Condition stashavail;    final Stdio.Buffer stash;    final int stashflushmode;    final int stashcount;    final int synctransact;   #ifdef PG_DEBUG
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:340:    i->fillread.signal(), i->fillread=0;    lock=0;    }       final int close() {    int ret;    destruct(nostash);    PD("%d>Close socket\n",socket->query_fd());    ret=socket->close();    sendterminate(); +  foreach(closecallbacks;function(void|mixed:void) closecb;) +  closecb(); +  closecallbacks=(<>);    return ret;    }       protected void destroy() { -  catch(close()); // Exceptions don't work inside destructors -  socket->set_nonblocking(); // Clear all callbacks +  catch { // Exceptions don't work inside destructors +  close(); +  socket->set_callbacks(); // Clear all callbacks +  };    connectfail=0;    }       final void connectloop(object pgsqlsess, int nossl) {    mixed err=catch {    for(;;clear()) {    socket->connect(pgsqlsess._host,pgsqlsess._port);   #if constant(SSL.File)    if(!nossl && !pgsqlsess->nossl    && (pgsqlsess._options.use_ssl || pgsqlsess._options.force_ssl)) {
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:491:    protected void create(object _pgsqlsess,conxion _c,string query,    int _portalbuffersize,int alltyped,array params,int forcetext,    int _timeout) {    pgsqlsess = _pgsqlsess;    cr = (c = _c)->i;    _query = query;    datarows = Thread.Queue();    _ddescribe=Thread.Condition();    _ddescribemux=Thread.Mutex();    closemux=Thread.Mutex(); +  c->closecallbacks+=(<destroy>);    portalbuffersize=_portalbuffersize;    alltext = !alltyped;    _params = params;    _forcetext = forcetext;    _state = PORTALINIT;    timeout = _timeout;    gottimeout = _pgsqlsess->cancelquery;    }       //! Returns the command-complete status for this query.
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:829:    lock=_unnamedstatementkey=0;    else {    plugbuffer->add_int16(sizeof(datarowtypes));    if(sizeof(datarowtypes))    plugbuffer->add_ints(map(datarowtypes,oidformat),2);    else if(!paralleliseprefix->match(_query)) {    lock=pgsqlsess->_shortmux->lock();    if(pgsqlsess->_portalsinflight) {    pgsqlsess->_waittocommit++;    PD("Commit waiting for portals to finish\n"); -  PT(pgsqlsess->_readyforcommit->wait(lock)); +  catch(PT(pgsqlsess->_readyforcommit->wait(lock)));    pgsqlsess->_waittocommit--;    }    }    lock=0;    PD("Bind portal %O statement %O\n",_portalname,_preparedname);    _fetchlimit=pgsqlsess->_fetchlimit;    _openportal();    conxion bindbuffer=c->start(1);    _unnamedstatementkey=0;    bindbuffer->add_int8('B')->add_hstring(plugbuffer,4,4);
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:914:    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->_shortmux->lock();    if(!--pgsqlsess->_portalsinflight) {    if(pgsqlsess->_waittocommit) {    PD("Signal no portals in flight\n"); -  pgsqlsess->_readyforcommit->signal(); +  catch(pgsqlsess->_readyforcommit->signal());    lockc=0;    } else if(!alreadyfilled)    pgsqlsess->_readyforquerycount++, retval=SYNCSEND;    pgsqlsess->_pportalcount=0;    }    lockc=0;    }    lock=0;    return retval;    }
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:962:    if(!datarowtypes) {    Thread.MutexKey lock=_ddescribemux->lock();    datarowtypes=emptyarray;    datarowdesc=emptyarray;    _ddescribe->broadcast();    lock=0;    }    }       final void _releasesession(void|string statusccomplete) { +  c->closecallbacks-=(<destroy>);    if(statusccomplete && !statuscmdcomplete)    statuscmdcomplete=statusccomplete;    inflight=0; -  +  catch {    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();    };    }