Sign in Join

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

Mailing lists / fpc-devel / 2016-01

Re: Inconsistent use of Timeout in SimpleIPC

9 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Denis Kozlov

Did anyone have a chance to review the changes to SimpleIPC?

Patches are attached in the previous message.

Proposed next steps:
1) If everyone is happy - commit changes (should I create a bug report in mantis?).
2) I can merge "wince" with "win" implementation since they are identical except for wide types/winapi, but won't be able to test on Windows CE.
3) Investigate if implementations on other platforms can benefit from message queue and overflow handling.

Denis

Denis Kozlov wrote 5 lines
I have rewritten SimpleIPC implementation for Windows. Summary of changes: 1. Using SetTimer + GetMessage method for handling PeekMessage. 2. Store all received incoming messages in a message queue (per IPC

server instance).

3. Implemented message queue (PeekMessage receives messages, ReadMessage

picks from the queue)

4. Implemented optional message queue limit and overflow handling (more

on that below).

5. Timeout<-1 is forced to -1; Documented meaning of various Timeout

values in comments.

6. Minor refactoring and code formatting changes. All these changes currently affect only the Windows implementation. The

main IPC interface has not changed. This allows to fix all major issues on Windows and test the new concept of buffering/queueing IPC messages.

A new global type was introduced: > TIPCMessageOverflowAction = (ipcmoaNone, ipcmoaDiscardOld,
ipcmoaDiscardNew, ipcmoaError);
Added two global variables which configure message queue limit and

overflow handling (affect newly created IPC servers):

> DefaultIPCMessageOverflowAction: TIPCMessageOverflowAction = ipcmoaNone; > DefaultIPCMessageQueueLimit: Integer = 0; Currently these are used only in Windows implementation, but they need to

be in the interface section to allow unit testing and perhaps later reuse on other platforms.

The second part is a comprehensive test suite for Windows implementation

of SimpleIPC. Tests spawn client mode instances as needed for proper testing of IPC. Tests check handling of messages, processing delays, synchronicity and message queue overflow actions. Read comments for each test routine for additional information. All timing based checks are very relaxed and can be controlled by IPC_BASETIME constant (a base line time per message in milliseconds), which can be increased for really-really slow machines. Simply compile and run. Exception is raised if any errors occur.

Other platforms will fail most tests due to not implemented featured,

such as message queue and overflow handling. Perhaps it could be added to FPC test suite for Windows platform only, but I'm not sure how suitable it is due to complexity of multiple processes and timing checks.

I also tested separately for compatibility with Lazarus message loop by

using PeekMessage(0, True) in Application.OnIdle, it works perfectly.

Attached files (full copies included for convenience; patches against FPC

trunk revision 32628 from 10 Dec 2015):

1) testipc.pas/testipc.out.txt - tests for SimpleIPC and example output. 2) simpleipc.pp/simpleipc.pp.patch - patch and a full copy of main

SimpleIPC unit.

3) simpleipc.inc/simpleipc.inc.patch - patch and a full copy of Windows

include file (not Windows CE).

Reply by email

Michael Van Canneyt
to Denis Kozlov
Denis Kozlov wrote 7 lines
Did anyone have a chance to review the changes to SimpleIPC? Patches are attached in the previous message. Proposed next steps: 1) If everyone is happy - commit changes (should I create a bug report in mantis?).

Please do. I will personally handle the report :-)

2) I can merge "wince" with "win" implementation since they are identical except for wide types/winapi, but won't be able to test on Windows CE.

Please do.

3) Investigate if implementations on other platforms can benefit from message queue and overflow handling.

Yes please, we discussed this before, no ?

I was in fact waiting for this part, rather than applying the patch as it is. But if you prefer we can do it in steps ?

Michael.

Reply by email

Michael Van Canneyt
to Denis Kozlov
Denis Kozlov wrote 11 lines
On 5 January 2016 at 12:39, Michael Van Canneyt wrote: > I was in fact waiting for this part, rather than applying the patch as it > is. > But if you prefer we can do it in steps ? > I prefer to do this in steps, easier to control changes. Bug report with same patch files: http://bugs.freepascal.org/view.php?id=29346

Great, thank you. I applied the patch (plus minor change to fpmake.pp).

I will test now the graphical debugserver program on windows. It lost messages on windows, I'm supposing this now will no longer be the case.. :)

I am looking forward to seeing the backlog mechanism on other platforms :-)

Michael.

Reply by email

Denis Kozlov
to Denis Kozlov: Did anyone have a chance to review the changes to SimpleIPC? Patches are attached in the…

In regards to merging "wince" and "win" implementations of SimpleIPC.

The only real difference is the use of Wide vs Ansi types and functions of WinAPI. Currently, "win32" and "win64" platforms use A versions, while "wince" uses W versions.

Since FPC trunk no longer supports Win9x platforms, is it safe to use W variants across all windows platforms for SimpleIPC?

Denis

Denis Kozlov wrote 8 lines
Proposed next steps: 1) If everyone is happy - commit changes (should I create a bug report in mantis?). 2) I can merge "wince" with "win" implementation since they are identical except for wide types/winapi, but won't be able to test on Windows CE. 3) Investigate if implementations on other platforms can benefit from message queue and overflow handling.

Reply by email

Michael Van Canneyt
to Denis Kozlov
Denis Kozlov wrote 9 lines
In regards to merging "wince" and "win" implementations of SimpleIPC. The only real difference is the use of Wide vs Ansi types and functions of WinAPI. Currently, "win32" and "win64" platforms use A versions, while "wince" uses W versions. Since FPC trunk no longer supports Win9x platforms, is it safe to use W variants across all windows platforms for SimpleIPC?

I would think yes.

Michael.

Reply by email

Denis Kozlov
to Denis Kozlov: In regards to merging "wince" and "win" implementations of SimpleIPC. The only real…
Denis Kozlov wrote 5 lines
In regards to merging "wince" and "win" implementations of SimpleIPC. The only real difference is the use of Wide vs Ansi types and functions of WinAPI. Currently, "win32" and "win64" platforms use A versions, while "wince" uses W versions.

I have updated "win" implementation of SimpleIPC to use W versions of WinAPI types and functions. Patch is attached. Tested on Windows 7.

It should now be compatible with "wince", so the next patch will be use this common "simpleipc.inc" on all Windows platforms (AllWindowsOSes). Prefer to do things in logical steps.

Denis

Reply by email

Michael Van Canneyt
to Denis Kozlov
Denis Kozlov wrote 9 lines
On 16/01/2016 21:43, Denis Kozlov wrote: > In regards to merging "wince" and "win" implementations of SimpleIPC. > > The only real difference is the use of Wide vs Ansi types and functions of > WinAPI. Currently, "win32" and "win64" platforms use A versions, while > "wince" uses W versions. I have updated "win" implementation of SimpleIPC to use W versions of WinAPI types and functions. Patch is attached. Tested on Windows 7.

Applied in rev. 32989.

Many thanks!

Michael.

Reply by email

Denis Kozlov
to Denis Kozlov: I have updated "win" implementation of SimpleIPC to use W versions of WinAPI types and…
Denis Kozlov wrote
so the next patch will be use this common "simpleipc.inc" on all Windows platforms (AllWindowsOSes).

Patch attached here:
http://bugs.freepascal.org/view.php?id=29496

Summary of changes:
1) Moved "src/win/simpleipc.inc" to "src/winall/simpleipc.inc"
2) Removed "src/wince/simpleipc.inc"
3) Included "src/winall" for AllWindowsOSes in fpmake.pp

Denis

Reply by email