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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:101:    }   }      private void run_local_backend() {    Thread.MutexKey lock;    int looponce;    do {    looponce=0;    if(lock=backendmux->trylock()) {    PD("Starting local backend\n"); -  while (!clientsregistered->drained()) { // Autoterminate when not needed +  while (!clientsregistered->drained() // Autoterminate when not needed +  || sizeof(local_backend->call_out_info())) {    mixed err;    if (err = catch(local_backend(4096.0)))    werror(describe_backtrace(err));    }    PD("Terminating local backend\n");    lock=0;    looponce = !clientsregistered->drained();    }    } while(looponce);   }
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:625:    statuscmdcomplete||(_unnamedstatementkey?"*parsing*":""));    break;    }    return res;    }       protected void create(object _pgsqlsess,conxion _c,string query,    int _portalbuffersize,int alltyped,array params,int forcetext,    int _timeout, int _syncparse, int _transtype) {    pgsqlsess = _pgsqlsess; -  cr = (c = _c)->i; +  if (catch(cr = (c = _c)->i)) +  losterror();    _query = query;    datarows = Thread.Queue();    _ddescribe=Thread.Condition();    _ddescribemux=Thread.Mutex();    closemux=Thread.Mutex();    portalbuffersize=_portalbuffersize;    alltext = !alltyped;    _params = params;    _forcetext = forcetext;    _state = PORTALINIT;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:707:    //! can still increase between subsequent calls if the results from    //! the query are not complete yet. This function is only guaranteed to    //! return the correct count after EOF has been reached.    //! @seealso    //! @[Sql.sql_result()->num_rows()]    /*semi*/final int num_rows() {    trydelayederror();    return rowsreceived;    }    -  private inline void trydelayederror() { +  private void losterror() { +  string err; +  if (pgsqlsess) +  err = pgsqlsess->error(1); +  error("%s\n", err || "Database connection lost"); +  } +  +  private void trydelayederror() {    if(_delayederror)    throwdelayederror(this); -  +  else if (_state == PURGED) +  losterror();    }       //! @seealso    //! @[Sql.sql_result()->eof()]    /*semi*/final int eof() {    trydelayederror();    return eoffound;    }       //! @seealso
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1065:    case COPYINPROGRESS:    case COMMITTED:    case BOUND:    portalsifkey = 0;    }    switch(_state) {    case BOUND:    case PARSING:    stmtifkey = 0;    } -  _state=CLOSED; +  _state = PURGED;    lock=0;    releaseconditions();    }       final int _closeportal(conxsess cs) {    object plugbuffer = CHAIN(cs);    int retval=KEEP;    PD("%O Try Closeportal %d\n",_portalname,_state);    Thread.MutexKey lock=closemux->lock();    _fetchlimit=0; // disables further Executes
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1144:    _portalname,_fetchlimit,inflight);    lock=0;    }    }       private void releaseconditions() {    _unnamedportalkey=_unnamedstatementkey=0;    pgsqlsess=0;    if(!datarowtypes) {    Thread.MutexKey lock=_ddescribemux->lock(); -  datarowtypes=emptyarray; -  datarowdesc=emptyarray; +  datarowdesc = datarowtypes = emptyarray;    _ddescribe->broadcast();    lock=0;    }    }       final void _releasesession(void|string statusccomplete) {    c->closecallbacks-=(<_destruct>);    if(statusccomplete && !statuscmdcomplete)    statuscmdcomplete=statusccomplete;    inflight=0;    conxsess plugbuffer;    if (!catch(plugbuffer = c->start()))    plugbuffer->sendcmd(_closeportal(plugbuffer)); -  _state=CLOSED; +  if (_state < CLOSED) +  _state = CLOSED;    datarows->write(1); // Signal EOF    releaseconditions();    }       protected void _destruct() {    catch { // inside destructors, exceptions don't work    _releasesession();    };    }