microsoft / Detours

Detours is a software package for monitoring and instrumenting API calls on Windows. It is distributed in source code form.
MIT License
5.01k stars 979 forks source link

[bugs]ERROR_PIPE_CONNECTED when ConnectNamedPipe in syelogd if there are lots of clients #241

Closed fishjam closed 2 years ago

fishjam commented 2 years ago

Describe the bug I have written a UT code with multi thread client to test my pipe server(include the syelog), and I found if there are lots of client request connect to syelog at same time, there is ERROR_PIPE_CONNECTED when call ConnectNamedPipe , ad no err handle for it.

Command-line test case

E:\CodeGithub\fishjam-Detours\bin.X64>syelogd.exe
20220614033813631 ---- --.60: Before CreateWorkers.

20220614033813632 ---- --.60: Before CreatePipeConnection

20220614033813632 ---- --.60: Enter  WorkerThread
20220614033813632 ---- --.60: Enter CreatePipeConnection for 220.
20220614033813633 ---- --.60: After CreatePipeConnection

SYELOGD: Ready for clients.  Press Ctrl-C to stop.
20220614033821170 ---- --.60: GetQueuedCompletionStatus, bRet = 1, dwBytes=0, pClient=000001F3E5789390
20220614033821171 ---- --.60: Enter CreatePipeConnection for 220.
20220614033821172 ---- --.00: Error 535 in ConnectNamedPipe.
SYELOGD: Error 535 in ConnectNamedPipe.

Expected behavior I fix it by add the speical error handle, and will create the PR for it.

Detours version

fishjam commented 2 years ago

After fix it:

E:\CodeGithub\fishjam-Detours\bin.X64>syelogd.exe
SYELOGD: Ready for clients.  Press Ctrl-C to stop.
20220614052404152 14272 50.60: fishjam test thread:1, testIndex:0
20220614052404152 14272 50.60: fishjam test thread:1, testIndex:1
20220614052404153 14272 50.60: fishjam test thread:1, testIndex:2
20220614052404155 14272 50.60: fishjam test thread:2, testIndex:0
20220614052404155 14272 50.60: fishjam test thread:1, testIndex:3
20220614052404155 14272 50.60: fishjam test thread:2, testIndex:1
20220614052404155 14272 50.60: fishjam test thread:1, testIndex:4
20220614052404155 14272 50.60: fishjam test thread:2, testIndex:2
20220614052404155 14272 50.60: fishjam test thread:1, testIndex:5
20220614052404156 14272 50.60: fishjam test thread:2, testIndex:3
20220614052404157 14272 50.60: fishjam test thread:3, testIndex:0
20220614052404156 14272 50.60: fishjam test thread:1, testIndex:6
20220614052404157 14272 50.60: fishjam test thread:2, testIndex:4
...