> This goes pear-shaped as follows: > > * The SSL connection is made and used > * The remote side closes its file descriptor (e.g. process killed, > TCP shutdown(RD)) > * Local SSL_read() returns 0. The app event loop sets a flag and > makes sure it never calls SSL_read() again. > * The app event loop prepares for poll() by calling SSL_want_read() > and SSL_want_write(). > * SSL_want_read() returns 'true'. This is erroneous. > * poll() returns immediately. > * Repeat the last 3 steps indefinitely. Uses 100% CPU.
The application is broken. Once SSL_read returns 0, the connection is dead. > I see three ways to slice this: > > * Say "Silly OpenSSL API user! You should have known/guessed that > you can't use SSL_want_read() / SSL_want_write() anymore after > SSL_read() has returned 0." You can't use them that way. You can call them if you want. SSL_want_read is the correct indication, telling you that you can make SSL calls as soon as the socket is readable, which it already is. There is nothing to wait for, SSL_want_read returning true or false are equally valid, since the socket is readable. > This does not seem reasonable, because as far as I can see this > rule is not mentioned in the API documentation for SSL_read() or > SSL_want_read(). Right? What do you think SSL_want_read should return in this case? The choices are true or false and you don't like true. So I'm guessing you think false. But if the socket is readable, your call will return immediately. Isn't that what SSL_want_read=true means? > * The OpenSSL documentation can be updated to mention this. I suppose so, but I don't see much point. > * The OpenSSL code can be updated to handle this nicely: make sure > SSL_want_read() and SSL_want_write() return false, and wait for > the application to call SSL_write() sooner or later, which will > return an error as normal. At that moment the non-blocking > application can be expected to "get the idea" and clean up the > connection smoothly. The application may never call SSL_write. It may have already sent all the data it ever plans to send. This is not a sensible plan. If both SSL_want_read and SSL_want_write are false, the application will never make the forward progress that it can make. The socket is already readable, and the only progress that can ever be made requires nothing more than that the socket be readable. DS ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]