accept() call blocks forever under 10.3.9, even if a client successfully connects
accept() call blocks forever under 10.3.9, even if a client successfully connects
- Subject: accept() call blocks forever under 10.3.9, even if a client successfully connects
- From: Markus Hanauska <email@hidden>
- Date: Thu, 27 Sep 2007 11:58:34 +0200
Hello again,
I have a 10.3.9 socket problem, that I can also reproduce in my code
under 10.3.9. I can reproduce it under 10.4.10, but only sporadically.
What I do is opening a UNIX socket (we have our own IPC framework, it
can run over any type of socket, including network sockets, but right
now we use it only on a single machine, locally, using a UNIX socket) in
a server process.
What I do is no big magic, opening, binding to a local path, calling
listen on it and then waiting for incoming connections using accept.
Now I have several clients, that also open a socket, connecting it to
the server socket and doing some IPC with the server.
This all works nicely... up to the point I close one of the client
sockets. Once I close one of them (regardless which one), I can't
connect to the server socket any longer. If I start another client, it
seems to connect, but can't ever do any IPC. In fact, the server hangs
in accept. It never wakes up from accept, even though another client
connected.
Even more confusing, if I start another client after that happens, this
client seems to connect also, this time accept does wake up, however,
when the client sends data, the data never arrives at the server
(reading on the socket I got from accept simply never receives
anything). When the client disconnects, the server correctly recognizes
that the accepted socket has closed, so that is still working.
I can modify my clients to never close their IPC sockets and never die,
then I will never run into the problem. I will run into the problem the
first time a socket is closed.
Assuming the server socket is broken after the close of a client socket
(the server never closes the socket, the client closes it and if the
server sees that, it will close the socket, too), I'd expect accept to
fail with an error code, but that doesn't happen.
Now under which condition will accept hang? Why would it never wake up,
even not if a client connects? Why does it wake-up if a second one
connects and why is the resulting socket unusable then?
I debugged, I dumped all kind of socket output, I ran lsof... but I
can't find any explanation for why this happens. Like I said, it happens
always under 10.3.9, it happens very sporadically under 10.4.10 (usually
if the server socket was open for a very long time and nobody connected
to it).
Any ideas anyone? Anything I should look or test for?
Regards,
Markus
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden