[openbeosnetteam] Yet another select() support fix. again.

Axel wrote:
> True. Anyway, I don't understand how you'll want to use the release 
> count to report anything back, bug using a semaphore for select() 
> seems to be the right way (the other would be a port).


In on_socket_event callback(selectsync * sync, uint32 ref):
sem_id select_wakeup_sem = (sem_id) sync;
release_sem_etc(select_wakeup_sem, ref);

In select(), after a successfull acquire_sem(select_wakeup_sem), I get the sem 
sem count => -ref, then delete it.

The "ref" is a magic number:
fd of the socket selected() << 8 | select event to monitor (read = 1, write = 
2, exception = 3). I pass it to net_stack_[de]select() via ioctl().
In fact, BONE select() send a similar build 'ref' value ;-)

That way, by looking at sem count, I could know which fd and on what event 
wakeup select(). Without needing to pass any fd_set data to kernel land!

Downside: One and only one fd/event will be return by select().
But if it works, it's way better than net_server select() support...

-Philippe.

Other related posts: