aio_connect ?
Igor Sysoev
is at rambler-co.ru
Fri Oct 22 13:25:37 PDT 2004
On Thu, 21 Oct 2004, Ronald F. Guilmette wrote:
> >I believe if you want to build a more maintainable, more adaptable,
> >more modularized program then you should avoid two things - the threads and
> >the signals. If you like to use a callback behaviour of the signals you could
> >easy implement it without any signal.
>
> OK. I'll bite. How?
I'm sure you know it. Sorry, English is not my native language so I may
tell you only shortly.
You can use two notification models. First is the socket readiness
for operations, second is the operation completeness.
In the first model you use usual read()/write() operations and learn
readiness using select()/poll()/kevent().
In the second model you use aio_read()/aio_write() operations and learn
about their completeness using aio_suspend()/aio_waitcomplete()/kevent().
After you have got the notifications you would call your callback handlers
as well as the kernel would call your signal handlers.
The difference between your code and kernel is that your code always
calls handlers in the well known places that allows to avoid the various race
conditions. The kernel may call the signal handler any time if the signal
is not blocked.
Igor Sysoev
http://sysoev.ru/en/
More information about the freebsd-net
mailing list