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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:221:    fillread=Thread.Condition();    }   };      class conxion {    inherit Stdio.Buffer:o;    final conxiin i;       private Thread.Queue qportals;    final Thread.Mutex shortmux; -  private Thread.Mutex termthread; -  private Thread.MutexKey termlock; +  private int closenext;       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;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:332:    }    } while(0);    lock=started=0;    return;    };    lock=0;    catch(connectfail());    }       final int close() { -  int ret; -  if(!termlock && nostash) -  { termlock=termthread->lock(); -  Thread.MutexKey lock=i->fillreadmux->lock(); +  int ret=0; +  if(!closenext && nostash) +  { Thread.MutexKey lock=i->fillreadmux->lock();    if(i->fillread) { // Delayed close() after flushing the output buffer    i->fillread.signal();    i->fillread=0;    }    lock=0;    PD("%d>Delayed close, flush write\n",socket->query_fd());    i->read_cb(socket->query_id(),0); -  return ret; -  } +  closenext=1; +  } else {    destruct(nostash);    PD("%d>Close socket\n",socket->query_fd());    ret=socket->close();    foreach(closecallbacks;function(void|mixed:void) closecb;)    closecb();    closecallbacks=(<>); -  termlock=0; +  }    return ret;    }       protected void destroy() {    catch(close()); // Exceptions don't work inside destructors    connectfail=0; -  termthread->lock(1); +     }       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)) {    PD("SSLRequest\n");
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:433:    }       protected void create(object pgsqlsess,Thread.Queue _qportals,int nossl) {    o::create();    qportals = _qportals;    synctransact = 1;    socket=Stdio.File();    i=conxiin();    shortmux=Thread.Mutex();    nostash=Thread.Mutex(); -  termthread=Thread.Mutex(); +  closenext = 0;    stashavail=Thread.Condition();    stashqueue=Thread.Queue();    stash=Stdio.Buffer();    Thread.Thread(connectloop,pgsqlsess,nossl);    }   };      //! The result object returned by @[Sql.pgsql()->big_query()], except for   //! the noted differences it behaves the same as @[Sql.sql_result].   //!