Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-12

Patch proposal

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Nikolai ZHUBR

Hello people,

(Sorry if this appears twice on the list, I've made one attempt to post before I subscribed to the list, and it seems it was silently rejected)

Could someone please consider the patch below.

This patch makes ThreadFunc (rtl/unix/tthread.inc) behave like the generic ThreadProc (classes.inc).
That is, thread object will never be accessed by RTL after DoTerminate call (unless FreeOnTerminate=true, of course). As a side effect, any changes to FreeOnTerminate within DoTerminate are ignored. (The reason this is important is because one may want to initiate thread object disposal from within DoTerminate, but use another thread to get some data from the no-longer-running thread and then actually dispose it)

This patch is against version 2.4.0rc1.

Thank you!

Nikolai ZHUBR

--- fpcsrc/rtl/unix/tthread.inc.orig    Thu Jan 24 22:30:56 2008
+++ fpcsrc/rtl/unix/tthread.inc Sun Dec 27 14:12:20 2009
@@ -85,6 +85,7 @@
 function ThreadFunc(parameter: Pointer): ptrint;
 var
   LThread: TThread;
+  LFreeOnTerminate: boolean;
 {$ifdef DEBUG_MT}
   lErrorAddr, lErrorBase: Pointer;
 {$endif}
@@ -143,8 +144,9 @@
   Result := LThread.FReturnValue;
   WRITE_DEBUG('Result is ',Result);
   LThread.FFinished := True;
+  LFreeOnTerminate := LThread.FreeOnTerminate;
   LThread.DoTerminate;
-  if LThread.FreeOnTerminate then
+  if LFreeOnTerminate then
     begin
       WRITE_DEBUG('Thread ',ptruint(lthread),' should be freed');
       LThread.Free;

Reply by email

Jonas Maebe
to Nikolai ZHUBR
Nikolai ZHUBR wrote
(Sorry if this appears twice on the list, I've made one attempt to post before I subscribed to the list, and it seems it was silently rejected)

Messages from non-subscribers are held for moderator approval. Every day, this unfortunately includes 10 to 30 spam messages. While I manually go over all of them (for all 4 FPC mailing lists), inevitably I sometimes miss non-spam messages and accidentally discard them as well...

Could someone please consider the patch below.

I've committed it, thanks.

Jonas

Reply by email