On Thu, Mar 20, 2008 at 6:51 PM, David Schwartz <[EMAIL PROTECTED]>
wrote:

>
>      ready_sockets = ::select(m_max_socket + 1, rfds, 0, 0,&tv);
>      if (ready_sockets > 0)
>      {
>         if (FD_ISSET(s->get_sock(),p->get_rfds()))
>         {
>            new_s->set_non_blocking(true);
>            if (s->accept(new_s))
>            {
>                       call the code above which will call SSL_accept
>            }
>            else
>            {
>             /*error handling*/
>            }
>
> Where is the call to 'accept' (the system's 'accept')? Did you cut out a
> line before 'new_s->set_non_blocking'? Is 's->accept(new_s)' a wrapper
> around 'accept'? Can you paste the code to this wrapper?


Yes the 's->accept(new_s)' is a wrapper around the system 'accept'. Here is
the code for it:


bool csocket::accept ( csocket * new_socket ) const
{
    int addr_length = sizeof ( m_addr );
    new_socket->m_sock_fd = ::accept ( m_sock_fd, ( sockaddr * ) &m_addr, (
socklen_t * ) &addr_length );
    if ( new_socket->m_sock_fd <= 0 )
    {
        return false;
    }
    else
    {
        return true;
    }
}

So as you can see if accept returns EMFILE or ENFILE, I go immediately to
the "error handling" section.


I have added BIO_set_nbio call to my code following your advice :

          m_sbio = BIO_new_socket(m_sock_fd, BIO_NOCLOSE);
        BIO_set_nbio(m_sbio,1);
          SSL_set_bio(m_ssl, m_sbio, m_sbio);


Unfortunately this did not make a difference and SSL_accept still hangs,
sometimes after processing more than a 1000 clients...

Thanks again.


>
>
> > I am setting the socket as non blocking by simply calling:
>
>                if (fcntl(m_sock_fd, F_SETFL, O_NONBLOCK) == -1)
>                {
>                        return false;
>                }
>
> This does not make the BIO non-blocking. That may or may not matter, but
> to
> tell I need to see where the actual call to the system's 'accept' function
> is taking place. And you still haven't pasted that code.
>
> > I am confused when you say if my BIO is non-blocking too.
> > I thought that it is non blocking since the underlying socket
> > is non blocking. Is this a wrong assumption? if so how can I make
> > the BIO non blocking [BIO_set_nbio?]
>
> Right. A blocking BIO with a non-blocking socket can cause serious
> problems.
>
> Where is the actual call to 'accept' to accept the connection? What
> happens
> if 'accept' returns EMFILE or ENFILE?
>
> DS
>
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           [EMAIL PROTECTED]
>

Reply via email to