示例#1
0
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);
}
示例#2
0
文件: tclThreadTest.c 项目: aosm/tcl
     /* ARGSUSED */
static void
ThreadExitProc(
    ClientData clientData)
{
    char *threadEvalScript = (char *) clientData;
    ThreadEventResult *resultPtr, *nextPtr;
    Tcl_ThreadId self = Tcl_GetCurrentThread();

    Tcl_MutexLock(&threadMutex);

    if (threadEvalScript) {
	ckfree((char *) threadEvalScript);
	threadEvalScript = NULL;
    }
    Tcl_DeleteEvents((Tcl_EventDeleteProc *)ThreadDeleteEvent, NULL);

    for (resultPtr = resultList ; resultPtr ; resultPtr = nextPtr) {
	nextPtr = resultPtr->nextPtr;
	if (resultPtr->srcThreadId == self) {
	    /*
	     * We are going away. By freeing up the result we signal to the
	     * other thread we don't care about the result.
	     */

	    if (resultPtr->prevPtr) {
		resultPtr->prevPtr->nextPtr = resultPtr->nextPtr;
	    } else {
		resultList = resultPtr->nextPtr;
	    }
	    if (resultPtr->nextPtr) {
		resultPtr->nextPtr->prevPtr = resultPtr->prevPtr;
	    }
	    resultPtr->nextPtr = resultPtr->prevPtr = 0;
	    resultPtr->eventPtr->resultPtr = NULL;
	    ckfree((char *) resultPtr);
	} else if (resultPtr->dstThreadId == self) {
	    /*
	     * Dang. The target is going away. Unblock the caller. The result
	     * string must be dynamically allocated because the main thread is
	     * going to call free on it.
	     */

	    char *msg = "target thread died";

	    resultPtr->result = ckalloc(strlen(msg)+1);
	    strcpy(resultPtr->result, msg);
	    resultPtr->code = TCL_ERROR;
	    Tcl_ConditionNotify(&resultPtr->done);
	}
    }
    Tcl_MutexUnlock(&threadMutex);
}
示例#3
0
文件: caCmd.c 项目: auriocus/AsynCA
static void freepvInfo(pvInfo *i) {
	/* Remove all pending events in the Tcl event queue
	 * pointing to this PV */
	Tcl_DeleteEvents(PVeventDeleteProc, (ClientData)i);

	if (i->id) {
		if (i->monitorid) {
			ca_clear_subscription(i->monitorid);
		}
		ca_clear_channel(i->id);
	}
	ckfree(i->name);
	
	DecrIfNotNull(&i->connectprefix);
	DecrIfNotNull(&i->monitorprefix);
	ckfree(i);
}