Ben Laurie wrote:
> 
> Dan Kegel wrote:
> >
> > I'm adding SSL support to my app, and am finding it
> > tedious, partly because of having to figure out how
> > OpenSSL supports nonblocking sockets.
> >
> > demo/state_machine/state_machine.c is better than nothing,
> > but it waves its hands a fair bit,
> 
> Which bits are hand-wavy?

Mostly the bits that are commented as such, e.g. there are
several FIXME's.  Also, there may be a few hidden hand-wavy
parts; using this code in a regression test might flush them out
of hiding.

> > and doesn't actually
> > use nonblocking sockets.
> 
> It doesn't need to! It uses select instead.

To avoid blocking, you *must* use nonblocking I/O even if you use select();
there's no rule saying read() and write() won't block if select()
says they won't; select() can occasionally be wrong, or there might
not be as many bytes available or writable as you expect.  In this program, 
the call 
   read(0, buf, sizeof buf) 
may well block in normal operation -- what if 1024 bytes aren't
available?  

> > If I get up the energy, I might fix up state_machine.c
> > to be a little less hand-wavy, and / or write a program
> > that does a regression test on nonblocking I/O support.
> > (Heh, maybe I'll throw in a test case that demonstrates
> > the bug in SSL_peek that nobody seems to care about :-)
> 
> Which bug is that?

The one I reported on October 7th:
http://www.mail-archive.com/[email protected]/msg06753.html
- Dan

p.s. Richard Stevens' book "Unix Network Programming", Vol 1, 2nd ed,
is a great reference for anyone new to nonblocking I/O.  It's so
good I have to plug it for the benefit of newbies, even if 90%
of the people on this list have already read it.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to