This is a discussion on Re: SSL_poll() or _select()? - Openssl ; On Sun, Apr 15, 2007 at 12:54:16AM -0700, Nickolai Zeldovich wrote: > > One reason, as suggested by Thor, is that OpenSSL sometimes needs to > wait on more complex events than just socket read or write. In > particular, ...
On Sun, Apr 15, 2007 at 12:54:16AM -0700, Nickolai Zeldovich wrote:
> One reason, as suggested by Thor, is that OpenSSL sometimes needs to
> wait on more complex events than just socket read or write. In
> particular, some hardware appears to require the use of kevent to
> signal completion of crypto operations. It seems fairly natural,
> then, to express these wait predicates in terms of a struct kevent.
Well, just to be clear, the hardware I was using as an example uses
kevents because I made its device driver use kevents. It used to use
a device-specific system call for non-blocking I/O, like some others do --
and of course *that* meant you couldn't actually cleanly integrate it into
a set of events to wait on at all, if the other events in that set are
file-descriptor events. Yuck.
Anyway, I picked it as an example because I thought it demonstrated
reasonably nicely that if you have the library implement the select()
or poll() then you can still handle more complex waiting and notification
inside the library -- you can transform the user's fdset or pollfd into
whatever's appropriate for the mechanism you need to use to deal with
your crypto device, and dispatch it that way. When you return from wait
you can internally consume events for some of the things you were waiting
on, do more system calls, go back to sleep, etc.
I think Nickolai's idea of filtering events via a callback would work
but I'm concerned about exporting kevent as an interface to OpenSSL
because it's not very portable. I don't know how to best add a callback
to select() or poll() this way -- there's not really anywhere to put it.
Perhaps it could be returned by the routine that adds the SSL library's
fd's to the set?
I agree that composability is a good goal here but I do still think that
since most applications won't want to compose select or poll the simpler
interface I was suggesting would still be useful. It's trivial to
implement and it's better than what's there now (nothing).
I have been trying to remember how (if at all) other event-driven
libraries for Unix deal with this -- Xt in particular. But it's been a
very, very long time...
OpenSSL Project http://www.openssl.org
Development Mailing List firstname.lastname@example.org
Automated List Manager email@example.com