> Hi David,

> My code looks like this:

1 while(1)
2 {
3 r = SSL_accept(m_ssl);
4 if (r > 0)
5 {
6 break;
7 }
8 r = ssl_retry(r);
9 if ( r <= 0)
10 {
11 break;
12 }
13 }

Well, that's obviously badly broken. It's probably not precisely your issue,
but it's related. Since the socket is non blocking, there is no place for
this code to block waiting for the connection!

> The issue is not that it is going into an infinite while loop.

That's just pure luck.

> The issue is that SSL_accept on line 3 never returns!.
> My socket is a non blocking one so as far as I know
> SSL_accept should return.

How did you make it non blocking exactly? And is the BIO non-blocking too?

> A backtrace shows that when this happen the server gets stuck in:

> SSL_accept
> after calling SSL_accept.

Sounds like you're lucky. The BIO is actually blocking and that's saving
your code from looping. At least you're not burning the CPU.

What is your design intention if 'accept' returns EMFILE or ENFILE? If your
answer is "I have no idea" or "I never really thought about it", then it's
no surprise your code mishandles this case.


__________________________________________________ ____________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majordomo@openssl.org