void PgStopNotifyEventSource(Pg_ConnectionId * connid, bool allevents) { /* Remove the event source */ if (connid->notifier_running) { #if TCL_MAJOR_VERSION >= 8 Tcl_DeleteChannelHandler(connid->notifier_channel, Pg_Notify_FileHandler, (ClientData) connid); #else /* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */ Tcl_File tclfile = Tcl_GetFile((ClientData) connid->notifier_socket, TCL_UNIX_FD); Tcl_DeleteFileHandler(tclfile); #endif connid->notifier_running = 0; } /* Kill queued Tcl events that reference this channel */ if (allevents) Tcl_DeleteEvents(AllNotifyEventDeleteProc, (ClientData) connid); else Tcl_DeleteEvents(NotifyEventDeleteProc, (ClientData) connid); }
void PgStartNotifyEventSource(Pg_ConnectionId * connid) { /* Start the notify event source if it isn't already running */ if (!connid->notifier_running) { int pqsock = PQsocket(connid->conn); if (pqsock >= 0) { #if TCL_MAJOR_VERSION >= 8 Tcl_CreateChannelHandler(connid->notifier_channel, TCL_READABLE, Pg_Notify_FileHandler, (ClientData) connid); #else /* In Tcl 7.5 and 7.6, we need to gin up a Tcl_File. */ Tcl_File tclfile = Tcl_GetFile((ClientData) pqsock, TCL_UNIX_FD); Tcl_CreateFileHandler(tclfile, TCL_READABLE, Pg_Notify_FileHandler, (ClientData) connid); connid->notifier_socket = pqsock; #endif connid->notifier_running = 1; } } }
static Tcl_File tcl_filehandle(value fd) { return Tcl_GetFile((ClientData)Long_val(fd), TCL_UNIX_FD); }