> Moved to openssl-users.

I wish you hadn't done that, because I was not subscribed to openssl-users.
I'm subscribed now, but I hope I haven't missed any messages related to this
between Saturday and today.
 
> On Fri, May 04, 2001 at 06:53:19PM -0400, Harrington, Thomas wrote:
> > I'm trying to do nonblocking writes via OpenSSL.  Initially 
> I cribbed the
> > following from mod_ssl:
> ...
> > But doing a 4kB write, followed by a ~30kB one, the second 
> attempt would
> > consistently fail to write and get -1 back from SSL_write().
> 
> It is not said that the write did fail. You need to call 
> SSL_get_error()
> to find out more details. For nonblocking sockets I would say that the
> "failure" at this point is acceptable, because the 30kB write exceeds
> all internal and system buffer sizes, so that it may not be completed
> in the first attempt. I therefore expect SSL_get_error() to return
> SSL_ERROR_WANT_WRITE. You than select() the socket in question for
> "writable" condition and call SSL_write() again with the same 
> arguments,
> until SSL_write() has finished.

OK, I did forget to mention that I call BIO_sock_should_retry() to see if I
should try and write again, and I do write again, and again, with the same
buffer and with the same failure.

I realize that a write call on a nonblocking socket may not write the data.
But as I said: I only get failures if I set nonblocking using ioctl().  If I
set nonblocking via fcntl(), there's no problem at all.  It's not the fact
that SSL_write() doesn't write immediately that I'm puzzled about, it's the
fact that using fcntl() has a different effect on SSL_write() than using
ioctl() does, and I want to know why.  That's my real question: What
difference does this make with openssl, and why?  My code seems to work OK
right now, but since I'm relying on undocumented behavior I don't really
trust my fix yet.

Because you moved this over to openssl-users, I'll repost the original
question here.  Since I was not subscribed to openssl-users until today, I
can only guess that it was not seen on this list.

----------
I'm trying to do nonblocking writes via OpenSSL.  Initially I cribbed the
following from mod_ssl:

        int iostate = 1;
        rv = ioctl(sock, FIONBIO, (u_long*)&iostate);
        rv = SSL_write(ssl, (char*)buf, len);
        ...
        iostate = 0;
        ioctl(sock, FIONBIO, (u_long*)&iostate);

But doing a 4kB write, followed by a ~30kB one, the second attempt would
consistently fail to write and get -1 back from SSL_write().

If I replace the ioctl() calls with fcntl() calls that should be equivalent,
it works every time.  That is, set nonblocking as follows:

        iostate = fcntl(sock, F_GETFL, 0);
        iostate |= O_NDELAY;
        rv = fcntl(sock, F_SETFL, iostate);

Why do I get different results here?  I dug through the openssl code a bit
and can't see where this should make a difference.  Buggy ioctl function,
maybe?
----------
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to