From: Nicolas Cannasse <ncannasse@motion-twin.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: linux-net@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: recv() hangs until SIGCHLD ?
Date: Mon, 13 Oct 2008 10:31:46 +0200 [thread overview]
Message-ID: <48F30772.7040207@motion-twin.com> (raw)
In-Reply-To: <48F063C5.3000707@motion-twin.com>
>> If there is data and the thread didn't wake up then that is a libc or
>> kernel problem;
>> but if there is no data, then look for cases where earlier interrupted
>> io actually
>> consumed the data already or blame the sending process not the receiver.
>> Also are the sockets blocking or non-blocking?
>
> The sockets are non-blocking.
Sorry, I made a spelling mistake here.
I wanted to tell that the sockets ARE blocking (default behavior).
> In a practical case, we have a thread blocked in recv() for more than 12
> hours, which is way beyond the timeout of the sender connection. The
> socket has already been closed by the sender so recv() should at least
> be noticed and returns 0.
To provide more informations :
Doing a lsof on the receiver, we can see that it has several ESTABLISHED
sockets connected to a given host/sender. Doing a lsof on the host does
not give any socket connected to the receiver (since they have been
closed due to a timeout).
Also, the application correctly handles 0.
The pseudo-code is the following :
loop:
ret = recv()
if( ret == -1 ) {
if( errno == EINTR ) goto loop;
return -1;
}
return ret;
Then, on the higher level, in case we get an error ( ret <= 0 ) then we
close the socket.
At first, we were using the libmysqlclient but since we had the bug with
it we rewrote a mysql client so we can more easily check what's
occurring. The same bug seems to occur with both implementations.
Best,
Nicolas
next prev parent reply other threads:[~2008-10-13 8:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-10 13:30 recv() hangs until SIGCHLD ? Nicolas Cannasse
2008-10-10 19:17 ` Stephen Hemminger
2008-10-11 8:28 ` Nicolas Cannasse
2008-10-11 12:20 ` David Schwartz
2008-10-12 15:47 ` Stephen Hemminger
2008-10-13 8:31 ` Nicolas Cannasse [this message]
2008-10-13 15:02 ` Nicolas Cannasse
-- strict thread matches above, loose matches on Subject: below --
2008-10-10 16:43 Nicolas Cannasse
2008-10-11 4:48 ` David Schwartz
2008-10-11 9:30 ` Samuel Thibault
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48F30772.7040207@motion-twin.com \
--to=ncannasse@motion-twin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net@vger.kernel.org \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox