pike.git/
lib/
modules/
Sql.pmod/
pgsql_util.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2017-12-02
2017-12-02 00:28:30 by Stephen R. van den Berg <srb@cuci.nl>
569a925c071c1c228c665f421b9b2e021f10a0d5 (
28
lines) (+
22
/-
6
)
[
Show
|
Annotate
]
Branch:
8.0
pgsql: Migrate user callbacks to the DefaultBackend as soon as it has started.
35:
#define LOSTERROR "Database connection lost" //! The instance of the pgsql dedicated backend.
-
final Pike.Backend local_backend
= Pike.SmallBackend()
;
+
final Pike.Backend local_backend;
-
+
private Pike.Backend cb_backend;
private Thread.Mutex backendmux = Thread.Mutex(); private Thread.ResourceCount clientsregistered = Thread.ResourceCount();
96:
private Regexp execfetchlimit = iregexp("^\a*((UPDA|DELE)TE|INSERT)\a|\aLIMIT\a+[1-9][; \t\f\r\n]*$");
+
private void default_backend_runs() { // Runs as soon as the
+
cb_backend = Pike.DefaultBackend; // DefaultBackend has started
+
}
+
+
private void create() {
+
// Run callbacks from our local_backend until DefaultBackend has started
+
cb_backend = local_backend = Pike.SmallBackend();
+
call_out(default_backend_runs, 0);
+
}
+
private Regexp iregexp(string expr) { Stdio.Buffer ret = Stdio.Buffer(); foreach (expr; ; int c)
181:
private inline mixed callout(function(mixed ...:void) f, float|int delay, mixed ... args) {
-
return
local
_backend->call_out(f, delay, @args);
+
return
cb
_backend->call_out(f, delay, @args);
} // Some pgsql utility functions
1259:
plugbuffer->sendcmd(flushmode, this); }
+
inline private array setuptimeout() {
+
return local_backend->call_out(gottimeout, timeout);
+
}
+
//! @returns //! One result row at a time. //!
1274:
if (!eoffound) { if (!datarow) { PD("%O Block for datarow\n", _portalname);
-
array cid =
callout
(
gottimeout, timeout
);
+
array cid =
setuptimeout
();
PT(datarow = datarows->read()); local_backend->remove_call_out(cid); if (arrayp(datarow))
1300:
return 0; array(array|int) datarow = datarows->try_read_array(); if (!sizeof(datarow)) {
-
array cid =
callout
(
gottimeout, timeout
);
+
array cid =
setuptimeout
();
PT(datarow = datarows->read_array()); local_backend->remove_call_out(cid); }
1340:
array(mixed) args) { int|array datarow; for (;;) {
-
array cid =
callout
(
gottimeout, timeout
);
+
array cid =
setuptimeout
();
PT(datarow = datarows->read()); local_backend->remove_call_out(cid); if (!arrayp(datarow))
1369:
array(mixed) args) { array(array|int) datarow; for (;;) {
-
array cid =
callout
(
gottimeout, timeout
);
+
array cid =
setuptimeout
();
PT(datarow = datarows->read_array()); local_backend->remove_call_out(cid); if (!datarow || !arrayp(datarow[-1]))