> Hmm...interesting.  Essentially what you are saying is "If one thinks
> they need to use select() on a blocking socket, use non-blocking sockets
> instead.  And only when non-blocking sockets are insufficient, use
> select() (i.e. to avoid a CPU-eating polling type of situation without
> sacrificing I/O performance that would be associated with sleep())."

> Yes?  If so, the above paragraph or something similar should be
> documented somewhere important (e.g. the manpages).

That's one way to put what I'm saying. I agree it needs to be repeated more
often, that's one of the reasons I repeat it as often as I can.

> The "many have
> tried, failed, and caused real problems" issue you state indicates
> public documentation is not clear.  The discussion of a SSL_select()
> comes up every so often on this list and I believe this very issue is
> the root cause.

> Not every day I learn something new.  Though I'm slightly horrified
> because my code base is extensive and I do quite a bit of socket
> programming...and I've been doing it wrong for about 7 years.  This is
> apparently going to be a LONG weekend.

Sorry. I can tell you a few stories about people who assumed that they could
write code that never blocked and then when some strange combination of
events violated their assumptions, their code blocked, and their program
failed.

The Linux UDP inetd denial-of-service attack was one such failure.
Denial-of-service attacks on 'accept' are similar.

Now, as far as I know, there has never been a problem with a TCP read
blocking after a read hit on select (unless another process/thread grabs the
data, obviously). It's hard to imagine how that could ever be a problem in
the future either. But both of the examples I mention started out with the
same type of thinking. At the time that code was written, there was no way
it could fail either.

A TCP write is *always* a problem. Even setting the low water mark won't
save you because the low water mark is not set in *application* bytes, it's
set in *queue* bytes. And no law requires a one-to-one relationship between
them. I can't imagine a way a one-byte TCP write could block after a
'select' hit, but who knows, maybe someone will find a way to shrink the
window or something.

DS


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to