Branch: Tag:

2020-02-25

2020-02-25 00:59:55 by Stephen R. van den Berg <srb@cuci.nl>

Revert "pgsql: Eliminate output_to() usage."

Reverted because the new write(Stdio.Buffer) does not work correctly.

This reverts commit c3de6fbb7d0fc577e49bfcefbf00d33c0ba875b0.

473:    |SSL.File   #endif    socket; +  private int towrite;    final multiset(Result) runningportals = (<>);       final MUTEX nostash;
493:    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;
545:    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();
613:    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;