mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stelian Pop <stelian.pop@fr.alcove.com>
To: "David S. Miller" <davem@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: socket write(2) after remote shutdown(2) problem ?
Date: Fri, 5 Apr 2002 14:00:55 +0200	[thread overview]
Message-ID: <20020405120054.GF16595@come.alcove-fr> (raw)
In-Reply-To: <20020405104733.GD16595@come.alcove-fr> <20020405.024435.88131177.davem@redhat.com> <20020405105509.GE16595@come.alcove-fr> <20020405.030251.28451401.davem@redhat.com>

On Fri, Apr 05, 2002 at 03:02:51AM -0800, David S. Miller wrote:

>    From: Stelian Pop <stelian.pop@fr.alcove.com>
>    Date: Fri, 5 Apr 2002 12:55:09 +0200
>    
>    > 	* client socket receives a TCP reset
>    
>    How is the client socket supposed to know it received a TCP reset
>    (I am talking from the application point of view, not the kernel...) ?
> 
> You may find out by attempting to read data, or you may use the
> extended IP error reporting Linux has.

In the client, I've added a read(fd, buf, 1) just after the write,
and rerun:

	client				server

	...				...
					shutdown()
	...		
lsof will shown the client socket being in CLOSE_WAIT at this point
					...
	write(fd, buf, 5) = 5
	read(fd, buf, 1) = 0
	...
	exit(0)
					exit(0)

As you can see, read() doesn't return any error, just 0 to 
indicate end-of-file (seems correct interpretation of remote
shutdown here), but it doesn't report any error from the 
precedent write... Bug ?

> But all of this is irrelevant.  When a server closes and says "send me
> no more data", this implies that the server told the client it doesn't
> want any more data.

Perfectly valid but only if the 'applicative close' has reached the
other end. If it's still queued in TCP buffers, the client may not
have received yet that close... I thought that this was the only
reason that shutdown() existed at all: flush the buffers preparing
an imminent close...

> If the client sends data, this is a gross fatal
> error, so TCP resets in FIN_WAIT{1,2} states.
> 
> RFC 793 originally specified to queue the data, RFC 1122 is where
> the current behavior is defined.

Thanks for the pointer. 

Stelian.
-- 
Stelian Pop <stelian.pop@fr.alcove.com>
Alcove - http://www.alcove.com

  reply	other threads:[~2002-04-05 12:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-05  9:50 Stelian Pop
2002-04-05 10:04 ` David S. Miller
2002-04-05 10:47   ` Stelian Pop
2002-04-05 10:44     ` David S. Miller
2002-04-05 10:55       ` Stelian Pop
2002-04-05 11:02         ` David S. Miller
2002-04-05 12:00           ` Stelian Pop [this message]
2002-04-05 12:04             ` David S. Miller
2002-04-05 12:23               ` Stelian Pop
2002-04-05 12:59               ` Stelian Pop
     [not found] <20020405104733.GD16595@come.alcove-fr.suse.lists.linux.kernel>
     [not found] ` <20020405.024435.88131177.davem@redhat.com.suse.lists.linux.kernel>
     [not found]   ` <20020405105509.GE16595@come.alcove-fr.suse.lists.linux.kernel>
     [not found]     ` <20020405.030251.28451401.davem@redhat.com.suse.lists.linux.kernel>
2002-04-05 11:47       ` Andi Kleen

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=20020405120054.GF16595@come.alcove-fr \
    --to=stelian.pop@fr.alcove.com \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®