On Sat, 29 Sep 2007, Thor Lancelot Simon wrote: > On Sat, Sep 29, 2007 at 03:11:18PM -0700, Davide Libenzi wrote: > > > > Heh? Wait for read&write? Consider such code: > > > > for (;;) { > > err = SSL_shutdown(); > > code = SSL_get_error(ssl, err); > > if (code == SSL_ERROR_SYSCALL) { > > select(SSL_get_fd(ssl), RDWR); > > This is not how select() works, but I assume you know that and are > intentionally writing pseudocode. However, what it elides is that, > generally, applications using select() for nonblocking I/O are managing > many sockets at once. In practice, selecting on one of those sockets in > both directions when you only care about one direction is almost zero > cost.
Yes, I think I know something about select(2), poll(2), and handling many sockets at a time ;) That was obviously pseudocode. Handling many sockets at a time does not change the picture though. You'll permanently exit your I/O scheduler because you get for an event that the underline API is not waiting for. In the multiple socket example it can be even worse, since you can have the fd array setup/teardown costs. > Obviously, if you're shutting down, and the socket's returned ready for > write once, you select only for read; the corresponsing condition is true > in the opposite direction. > > Yes, it's a stupid API. Yes, it's a nuisance to work around it. But > changing it is _still_ going to break people's code that switches on what > were, previously, the only possible error codes that could be returned > during a shutdown -- which didn't include WANT_READ and WANT_WRITE. > > I can easily fix the code _I_ care about to conform to the (better) API > you're proposing. But I don't think that's a particularly good reason to > break other people's code, and pretending that it was impossible to get > the job done isn't tremendously helpful either; there really is a lot of > code out there already that uses non-blocking BIOs despite all their > warts (see my complaints about the need for SSL_select() from several > months ago for another example) and that code really, truly does manage > to shut down sessions without spinning. I seriously doubt ppl are using SSL_shutdown() with non-blocking BIOs, together with the current API semantics. Seriously. - Davide ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]