pike.git/
lib/
modules/
Sql.pmod/
pgsql_util.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2021-03-27
2021-03-27 09:39:42 by Stephen R. van den Berg <srb@cuci.nl>
909e4a5a4d8cf8d95c096c9725e7fd6c7c3ac524 (
38
lines) (+
15
/-
23
)
[
Show
|
Annotate
]
Branch:
master
pgsql: Shufflerised.
82:
//! The instance of the pgsql dedicated backend. final Pike.Backend local_backend;
+
private Shuffler.Shuffler shuffler = Shuffler.Shuffler();
private Pike.Backend cb_backend; private Result qalreadyprinted; private Thread.Mutex backendmux = Thread.Mutex();
156:
protected void create() { atexit(_destruct); // Run callbacks from our local_backend until DefaultBackend has started
-
cb_backend = local_backend = Pike.Backend();
+
shuffler->set_backend(
cb_backend = local_backend = Pike.Backend()
)
;
call_out(default_backend_runs, 0); }
485:
|SSL.File #endif socket;
+
final Shuffler.Shuffle shuffle;
final multiset(Result) runningportals = (<>); final MUTEX nostash;
504:
final int queueinidx = -1; #endif
-
#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);
-
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(),
558:
return !waitforreal && bufcon(this)->start(); }
-
private
int
write
_cb() {
-
Thread.MutexKey lock = shortmux->lock();
+
private
void
done
_cb() {
if (this) { // Guard against async destructs
-
output_to(socket);
-
lock = 0;
-
if (!i->fillread
&& !sizeof(this
)
)
+
if (!i->fillread)
close(); }
-
return 0;
+
} private int getstash(int mode) {
628:
add(PGFLUSH); case SENDOUT:; }
-
Thread.MutexKey lock = shortmux->trylock();
-
if (
lock &&
sizeof(this)) {
+
if (sizeof(this)) {
PD("%d>Sendcmd %O\n", socket->query_fd(), (string)this);
-
output
_
to
(
socket
);
+
#if
PG_DEBUGHISTORY
>
0
+
i->history += ({">>" + (string)this});
+
i->history = i->history[<PG
_
DEBUGHISTORY - 1 ..];
+
#endif
+
shuffle->add_source
(
this
);
+
shuffle->start(1);
} } while (0); started = 0;
752:
error(strerror(socket->errno()) + ".\n"); socket->set_backend(local_backend); socket->set_buffer_mode(i, 0);
-
socket->set_nonblocking(i->read_cb,
write_cb
, close);
+
socket->set_nonblocking(i->read_cb,
0
, close);
+
(shuffle = shuffler->shuffle(socket))->set_done_callback(done_cb);
if (nossl != 2) Thread.Thread(pgsqlsess->processloop, this); return;