<div dir="ltr"><div dir="ltr"><div>Hello,</div><div><br></div><div>And many thanks for the answer.</div><div><br></div><div>"Does the server parent process close its copy of the conversation socket?" : I checked in my code, but it seems that no. Is it needed  ? May it explain my problem ?</div><div><br></div><div>"
Do you have keepalives enabled?" To be honest, I did not know it was possible to not enable them. I checked with command "netstat -tnope" and it tells me that it is not enabled.</div><div><br></div><div>I suppose that, if for some reason, the communication with the client is lost (crash of client, loss of network, etc.) and keepalive is not enabled, this may fully explain my problem ? <br></div><div><br></div><div>If yes, do you have an idea of why keepalive is not enabled ? I thought that by default on linux it was ? <br></div><div><br></div>Many thanks,</div><div>Brice<br></div><div dir="ltr"><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 13 nov. 2020 à 15:43, Michael Wojcik <<a href="mailto:Michael.Wojcik@microfocus.com">Michael.Wojcik@microfocus.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> From: openssl-users <<a href="mailto:openssl-users-bounces@openssl.org" target="_blank">openssl-users-bounces@openssl.org</a>> On Behalf Of Brice André<br>
> Sent: Friday, 13 November, 2020 05:06<br>
<br>
> ... it seems that in some rare execution cases, the server performs a SSL_read,<br>
> the client disconnects in the meantime, and the server never detects the<br>
> disconnection and remains stuck in the SSL_read operation.<br>
<br>
...<br>
<br>
> #0  0x00007f836575d210 in __read_nocancel () from /lib/x86_64-linux-gnu/libpthread.so.0<br>
> #1  0x00007f8365c8ccec in ?? () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1<br>
> #2  0x00007f8365c8772b in BIO_read () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1<br>
<br>
So OpenSSL is in a blocking read of the socket descriptor.<br>
<br>
> tcp        0      0 <a href="http://5.196.111.132:5413" rel="noreferrer" target="_blank">http://5.196.111.132:5413</a>      <a href="http://85.27.92.8:25856" rel="noreferrer" target="_blank">http://85.27.92.8:25856</a>        ESTABLISHED 19218/./MabeeServer<br>
> tcp        0      0 <a href="http://5.196.111.132:5412" rel="noreferrer" target="_blank">http://5.196.111.132:5412</a>      <a href="http://85.27.92.8:26305" rel="noreferrer" target="_blank">http://85.27.92.8:26305</a>        ESTABLISHED 19218/./MabeeServer<br>
<br>
> From this log, I can see that I have two established connections with remote<br>
> client machine on IP 109.133.193.70. Note that it's normal to have two connexions<br>
> because my client-server protocol relies on two distinct TCP connexions.<br>
<br>
So the client has not, in fact, disconnected.<br>
<br>
When a system closes one end of a TCP connection, the stack will send a TCP packet<br>
with either the FIN or the RST flag set. (Which one you get depends on whether the<br>
stack on the closing side was holding data for the conversation which the application<br>
hadn't read.)<br>
<br>
The sockets are still in ESTABLISHED state; therefore, no FIN or RST has been<br>
received by the local stack.<br>
<br>
There are various possibilities:<br>
<br>
- The client system has not in fact closed its end of the conversation. Sometimes<br>
this happens for reasons that aren't immediately apparent; for example, if the<br>
client forked and allowed the descriptor for the conversation socket to be inherited<br>
by the child, and the child still has it open.<br>
<br>
- The client system shut down suddenly (crashed) and so couldn't send the FIN/RST.<br>
<br>
- There was a failure in network connectivity between the two systems, and consequently<br>
the FIN/RST couldn't be received by the local system.<br>
<br>
- The connection is in a state where the peer can't send the FIN/RST, for example<br>
because the local side's receive window is zero. That shouldn't be the case, since<br>
OpenSSL is (apparently) blocked in a receive on the connection. but as I don't have<br>
the complete picture I can't rule it out.<br>
<br>
> This let me think that the connexion on which the SSL_read is listening is<br>
> definitively dead (no more TCP keepalive)<br>
<br>
"definitely dead" doesn't have any meaning in TCP. That's not one of the TCP states,<br>
or part of the other TCP or IP metadata associated with the local port (which is<br>
what matters).<br>
<br>
Do you have keepalives enabled?<br>
<br>
> and that, for a reason I do not understand, the SSL_read keeps blocked into it.<br>
<br>
The reason is simple: The connection is still established, but there's no data to<br>
receive. The question isn't why SSL_read is blocking; it's why you think the<br>
connection is gone, but the stack thinks otherwise.<br>
<br>
> Note that the normal behavior of my application is : client connects, server<br>
> daemon forks a new instance,<br>
<br>
Does the server parent process close its copy of the conversation socket?<br>
<br>
--<br>
Michael Wojcik<br>
</blockquote></div></div>