Re: [HACKERS] bug in libpgtcl listen

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)it>
Cc: hackers(at)postgreSQL(dot)org (PostgreSQL Hackers)
Subject: Re: [HACKERS] bug in libpgtcl listen
Date: 1999-01-17 21:19:54
Message-ID: 15556.916607994@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)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

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-01-17 21:22:22 Re: [HACKERS] some patches for 6.4.2
Previous Message Tom Lane 1999-01-17 20:00:18 Re: [HACKERS] doc/FAQ* files are hosed