Massimo Dal Zotto <dz@cs.unitn.it> writes:
> I found a bug in the notify handler of the libpgtcl interface.
> If I have setup a notify handler and the backend dies, the tcl interpreter
> will not remove the handler and loop forever with a bad fd in select().
Good point. I don't like your particular fix though, since I'm not sure
that Tcl will always call the file event handler in that situation ---
other platforms and/or Tcl releases might behave differently than yours.
I put the check into PgNotifyTransferEvents() instead, from which it
will get called in the same conditions as your fix, and it will also get
called after every PQexec():
*** src/interfaces/libpgtcl/pgtclId.c Sun Sep 20 21:02:03 1998
--- ./pgtclId.c Sun Jan 17 15:30:53 1999
***************
*** 582,587 ****
--- 582,596 ---- Tcl_QueueEvent((Tcl_Event *) event, TCL_QUEUE_TAIL); free(notify); }
+
+ /*
+ * This is also a good place to check for unexpected closure of the
+ * connection (ie, backend crash), in which case we must shut down the
+ * notify event source to keep Tcl from trying to select() on the now-
+ * closed socket descriptor.
+ */
+ if (PQsocket(connid->conn) < 0)
+ PgStopNotifyEventSource(connid); } /*
regards, tom lane