Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3dd8369

Browse files
committed
Back out tcl patch, per Tom Lane:
Everytime if I do PQconsumeInput (when the backend channel gets readable) I check for the return value. (0 == error) and generate a notification manually, e.g. fixed string connection_closed) and pass it to the
1 parent 5bf6af6 commit 3dd8369

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

src/interfaces/libpgtcl/pgtclCmds.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.63 2002/08/17 12:19:31 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.64 2002/08/18 01:39:43 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -419,11 +419,8 @@ Pg_disconnect(ClientData cData, Tcl_Interp *interp, int argc, char *argv[])
419419

420420
#if TCL_MAJOR_VERSION >= 8
421421
conn = PgGetConnectionId(interp, argv[1], &connid);
422-
if (connid->notifier_channel != NULL) {
423-
/* stop listening for NOTIFY events on that channel */
424-
PgStopNotifyEventSource(connid,1);
422+
if (connid->notifier_channel != NULL)
425423
Tcl_UnregisterChannel(interp, connid->notifier_channel);
426-
}
427424
#endif
428425

429426
return Tcl_UnregisterChannel(interp, conn_chan);

src/interfaces/libpgtcl/pgtclId.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.31 2002/08/17 12:19:31 momjian Exp $
16+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.32 2002/08/18 01:39:43 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -277,7 +277,7 @@ PgDelConnectionId(DRIVER_DEL_PROTO)
277277
* Turn off the Tcl event source for this connection, and delete any
278278
* pending notify events.
279279
*/
280-
PgStopNotifyEventSource(connid,1);
280+
PgStopNotifyEventSource(connid);
281281

282282
/* Close the libpq connection too */
283283
PQfinish(connid->conn);
@@ -441,7 +441,7 @@ PgGetConnByResultId(Tcl_Interp *interp, char *resid_c)
441441
*mark = '.';
442442
if (conn_chan && Tcl_GetChannelType(conn_chan) == &Pg_ConnType)
443443
{
444-
Tcl_SetResult(interp, (char *)Tcl_GetChannelName(conn_chan), TCL_VOLATILE);
444+
Tcl_SetResult(interp, Tcl_GetChannelName(conn_chan), TCL_VOLATILE);
445445
return TCL_OK;
446446
}
447447

@@ -611,9 +611,7 @@ PgNotifyTransferEvents(Pg_ConnectionId * connid)
611611
* closed socket descriptor.
612612
*/
613613
if (PQsocket(connid->conn) < 0)
614-
/* do not remove any pending events, so that the virtual notification
615-
connection_closed will be processed */
616-
PgStopNotifyEventSource(connid,0);
614+
PgStopNotifyEventSource(connid);
617615
}
618616

619617
/*
@@ -677,17 +675,7 @@ Pg_Notify_FileHandler(ClientData clientData, int mask)
677675
* it internally to libpq; but it will clear the read-ready
678676
* condition).
679677
*/
680-
if (!PQconsumeInput(connid->conn)) {
681-
NotifyEvent *event = (NotifyEvent *) ckalloc(sizeof(NotifyEvent));
682-
683-
PGnotify *closed = (PGnotify *) ckalloc(sizeof(PGnotify));
684-
strcpy(closed->relname,"connection_closed");
685-
event->header.proc = Pg_Notify_EventProc;
686-
event->info= *closed;
687-
event->connid = connid;
688-
Tcl_QueueEvent((Tcl_Event *) event, TCL_QUEUE_TAIL);
689-
ckfree((void *)closed);
690-
}
678+
PQconsumeInput(connid->conn);
691679

692680
/* Transfer notify events from libpq to Tcl event queue. */
693681
PgNotifyTransferEvents(connid);
@@ -736,7 +724,7 @@ PgStartNotifyEventSource(Pg_ConnectionId * connid)
736724
}
737725

738726
void
739-
PgStopNotifyEventSource(Pg_ConnectionId * connid, int remove_pending)
727+
PgStopNotifyEventSource(Pg_ConnectionId * connid)
740728
{
741729
/* Remove the event source */
742730
if (connid->notifier_running)
@@ -755,5 +743,5 @@ PgStopNotifyEventSource(Pg_ConnectionId * connid, int remove_pending)
755743
}
756744

757745
/* Kill any queued Tcl events that reference this channel */
758-
if (remove_pending) Tcl_DeleteEvents(NotifyEventDeleteProc, (ClientData) connid);
746+
Tcl_DeleteEvents(NotifyEventDeleteProc, (ClientData) connid);
759747
}

src/interfaces/libpgtcl/pgtclId.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
13-
* $Id: pgtclId.h,v 1.19 2002/08/17 12:19:31 momjian Exp $
13+
* $Id: pgtclId.h,v 1.20 2002/08/18 01:39:43 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -44,7 +44,7 @@ extern PGresult *PgGetResultId(Tcl_Interp *interp, char *id);
4444
extern void PgDelResultId(Tcl_Interp *interp, char *id);
4545
extern int PgGetConnByResultId(Tcl_Interp *interp, char *resid);
4646
extern void PgStartNotifyEventSource(Pg_ConnectionId * connid);
47-
extern void PgStopNotifyEventSource(Pg_ConnectionId * connid, int remove_pend);
47+
extern void PgStopNotifyEventSource(Pg_ConnectionId * connid);
4848
extern void PgNotifyTransferEvents(Pg_ConnectionId * connid);
4949
extern void PgNotifyInterpDelete(ClientData clientData, Tcl_Interp *interp);
5050

0 commit comments

Comments
 (0)