rem: itPtr->servPtr = NULL; tid = Ns_GetThreadId(); Ns_MutexLock(&ilock); do { sprintf(itPtr->name, "nsinterp:%d:%d", tid, next++); itPtr->hPtr = Tcl_CreateHashEntry(&interps, itPtr->name, &new); } while (!new); Tcl_SetHashValue(itPtr->hPtr, itPtr); Ns_MutexUnlock(&ilock); itPtr->cancel = Tcl_AsyncCreate(AsyncCancel, itPtr);
add: itPtr->servPtr = NsGetServer(server);
context: NewInterpData(Tcl_Interp *interp){    static volatile int initialized = 0;    static unsigned int next = 0;    NsInterp *itPtr;    int new, tid;    /*     * Core one-time AOLserver initialization to add a few Tcl_Obj     * types.  These calls cannot be in NsTclInit above because     * Tcl is not fully initialized at libnsd load time.     */    if (!initialized) {	Ns_MasterLock();	if (!initialized) {	    NsTclInitQueueType();	    NsTclInitAddrType();	    NsTclInitTimeType();	    NsTclInitCacheType();	    NsTclInitKeylistType();	    initialized = 1;	}	Ns_MasterUnlock();    }    /*     * Allocate and initialize a new NsInterp struct.     */    itPtr = ns_calloc(1, sizeof(NsInterp));    itPtr->interp = interp;    itPtr->servPtr = NULL;    tid = Ns_GetThreadId();    Ns_MutexLock(&ilock);    do {    	sprintf(itPtr->name, "nsinterp:%d:%d", tid, next++);    	itPtr->hPtr = Tcl_CreateHashEntry(&interps, itPtr->name, &new);    } while (!new);    Tcl_SetHashValue(itPtr->hPtr, itPtr);    Ns_MutexUnlock(&ilock);    itPtr->cancel = Tcl_AsyncCreate(AsyncCancel, itPtr);    Tcl_InitHashTable(&itPtr->sets, TCL_STRING_KEYS);    Tcl_InitHashTable(&itPtr->chans, TCL_STRING_KEYS);	    Tcl_InitHashTable(&itPtr->https, TCL_STRING_KEYS);	    /*     * Associate the new NsInterp with this interp.  At interp delete     * time, Tcl will call FreeInterpData to cleanup the struct.     */    Tcl_SetAssocData(interp, "ns:data", FreeInterpData, itPtr);    /*     * Add core AOLserver commands.     */    NsTclAddCmds(interp, itPtr);    Tcl_PkgProvide(interp, "Nsd", NS_VERSION);    return itPtr;}