|
-
September 23rd, 2006, 07:24 PM
#1
Semaphore timeout while using pipes?
I'm using named pipes two communicate between two processes on the same computer. Quite frequently (and randomly), however, a ConnectNamedPipe() operation fails and GetLastError() returns 121, which according to MSDN is due to a semaphore timeout. Can someone explain what pipes have to do with semaphores and why I could be getting this error?
EDIT: Sorry, I made a mistake. It is CreateFile(), not ConnectNamedPipe(), that produces the error.
Last edited by HighCommander4; September 25th, 2006 at 05:53 PM.
Old Unix programmers never die, they just mv to /dev/null
-
September 25th, 2006, 02:06 PM
#2
Re: Semaphore timeout while using pipes?
one process creates the named pipe via CreateNamedPipe() and waits for clients via ConnectNamedPipe(). are there multiple connections to the pipe created in the first process on the second process?
Kuphryn
-
September 25th, 2006, 05:52 PM
#3
Re: Semaphore timeout while using pipes?
 Originally Posted by kuphryn
one process creates the named pipe via CreateNamedPipe() and waits for clients via ConnectNamedPipe(). are there multiple connections to the pipe created in the first process on the second process?
Kuphryn
The second process keeps connecting to and disconnecting from the first process' pipe using CreateFile() and CloseHandle(). It is CreateFile() in the second process that produces the error code 121 frequently, usually after connecting and disconnecting multiple times.
Old Unix programmers never die, they just mv to /dev/null
-
September 25th, 2006, 06:04 PM
#4
Re: Semaphore timeout while using pipes?
logic is correct. multiple threads? possible that you open more pipes than close pipe?
Kuphryn
-
September 26th, 2006, 06:51 PM
#5
Re: Semaphore timeout while using pipes?
 Originally Posted by kuphryn
logic is correct. multiple threads? possible that you open more pipes than close pipe?
Kuphryn
Nope, both processes are single-threaded. The use of pipes is well encapsulated in functions that start by connecting the pipe and end by disconnecting it, so I'd say it's unlikely I open the pipes more than I close them.
I changed my code to decrease the number of connects/disconnects, preferring to stay connected until a larger amount of data is transferred, and the errors have significantly decreased in frequency, but still come up once in a while and undermine the reliability of my code.
I'm wondering if it has something to do with the amount of pipe instances I'm allowing when I'm creating the pipe, though I'm not sure how that could be the problem since the pipes are only being used between two processes...
EDIT: I have increased the number of allowed pipe instances that I specify at the time of pipe creation, but it had no effect. The errors continue to appear very randomly.
Last edited by HighCommander4; September 28th, 2006 at 03:10 PM.
Old Unix programmers never die, they just mv to /dev/null
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|