pike.git
/
lib
/
modules
/
Sql.pmod
/
pgsql_util.pmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:361:
if (mode == SYNCSEND) { add(PGSYNC); realbuffer->stashqueue->write(1); mode = SENDOUT; // Demote it to prevent an extra SYNC upon stashflush } realbuffer->stash->add(this); PD("%d>Stashed mode %d > %d\n", realbuffer->socket->query_fd(), mode, realbuffer->stashflushmode); if (mode > realbuffer->stashflushmode) realbuffer->stashflushmode = mode;
+
lock = 0;
dirty = 0; this->clear(); if (lock = realbuffer->nostash->trylock(1)) { #ifdef PG_DEBUGRACE conxsess sess = conxsess(realbuffer); realbuffer->started = lock; lock = 0; sess->sendcmd(SENDOUT); #else realbuffer->started = lock;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:516:
describe_backtrace(nostash->current_locking_thread()->backtrace())); #endif while (lock = (waitforreal ? nostash->lock : nostash->trylock)(1)) { int mode; stashcount->wait_till_drained(); #ifdef PG_DEBUGRACE conxsess sess = conxsess(this); #endif started = lock; lock = 0; // Force release before acquiring next
-
lock
= shortmux->lock
()
;
-
mode =
getstash(KEEP)
;
-
lock = 0;
-
if (mode
> KEEP)
+
if
(
sizeof(stash
)
&&
getstash(KEEP) > KEEP)
sendcmd(mode); // Force out stash to the server #ifdef PG_DEBUGRACE return sess; #else return this; #endif } return bufcon(this)->start(); }
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:542:
if (this) { // Guard against async destructs towrite -= output_to(socket, towrite); lock = 0; if (!i->fillread && !sizeof(this)) close(); } return 0; } private int getstash(int mode) {
-
if
(
sizeof(stash
)
) {
+
Thread.MutexKey
lock = shortmux->lock
()
;
add(stash); stash->clear(); foreach (stashqueue->try_read_array(); ; int|Result portal) if (intp(portal)) qportals->write(synctransact++); else queueup(portal); PD("%d>Got stash mode %d > %d\n", socket->query_fd(), stashflushmode, mode); if (stashflushmode > mode) mode = stashflushmode; stashflushmode = KEEP;
-
}
+
return mode; } final void sendcmd(void|int mode, void|Result portal) { if (portal) queueup(portal); unfinalised: do { switch (mode) { default:
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:579:
add(PGSYNC); mode = SENDOUT; break; case FLUSHLOGSEND: PD("%d>%O %d Queue simplequery %d bytes\n", socket->query_fd(), portal._portalname, ++queueoutidx, sizeof(this)); mode = FLUSHSEND; } qportals->write(synctransact++); } while (0);
-
Thread.MutexKey
lock = shortmux->lock
()
;
+
if
(
sizeof(stash
)
)
mode = getstash(mode);
-
+
for(;;) {
#ifdef PG_DEBUG mixed err = #endif catch { outer: do { switch (mode) { default: PD("%d>Skip flush %d Queue %O\n", socket->query_fd(), mode, (string)this);
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:604:
add(PGFLUSH); case SENDOUT:; } if (towrite = sizeof(this)) { PD("%d>Sendcmd %O\n", socket->query_fd(), ((string)this)[..towrite-1]); towrite -= output_to(socket, towrite); } } while (0); started = 0;
+
if (sizeof(stash) && (started = nostash->trylock(1))) {
+
#ifdef PG_DEBUGRACE
+
conxsess sess = conxsess(this);
+
sess->sendcmd(SENDOUT);
+
#else
+
mode = getstash(SENDOUT);
+
continue;
+
#endif
+
}
return; };
-
lock
= 0;
+
break;
+
}
+
started
= 0;
PD("Sendcmd failed %s\n", describe_backtrace(err)); destruct(this); } final int close() { if (!closenext && nostash) { closenext = 1; { Thread.MutexKey lock = i->fillreadmux->lock(); if (i->fillread) { // Delayed close() after flushing the output buffer