SSL_CTX_set_mode(ssl, SSL_MODE_AUTO_RETRY);

2009/3/30 Nikos Balkanas <nbalka...@gmail.com>:
> Hi,
>
> I would like to ideally use non-blocking SSL_read and blocking SSL_write. Is
> this possible with BIO_set_nbio? What should the underlying socket be in
> that case?
>
> If this is not possible, as I suspect, i have the problem that the
> non-blocking SSL_write with select, will stall after first SSL_error of
> SSL_ERROR_WANT_READ || SSL_ERROR_WANT_WRITE without ever writing the data:
>
> while(((select(fd + 1, NULL, &rset, NULL, &alarm)) > 0) && FD_ISSET(fd,
> &rset))
> {
>       res = SSL_write(ssl, input, len);
>       if (res == -1)
>       {
>                SSL_error = SSL_get_error(ssl, res);
>                 printf("SSL_error = %d\n", SSL_error);
>                 if (SSL_error != SSL_ERROR_WANT_READ && SSL_error !=
> SSL_ERROR_WANT_WRITE)
>                     return(-1);
>                 else FD_CLR(fd, &rset);
>        }
>        else return(res);
> }
>
> My only solution so far has been to use the non-blocking SSL_write as a
> blocking one, but it is terribly inefficient, looping as many as 50
> times before writing the data:
>
> while((ret = SSL_write(ssl, request->data, request->len)) < 0)
> {
>         SSL_error = SSL_get_error(ssl, ret);
>         if (SSL_error != SSL_ERROR_WANT_READ && SSL_error !=
> SSL_ERROR_WANT_WRITE)
>                break;
>         thr_yield();
> }
>
> Any ideas?
> TIA, Nikos
>
>

Reply via email to