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