[haiku-development] Re: Problems with non-blocking sockets

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 09 Jan 2014 22:34:48 +0100

On 01/09/2014 06:39 PM, Adrien Destugues wrote:
- As Stop closes the socket, if the protocol thread was waiting on a read()
or write() call, it gets woken up and exits as expected.

While you would expect that, it's actually not what happens on other operating systems. This is a Haiku specific feature.

- When the thread is still waiting on the initial connect(), however, this
doesn't quite work. connect() isn't unlocked by close().

This is a bug that deserves to be fixed.

[...]
call to close(). However, I hit https://dev.haiku-os.org/ticket/2963 ,
which prevents this from working on Haiku (the select call will return
immediately, and there is no way to tell if the connection was succesful or
not).

And that's just another bug that has to be fixed :-)

You could look into how it's done on other operating systems, as those don't have this handy feature (select will just wait forever there), but this should be really fixed in the network stack, and not worked around.

A solution I did on another OS was to use a pipe that signaled the socket status, and then poll()'d on that, too (don't use select(), it's an ancient API).

So, I'm looking for:
- Help with solving #2963,
- Comments on the various solutions and which is the one to implement.

I'm currently a bit low on time, but I'll try to have a look into it over the next couple of days (to help you, it won't be enough to do any actual coding, I'm afraid).

Bye,
   Axel.


Other related posts: