Re: IOCP Across Threads - Error 995



The problem is that when a thread exits with outstanding overlapped
send requests in progress all of those requests are cancelled - See:
http://msdn2.microsoft.com/en-us/library/ms742203.aspx (under Note in
the Overlapped IO section). I expect that you're just being lucky when
you say that all your data arrives OK...

So, to fix this, you either need to keep track of when these requests
complete and keep your send thread alive until that point or you need
to do your sends from a thread that wont exit.

I opted for the later in my IOCP client server framework and I
'marshal' requests to the IO threads to action since I know the IO
threads wont exit... This makes the operations less effiicient when
used from threads that aren't in the IO pool but it means that the
code is easier for users of the framework to use.... In your case it's
probably as easy to track the sends and their completions and keep
your thread alive until all of the outstanding requests complete...

In case you're interested: my IOCP framework is available with full
source code, free of charge, here: http://www.lenholgate.com/archives/000637.html
and there are links to the original code project articles that explain
some of the design decisions made during development.

Len

On Oct 2, 1:08 am, LongJohn <LongJ...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Hi,

I have an application that creates an IOCP in the main thread, then creates
worker threads that wait on it. This works very well for incoming
connections from clients.

I have created an additional thread that initiates connections to the
clients (who are listening for these "reverse" connections). In that thread,
I associate the outgoing transaction sockets to the same IOCP (from the
global handle), so I can use a single handler for all the I/O. This thread
exits after the outgoing connections have connected and the send buffers have
been posted to them.

This even works well, but recently I have observed the following phenomenon:

When the outgoing connection thread ends, sometimes some of the sends that
were posted return to the handler with an error condition of 995, indicating
that they were aborted due to a thread exiting. The data is making it to the
client successfully.

As an experiment, I placed a Sleep() at the end of the outgoing connection
thread and all the sends now are returned to the handler successfully. This
is obviously not a solution.

I thought that when I posted sends to the global IOCP, it would not matter
which thread I did it from, or whether that thread was still alive. I don't
want to add another handler in that outgoing connection thread to wait for
all connections to complete before exiting the thread.

Is this really an error, or just a "notification"?

Any ideas?


.



Relevant Pages

  • Re: Do I want an ACK in my high-level protocol when using TCP?
    ...   for { ... have those 2 connections to B at once. ... application A will hold back sending requests ... other network I/O in the application. ...
    (comp.unix.programmer)
  • Re: Socket Programming
    ... * Single threaded application that multiplexes concurrent connections ... Some requests may be served within millisecond time scale. ... On a single cpu system, ... do is keep some rolling counter of number of connections accepted in ...
    (comp.lang.lisp)
  • Re: Network Firewall/Routing Solution
    ... >> firewall combo boxes that linksys sells, and I really don't want to run ... >> not working properly at all with multiple network cards. ... >> like Unicode and header information for http requests, ... >> non-pasv connections. ...
    (comp.security.firewalls)
  • zombies with AMD64 and 32 bit userspace with 2.6
    ... the test is a simple forking proxy that receives connections from one ... machine (running apache benchmark) and forwards them to anothr machine ... to do a test with more then about 30,000 requests in it the box starts to ... the smaller tests leave no zombies at all and can be run multiple times ...
    (Linux-Kernel)
  • Re: Fork and Closing Open Sockets
    ... The server pid accepts network connections until the 'host' connection ... exits, then all clients exit. ... case is a recorder shell based client that starts after the first ... client connects, but when the host exits, it waits for the shell to ...
    (comp.os.linux.networking)