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:149:
} } } class conxion { inherit Stdio.Buffer:i; inherit Stdio.Buffer:o; private Thread.Condition fillread;
+
private Thread.Mutex fillreadmux;
private Thread.Queue qportals; final Thread.Mutex shortmux; final Stdio.File socket; private object pgsqlsess; private int towrite; final function(:void) gottimeout; final int timeout; final Thread.Mutex nostash; final Thread.MutexKey started;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:202:
protected bool range_error(int howmuch) { if(!howmuch) return false; #ifdef PG_DEBUG if(howmuch<0) error("Out of range %d\n",howmuch); #endif if(fillread) { array cid=callout(gottimeout,timeout);
-
Thread.MutexKey lock=
shortmux
->lock();
+
Thread.MutexKey lock=
fillreadmux
->lock();
fillread.wait(lock); lock=0; local_backend->remove_call_out(cid); } else throw(MAGICTERMINATE); return true; } private int read_cb(mixed id,mixed b) {
-
Thread.MutexKey lock=
shortmux
->lock();
+
Thread.MutexKey lock=
fillreadmux
->lock();
if(fillread) fillread.signal(); lock=0; return 0; } private int write_cb() { Thread.MutexKey lock=shortmux->lock(); towrite-=output_to(socket,towrite); lock=0;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:261:
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;
if(started) {
-
Thread.MutexKey
lock=shortmux->lock();
+
lock=shortmux->lock();
if(sizeof(stash)) { add(stash); stash->clear(); foreach(stashqueue->try_read_array();;sql_result portal) queueup(portal); } mode=mergemode(this,mode); stashflushmode=KEEP;
-
lock=0;
+
} catch { outer: do { switch(mode) { default: break outer; case FLUSHSEND: PD("Flush\n"); add(PGFLUSH); case SENDOUT:; }
-
Thread.MutexKey
lock=shortmux->lock();
+
if(!lock)
+
lock=shortmux->lock();
if(towrite=sizeof(this)) { PD("%d>Sendcmd %O\n",socket->query_fd(),((string)this)[..towrite-1]); towrite-=output_to(socket,towrite); }
-
lock=0;
+
} while(0);
-
started=0;
+
lock=
started=0;
return; };
-
+
lock=0;
if(pgsqlsess) pgsqlsess->_connectfail(); } final void sendterminate() { destruct(fillread); // Delayed close() after flushing the output buffer } final int close() { destruct(nostash);
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:380:
return res; } protected void create(object _pgsqlsess,Thread.Queue _qportals,int nossl) { i::create(); o::create(); qportals = _qportals; synctransact = 1; gottimeout=sendcmd; // Preset it with a NOP timeout=128; // Just a reasonable amount socket=Stdio.File();
-
stashqueue
=Thread.
Queue();
-
nostash=Thread.
Mutex();
+
fillreadmux
=Thread.Mutex();
shortmux=Thread.Mutex();
-
stashavail
=Thread.
Condition
();
+
nostash
=Thread.
Mutex
();
fillread=Thread.Condition();
-
+
stashavail=Thread.Condition();
+
stashqueue=Thread.Queue();
stash=Stdio.Buffer(); pgsqlsess=_pgsqlsess; Thread.Thread(connectloop,nossl); } } //! The result object returned by @[Sql.pgsql()->big_query()], except for //! the noted differences it behaves the same as @[Sql.sql_result]. //! //! @seealso