[haiku-development] Re: select_sync reference counting

  • From: Hamish Morrison <hamishm53@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 11 Jun 2015 14:22:33 +0100

Hi Ingo,

On 11/06/2015 09:58, Ingo Weinhold wrote:

E.g. have a look at deselect_select_infos() [1] -- which is called when
the FD slot is vacated -- and deselect_fd() [2] -- which is called by
the select() and friends.

Thanks for the explanation. I see it now -- the deselection is done
outwith the io_mutex, so the notification from the file close can race
with the deselection at the end of the select/poll/wait_for_objects
call. Ports and semaphores do everything under the lock for that port or
semaphore, so they can avoid this.

As a bit of background, I was looking into implementing a 'stateful
poll' -- like epoll or kqueue -- where an fd is registered with an event
queue, and events are retrieved later. This race makes deregistration of
an fd problematic; the event can't be deleted right after deselection,
and it would be preferable not to make the individual events reference
counted.

I'm sure I'll figure something out though.

Cheers
Hamish

Other related posts: