Skip to content

Commit

Permalink
Fix [7a56471157]: Consider tip#609 for version >= 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Dec 2, 2024
1 parent 98ea750 commit 592074a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
13 changes: 5 additions & 8 deletions generic/threadCmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ Init(
if (tsdPtr->interp == NULL) {
Tcl_Interp *tmpInterp, *mainInterp = interp;
memset(tsdPtr, 0, sizeof(ThreadSpecificData));
/*
/*
* Retrieve main interpreter of the thread, only
* main interpreter used as default thread-interpreter,
* so no childs here, see bug [d4ba38d00d06ebba]
Expand Down Expand Up @@ -2469,8 +2469,7 @@ ThreadTransfer(
* Queue the event and poke the other thread's notifier.
*/

Tcl_ThreadQueueEvent(thrId, (Tcl_Event*)evPtr, TCL_QUEUE_TAIL);
Tcl_ThreadAlert(thrId);
Tcl_ThreadQueueEvent(thrId, (Tcl_Event*)evPtr, TCL_QUEUE_TAIL|TCL_QUEUE_ALERT_IF_EMPTY);

/*
* (*) Block until the other thread has either processed the transfer
Expand Down Expand Up @@ -2811,11 +2810,10 @@ ThreadSend(

eventPtr->event.proc = ThreadEventProc;
if ((flags & THREAD_SEND_HEAD)) {
Tcl_ThreadQueueEvent(thrId, (Tcl_Event*)eventPtr, TCL_QUEUE_HEAD);
Tcl_ThreadQueueEvent(thrId, (Tcl_Event*)eventPtr, TCL_QUEUE_HEAD|TCL_QUEUE_ALERT_IF_EMPTY);
} else {
Tcl_ThreadQueueEvent(thrId, (Tcl_Event*)eventPtr, TCL_QUEUE_TAIL);
Tcl_ThreadQueueEvent(thrId, (Tcl_Event*)eventPtr, TCL_QUEUE_TAIL|TCL_QUEUE_ALERT_IF_EMPTY);
}
Tcl_ThreadAlert(thrId);

if ((flags & THREAD_SEND_WAIT) == 0) {
/*
Expand Down Expand Up @@ -3089,8 +3087,7 @@ ThreadReserve(
evPtr->clbkData = NULL;
evPtr->resultPtr = resultPtr;

Tcl_ThreadQueueEvent(thrId, (Tcl_Event*)evPtr, TCL_QUEUE_TAIL);
Tcl_ThreadAlert(thrId);
Tcl_ThreadQueueEvent(thrId, (Tcl_Event*)evPtr, TCL_QUEUE_TAIL|TCL_QUEUE_ALERT_IF_EMPTY);

if (dowait) {
while (resultPtr->result == NULL) {
Expand Down
3 changes: 1 addition & 2 deletions generic/threadPoolCmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1809,8 +1809,7 @@ SignalWaiter(
evPtr = (Tcl_Event *)Tcl_Alloc(sizeof(Tcl_Event));
evPtr->proc = RunStopEvent;

Tcl_ThreadQueueEvent(waitPtr->threadId,(Tcl_Event*)evPtr,TCL_QUEUE_TAIL);
Tcl_ThreadAlert(waitPtr->threadId);
Tcl_ThreadQueueEvent(waitPtr->threadId,(Tcl_Event*)evPtr,TCL_QUEUE_TAIL|TCL_QUEUE_ALERT_IF_EMPTY);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion tests/thread.test
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test thread-1.11 {no segfault on 2nd interpreter, bug [d4ba38d00d06ebba]} -body
# any other thread invocation before 2nd interpreter gets the thread::id (TSD),
# but test-suite calls thread::id command (tcltest, all.tcl and thread.test):
set fd [open [list |[info nameofexecutable] << [string map [list {$$load} [tcltest::loadScript]] {
$$load; package require thread
$$load; package require thread
interp create ci
set l {}
ci eval {$$load; package require thread; thread::id}
Expand Down

0 comments on commit 592074a

Please sign in to comment.