kern/84761: shutdown() of non-connected socket should fail with
ENOTCONN
Maxim Konovalov
maxim at macomnet.ru
Wed Aug 10 18:00:34 GMT 2005
The following reply was made to PR kern/84761; it has been noted by GNATS.
From: Maxim Konovalov <maxim at macomnet.ru>
To: James Juran <James.Juran at baesystems.com>
Cc: bug-followup at freebsd.org, rwarson at freebsd.org
Subject: Re: kern/84761: shutdown() of non-connected socket should fail with
ENOTCONN
Date: Wed, 10 Aug 2005 21:57:44 +0400 (MSD)
Hi,
[...]
> Calling shutdown(2) on a non-connected socket should fail with ENOTCONN
> according to the manpage. Instead, it succeeds.
Indeed, Linux 2.4 and Solaris 9 return ENOTCONN. It seems all BSDs
don't.
> >How-To-Repeat:
> Run this program. It should hit the perror(), but instead prints
> "shutdown succeeded".
Here is a patch but I'm not sure about it and CC'ed rwatson at . Robert,
what do you think?
Index: uipc_socket.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.242
diff -u -p -r1.242 uipc_socket.c
--- uipc_socket.c 1 Jul 2005 16:28:30 -0000 1.242
+++ uipc_socket.c 10 Aug 2005 17:20:39 -0000
@@ -1428,7 +1428,8 @@ soshutdown(so, how)
if (!(how == SHUT_RD || how == SHUT_WR || how == SHUT_RDWR))
return (EINVAL);
-
+ if ((so->so_state & SS_ISCONNECTED) == 0)
+ return (ENOTCONN);
if (how != SHUT_WR)
sorflush(so);
if (how != SHUT_RD)
%%%
--
Maxim Konovalov
More information about the freebsd-bugs
mailing list