Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ERROR_ALREADY_EXISTS on reading from Named Pipe

440 views
Skip to first unread message

Jeroen ter Hofstede

unread,
Jan 22, 2010, 6:07:53 AM1/22/10
to
Hi all,


Does anybody know under which circumstances reading from a Named Pipe
may return an ERROR_ALREADY_EXISTS (183) error?
In our case, the pipe has been used successfully for some time, and
then GetOverlappedResult() returns this error.

The sequence is:
ReadFile (...); // overlapped IO, call succeeds with
ERROR_IO_PENDING
WaitForSingleObject (...) // waiting for the event associated with the
overlapped IO
GetOverlappedResult (...) // Returns ERROR_ALREADY_EXISTS

There is only a single thread accessing the named pipe. It's partner
is still alive. Until now it only occurs on some computers of a
customer of ours, but we have not been able to find out what makes
these machines different. Googling did not return relevant results.


TIA,
Jeroen

David Schwartz

unread,
Jan 22, 2010, 9:16:01 AM1/22/10
to
On Jan 22, 3:07 am, Jeroen ter Hofstede

<jeroen.ter.hofst...@wanadoo.nl> wrote:
> Hi all,
>
> Does anybody know under which circumstances reading from a Named Pipe
> may return an ERROR_ALREADY_EXISTS (183) error?
> In our case, the pipe has been used successfully for some time, and
> then GetOverlappedResult() returns this error.
>
> The sequence is:
> ReadFile (...);                 // overlapped IO, call succeeds with
> ERROR_IO_PENDING
> WaitForSingleObject (...) // waiting for the event associated with the
> overlapped IO
> GetOverlappedResult (...) // Returns ERROR_ALREADY_EXISTS

I assume you mean GetOverlappedResult returns non-zero and then
GetLastError returns ERROR_ALREADY_EXISTS, right? If you're not 100%
sure, make sure.

And you are 100% sure the overlapped object is from the ReadFile
operation? And the handle you passed to GetOverlappedResult is the
handle to the pipe?

In all other cases (at least that I know of), ERROR_ALREADY_EXISTS is
actually a success indication. So most likely, the operating has
actually succeeded.

DS

Jeroen ter Hofstede

unread,
Jan 22, 2010, 9:22:43 AM1/22/10
to
On 22 jan, 12:07, Jeroen ter Hofstede <jeroen.ter.hofst...@wanadoo.nl>
wrote:

> Hi all,
>
> Does anybody know under which circumstances reading from a Named Pipe
> may return an ERROR_ALREADY_EXISTS (183) error?

Argh. Please disregard. It appears that something was resetting
GetLastError() in between the calls.

Jeroen ter Hofstede

unread,
Jan 22, 2010, 9:26:09 AM1/22/10
to
On 22 jan, 15:16, David Schwartz <dav...@webmaster.com> wrote:

> I assume you mean GetOverlappedResult returns non-zero and then
> GetLastError returns ERROR_ALREADY_EXISTS, right? If you're not 100%
> sure, make sure.

I apologize for wasting your time. It appears that another call (.Net
marshalling) reset GetLastError() in between the calls.
Thanks anyway!

David Schwartz

unread,
Jan 22, 2010, 11:57:11 AM1/22/10
to
On Jan 22, 6:26 am, Jeroen ter Hofstede
<jeroen.ter.hofst...@gmail.com> wrote:

> I apologize for wasting your time. It appears that another call (.Net
> marshalling) reset GetLastError() in between the calls.
> Thanks anyway!

No problem. I learned a few things myself while researching your
answer.

That's a surprisingly common mistake. That's why the first thing I
said is to 100% make sure you were really seeing what you thought you
were seeing.

Glad you got it sorted out.

DS

0 new messages