pike.git/
lib/
modules/
Sql.pmod/
pgsql_util.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2017-11-28
2017-11-28 12:39:22 by Stephen R. van den Berg <srb@cuci.nl>
81790ff734eeef458da12ba2cdb074166ac5400d (
120
lines) (+
58
/-
62
)
[
Show
|
Annotate
]
Branch:
master
pgsql: Rely on block boundaries to release locks.
265:
if (!didreadcb) fillread.wait(lock); didreadcb = 0;
-
lock = 0;
+
} else throw(MAGICTERMINATE); return true;
282:
procmsg = 0, lock = 0, Thread.Thread(id); else if (fillread) didreadcb = 1, fillread.signal();
-
lock = 0;
+
return 0; }
439:
towrite -= output_to(socket, towrite); } } while (0);
-
lock =
started = 0;
+
started = 0;
return; }; lock = 0;
450:
final int close() { if (!closenext && nostash) { closenext = 1;
+
{
Thread.MutexKey lock = i->fillreadmux->lock();
-
if (i->fillread) {
// Delayed close() after flushing the output buffer
+
if (i->fillread) { // Delayed close() after flushing the output buffer
i->fillread.signal(); i->fillread = 0; }
-
lock = 0;
+
}
PD("%d>Delayed close, flush write\n", socket->query_fd()); i->read_cb(socket->query_id(), 0); return 0;
684:
int _portalbuffersize, int alltyped, array params, int forcetext, int _timeout, int _syncparse, int _transtype) { pgsqlsess = _pgsqlsess;
-
if (
catch(cr
=
(
c =
_
c
)
->i
))
+
if (
c
=
_
c
)
+
cr
= c->i
;
+
else
losterror(); _query = query; datarows = Thread.Queue();
731:
} private void waitfordescribe() {
+
{
Thread.MutexKey lock = _ddescribemux->lock(); if (!datarowtypes) PT(_ddescribe->wait(lock));
-
lock = 0;
+
}
if (this) // If object already destructed, skip the next call trydelayederror(); // since you cannot call functions anymore else
883:
datarowdesc = drowdesc; datarowtypes = drowtypes; _ddescribe->broadcast();
-
lock = 0;
+
} final void _preparebind(array dtoid) {
1069:
execfetchlimit->match(_query)) && _fetchlimit, bindbuffer); }
-
} else
-
lock = 0;
+
}
-
+
}
final void _processrowdesc(array(mapping(string:mixed)) datarowdesc, array(int) datarowtypes) {
1083:
} final void _parseportal() {
+
{
Thread.MutexKey lock = closemux->lock(); _state = PARSING;
-
+
{
Thread.MutexKey lockc = pgsqlsess->shortmux->lock(); if (syncparse || syncparse < 0 && pgsqlsess->wasparallelisable) { PD("Commit waiting for statements to finish\n"); catch(PT(pgsqlsess->statementsinflight->wait_till_drained(lockc))); } stmtifkey = pgsqlsess->statementsinflight->acquire();
-
lockc
=
0;
-
lock = 0;
+
}
+
}
statuscmdcomplete = 0; pgsqlsess->wasparallelisable = paralleliseprefix->match(_query); }
1105:
_state = COMMITTED; stmtifkey = 0; }
-
lock = 0;
+
} final void _bindportal() { Thread.MutexKey lock = closemux->lock(); _state = BOUND; portalsifkey = pgsqlsess->portalsinflight->acquire();
-
lock = 0;
+
} final void _purgeportal() { PD("Purge portal\n"); datarows->write(1); // Signal EOF
-
+
{
Thread.MutexKey lock = closemux->lock(); _fetchlimit = 0; // disables further Executes switch (_state) {
1132:
stmtifkey = 0; } _state = PURGED;
-
lock = 0;
+
}
releaseconditions(); }
1179:
pgsqlsess->pportalcount = 0; } }
-
lock = 0;
+
return retval; }
1202:
else if (!_fetchlimit) PD("<%O _fetchlimit %d, inflight %d, skip execute\n", _portalname, _fetchlimit, inflight);
-
lock = 0;
+
} }
1438:
switch (type) { case 'O': res = sprintf(DRIVERNAME".proxy(%s@%s:%d/%s,%d,%d)",
-
user, host, port, database, c
?
->socket && c->socket->query_fd(),
+
user, host, port, database, c
&& c
->socket && c->socket->query_fd(),
backendpid); break; }
1482:
} final int is_open() {
-
catch
{
-
return
c->socket->is_open();
-
};
-
return 0;
+
return
c
&&
c->socket
&&
c->socket->is_open();
} final string geterror(void|int clear) {
1653:
throw(MAGICTERMINATE); // Force proper termination } cr->procmsg = 1;
-
lock = 0;
+
return; // Terminate thread, wait for callback }
-
lock = 0;
+
} int msgtype = cr->read_int8(); if (!portal) {
2291:
final void close() { throwdelayederror(this);
+
{
Thread.MutexKey lock; if (qportals && qportals->size()) catch(cancelquery());
2302:
lock = unnamedstatement->lock(1); if (c) c->purge();
-
lock = 0;
+
}
destruct(waitforauthready); }