[fpc-devel] SimpleIPC and TWinMsgServerComm.PeekMessage

Juha Manninen juha.manninen62 at gmail.com
Wed Oct 9 19:50:53 CEST 2013


On Wed, Oct 9, 2013 at 6:10 PM, Sven Barth <pascaldragon at googlemail.com> wrote:
> I've looked at the code a bit more and the problem must be something else.
> MsgWaitForMultipleObjects waits on a FHWND which it created itself and
> additionally waits for the reception of a message through SendMessage. So
> this should not fail except maybe the creation of the window failed. Could
> you print the error message returned by "SysErrorMessage(GetLastOSError)" if
> put at the then-part of "if R=WAIT_FAILED"?

Funny, it gives the error in Finnish language. Translated meaning is
"Invalid handle".

Can you reproduce it? You must use the latest Lazarus trunk for
testing. Yesterday I fixed TForm1.GetLHelpFilename in unit
HelpConnectionUnit1. Apparently it was not tested on Windows until
yesterday.

This my my patch after preventing a potential INFINITE sleep :

--- a/packages/fcl-process/src/win/simpleipc.inc
+++ b/packages/fcl-process/src/win/simpleipc.inc
@@ -146,7 +146,9 @@ begin
     if (TimeOut=0) then
       TimeOut:=Integer(INFINITE);
     R:=MsgWaitForMultipleObjects(1,FHWND,False,TimeOut,QS_SENDMESSAGE);
-    B:=(R<>WAIT_TIMEOUT);
+    if (R=WAIT_FAILED) and (TimeOut<>INFINITE) then
+      Sleep(TimeOut);
+    B:=(R<>WAIT_TIMEOUT) and (R<>WAIT_FAILED);
     end;
   If B then
     Repeat


Regards,
Juha



More information about the fpc-devel mailing list