Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions generic/nsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ static Tcl_ExitProc ExitHandler;

#if defined(TCL_THREADS)
static Tcl_ExitProc Nsf_ThreadExitProc;
#if !defined(_WIN32) && !defined(_WIN64)
static pthread_t main_thread_id = 0;
#endif
#endif


Expand Down Expand Up @@ -35940,6 +35937,9 @@ ExitHandler(ClientData clientData) {
Tcl_Interp *interp = (Tcl_Interp *)clientData;
int flags;
NsfRuntimeState *rst;
#if defined(TCL_THREADS) && !defined(_WIN32) && !defined(_WIN64)
Tcl_ThreadId interpThreadId = Tcl_Interp_threadId(interp);
#endif

nonnull_assert(clientData != NULL);

Expand Down Expand Up @@ -36083,15 +36083,15 @@ ExitHandler(ClientData clientData) {

#if defined(TCL_THREADS) && !defined(_WIN32) && !defined(_WIN64)
/*
* The interpreter of the main thread has to be deleted by Tcl. Otherwise we
* Delete interpreters only by the thread that owns them. Otherwise we
* see fatal errors like the following from NaviServer, when exiting from
* the call "nsd -c":
*
* Fatal: Tcl_AsyncDelete: async handler deleted by the wrong thread
*/
/*fprintf(stderr, "+++ ExiHandler interp %p main_thread_id %p current %p\n",
(void*)interp, (void*) main_thread_id, pthread_self());*/
if (main_thread_id == pthread_self()) {
/*fprintf(stderr, "+++ ExitHandler interp %p current %p owned by %p\n",
(void*)interp, pthread_self(), interpThreadId);*/
if (pthread_equal((pthread_t)interpThreadId, pthread_self()) != 0) {
Tcl_Release(interp);
}
#else
Expand Down Expand Up @@ -36245,18 +36245,6 @@ Nsf_Init(
*/
NsfMutexLock(&initMutex);

#if defined(TCL_THREADS) && !defined(_WIN32) && !defined(_WIN64)
/*
* Keep the main thread id. Actually, we assume that the first thread is the
* main thread, although there is no guarantee for this. However, this
* avoids fatal errors when used in NaviServer.
*/
if (main_thread_id == 0) {
main_thread_id = pthread_self();
/*fprintf(stderr, "+++ Init interp %p main_thread %p\n", (void*)interp, (void*) main_thread_id);*/
}
#endif

Nsf_OT_byteCodeType = Tcl_GetObjType("bytecode");
assert(Nsf_OT_byteCodeType != NULL);

Expand Down