lkml.org 
[lkml]   [1999]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject2.2: data loss after socket close
Hello,

after porting an application to Linux i have found a bug
in 2.2's socket close() code for TCP connections (LINUX 2.0 is OK):

The sender writes some bytes and closes the socket.
The receiver waits in select() until there is something
to read, calls recv() and gets ECONNRESET ("Connection reset by peer")
instead of the last bytes written by the sender.

The ported application works well with HPUX, AIX, Solaris, SCO, SINIX,
NT (with some #ifdefs) AND Linux 2.0.36.

I tried to get around this problem with SOL_LINGER (which is
actually used in NT only). It did not change anything.

I searched for a problem report in dejanews and found one article
describing exactly the same problem (see below) with no answer.

I tested with 2.2.0, 2.2.5-22 (RedHat 6.0), 2.2.10 and 2.2.11pre3
with the same results. Would it be helpful for someone if i test
with some 2.1.X kernels?

It is no problem for me to insert an "#ifdef LINUX22" in the ipc code of
the application but i cannot find a clean workaround for that problem.

Please mail me if i can help to get that problem fixed. I will try any
patch and any non timely critical workaround (sleep(1) just before the
close() works but it is not a solution for that app).

Thorsten

The article describing the same problem:
--------------------------------------snip----------------------------------
From: neil@ogham.demon.co.uk
Newsgroups: comp.unix.programmer
Subject: Problem with socket closure in Linux 2.2 kernel?
Date: Sat, 17 Jul 1999 10:57:32 GMT
Message-ID: <932209052.25606.0.nnrp-02.c2de0bc0@news.demon.co.uk>

Hi

I've noticed that when TCP sockets are closed (in C code) using the close()
call in a program running under a 2.2 kernel, occasionally not all the
remaining data is sent to the remote host. Setting the SO_LINGER option via
setsockopt makes no difference and the only way to solve the problem is to
use the shutdown() function, but since this is non blocking this would
require some sort of program timer to be written that makes the program go
back and close the socket once this has expired to free up the file
descriptor (calling close() immediately after a shutdown has the same
effect as just calling the close on its own).

The programs I've seen this behaviour on have run with no problems under
2.0 kernels and earlier not to mention solaris , hp-ux, osf/1 , aix and
sequent dynix so I suspect there may be something wrong with TCP in 2.2
If I'm wrong please tell me a way around this problem because its becoming
annoying.

Thanks in advance.

NJR
--------------------------------------snip----------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.027 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site