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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:466:       private Thread.Queue qportals;    final MUTEX shortmux;    private int closenext;       final sfile   #if constant(SSL.File)    |SSL.File   #endif    socket; +  private int towrite;    final multiset(Result) runningportals = (<>);       final MUTEX nostash;    final Thread.MutexKey started;    final Thread.Queue stashqueue;    final Thread.Condition stashavail;    final Stdio.Buffer stash;    //! @ignore    final int(KEEP..SYNCSEND) stashflushmode;    //! @endignore    final Thread.ResourceCount stashcount;    final int synctransact;   #ifdef PG_DEBUGRACE    final mixed nostrack;   #endif   #ifdef PG_DEBUG    final int queueoutidx;    final int queueinidx = -1;   #endif    -  private inline void flushtosocket() { +    #if PG_DEBUGHISTORY > 0 -  +  final int(-1..) output_to(Stdio.Stream stm, void|int(0..) nbytes) {    Stdio.Buffer tb = Stdio.Buffer(this); - #endif -  consume(socket->write(this)); - #if PG_DEBUGHISTORY > 0 -  int ret = sizeof(tb) - sizeof(this); +  int ret = o::output_to(stm, nbytes);    if (ret) {    i->history += ({">>" + tb->read(ret)});    i->history = i->history[<PG_DEBUGHISTORY - 1 ..];    } - #endif +  return ret;    } -  + #endif       private inline void queueup(Result portal) {    qportals->write(portal); portal->_synctransact = synctransact;    PD("%d>%O %d %d Queue portal %d bytes\n", socket->query_fd(),    portal._portalname, ++queueoutidx, synctransact, sizeof(this));    }       final bufcon|conxsess start(void|int waitforreal) {    Thread.MutexKey lock;   #ifdef PG_DEBUGRACE
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:538:   #else    return this;   #endif    }    return !waitforreal && bufcon(this)->start();    }       private int write_cb() {    Thread.MutexKey lock = shortmux->lock();    if (this) { // Guard against async destructs -  flushtosocket(); +  towrite -= output_to(socket, towrite);    lock = 0;    if (!i->fillread && !sizeof(this))    close();    }    return 0;    }       private int getstash(int mode) {    Thread.MutexKey lock = shortmux->lock();    add(stash); stash->clear();
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:606:    default:    PD("%d>Skip flush %d Queue %O\n",    socket->query_fd(), mode, (string)this);    break outer;    case FLUSHSEND:    PD("Flush\n");    add(PGFLUSH);    case SENDOUT:;    }    Thread.MutexKey lock = shortmux->trylock(); -  if (lock && sizeof(this)) { +  if (lock && (towrite = sizeof(this))) {    PD("%d>Sendcmd %O\n", -  socket->query_fd(), (string)this); -  flushtosocket(); +  socket->query_fd(), ((string)this)[..towrite-1]); +  towrite -= output_to(socket, towrite);    }    } while (0);    started = 0;    if (sizeof(stash) && (started = nostash->trylock(2))) {   #ifdef PG_DEBUGRACE    conxsess sess = conxsess(this);    sess->sendcmd(SENDOUT);   #else    mode = getstash(SENDOUT);    continue;