Branch: Tag:

2016-10-13

2016-10-13 09:52:22 by Stephen R. van den Berg <srb@cuci.nl>

pgsql: Drop termination lock even on exceptions.

Prevent cancelquery() from starting the statemachine.
This was responsible for the majority of the exceptions.

313:   //! 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:    _connectfail();    else    destruct(waitforauthready); +  unnamedstatement=0;    termlock=0;    return;    }
625:   }      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:    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   //! terminated instantly.
1201:   /*semi*/final void close() {    if(qportals && qportals->size())    catch(cancelquery()); +  if (unnamedstatement)    termlock=unnamedstatement->lock(1);    c->close(); -  +  if (unnamedstatement)    unnamedstatement->lock(1);    destruct(c);destruct(waitforauthready);   }