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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:468:       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); -  int ret = o::output_to(stm, nbytes); + #endif +  consume(socket->write(this)); + #if PG_DEBUGHISTORY > 0 +  int ret = sizeof(tb) - sizeof(this);    if (ret) {    i->history += ({">>" + tb->read(ret)});    i->history = i->history[<PG_DEBUGHISTORY - 1 ..];    } -  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:539:   #else    return this;   #endif    }    return !waitforreal && bufcon(this)->start();    }       private int write_cb() {    Thread.MutexKey lock = shortmux->lock();    if (this) { // Guard against async destructs -  towrite -= output_to(socket, towrite); +  flushtosocket();    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:607:    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 && (towrite = sizeof(this))) { +  if (lock && sizeof(this)) {    PD("%d>Sendcmd %O\n", -  socket->query_fd(), ((string)this)[..towrite-1]); -  towrite -= output_to(socket, towrite); +  socket->query_fd(), (string)this); +  flushtosocket();    }    } 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;