Skip to content
Snippets Groups Projects
Commit 8551f77a authored by Stephen R. van den Berg's avatar Stephen R. van den Berg
Browse files

pgsql: Drop termination lock even on exceptions.

Prevent cancelquery() from starting the statemachine.
This was responsible for the majority of the exceptions.
parent a1bb6df8
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,7 @@
#ifdef PG_DEBUG
#define PD(X ...) werror(X)
// PT() puts this in the backtrace
#define PT(X ...) (lambda(object _this){return (X);}(this))
#define PT(X ...) (lambda(object _this){(X);}(this))
#else
#undef PG_DEBUGMORE
#define PD(X ...) 0
......
......@@ -313,7 +313,7 @@ private .pgsql_util.conxion getsocket(void|int nossl) {
//! through the generic SQL-interface.
/*semi*/final void cancelquery() {
PD("CancelRequest\n");
.pgsql_util.conxion lcon=getsocket(1);
.pgsql_util.conxion lcon=getsocket(2);
lcon->add_int32(16)->add_int32(PG_PROTOCOL(1234,5678))
->add_int32(backendpid)->add(cancelsecret)->sendcmd(FLUSHSEND);
lcon=0;
......@@ -617,6 +617,7 @@ final void _processloop(.pgsql_util.conxion ci) {
_connectfail();
else
destruct(waitforauthready);
unnamedstatement=0;
termlock=0;
return;
}
......@@ -625,10 +626,11 @@ final void _processloop(.pgsql_util.conxion ci) {
}
private void procmessage() {
mixed err;
int terminating=0;
err = catch {
.pgsql_util.conxion ci=c; // cache value FIXME sensible?
.pgsql_util.conxiin cr=ci->i; // cache value FIXME sensible?
mixed err;
#ifdef PG_DEBUG
PD("Processloop\n");
......@@ -1190,6 +1192,12 @@ private void procmessage() {
termlock=0;
if(err && !stringp(err))
throw(err);
};
if (err) {
unnamedstatement=0;
termlock = 0;
throw(err);
}
}
//! Closes the connection to the database, any running queries are
......@@ -1201,9 +1209,11 @@ private void procmessage() {
/*semi*/final void close() {
if(qportals && qportals->size())
catch(cancelquery());
termlock=unnamedstatement->lock(1);
if (unnamedstatement)
termlock=unnamedstatement->lock(1);
c->close();
unnamedstatement->lock(1);
if (unnamedstatement)
unnamedstatement->lock(1);
destruct(c);destruct(waitforauthready);
}
......
......@@ -208,7 +208,11 @@ class conxiin {
}
final int read_cb(mixed id,mixed b) {
PD("Read callback %O\n",(string)b);
PD("Read callback %O\n",((string)b)
#ifndef PG_DEBUGMORE
[..255]
#endif
);
Thread.MutexKey lock=fillreadmux->lock();
if(procmsg&&id)
procmsg=0,lock=0,Thread.Thread(id);
......@@ -411,8 +415,10 @@ outer:
socket->set_backend(local_backend);
socket->set_buffer_mode(i,0);
socket->set_nonblocking(i->read_cb,write_cb,close);
connectfail=pgsqlsess->_connectfail;
Thread.Thread(pgsqlsess->_processloop,this);
if (nossl != 2) {
connectfail=pgsqlsess->_connectfail;
Thread.Thread(pgsqlsess->_processloop,this);
}
return;
};
catch(connectfail(err));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment