Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F135706343
D3039.id6838.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D3039.id6838.diff
View Options
Index: sys/kern/uipc_socket.c
===================================================================
--- sys/kern/uipc_socket.c
+++ sys/kern/uipc_socket.c
@@ -2334,6 +2334,9 @@
if (!(how == SHUT_RD || how == SHUT_WR || how == SHUT_RDWR))
return (EINVAL);
+ if ((so->so_state &
+ (SS_ISCONNECTED | SS_ISCONNECTING | SS_ISDISCONNECTING)) == 0)
+ return (ENOTCONN);
CURVNET_SET(so->so_vnet);
if (pr->pr_usrreqs->pru_flush != NULL)
Index: sys/kern/uipc_syscalls.c
===================================================================
--- sys/kern/uipc_syscalls.c
+++ sys/kern/uipc_syscalls.c
@@ -1383,6 +1383,15 @@
if (error == 0) {
so = fp->f_data;
error = soshutdown(so, uap->how);
+ /*
+ * Previous versions did not return ENOTCONN, but 0 in
+ * case the socket was not connected. Some important
+ * programs like syslogd up to r279016, 2015-02-19,
+ * still depend on this behavior.
+ */
+ if (error == ENOTCONN &&
+ td->td_proc->p_osrel < P_OSREL_SHUTDOWN_ENOTCONN)
+ error = 0;
fdrop(fp, td);
}
return (error);
Index: sys/sys/param.h
===================================================================
--- sys/sys/param.h
+++ sys/sys/param.h
@@ -77,12 +77,13 @@
#define __FreeBSD_kernel__
#ifdef _KERNEL
-#define P_OSREL_SIGWAIT 700000
-#define P_OSREL_SIGSEGV 700004
-#define P_OSREL_MAP_ANON 800104
-#define P_OSREL_MAP_FSTRICT 1100036
+#define P_OSREL_SIGWAIT 700000
+#define P_OSREL_SIGSEGV 700004
+#define P_OSREL_MAP_ANON 800104
+#define P_OSREL_MAP_FSTRICT 1100036
+#define P_OSREL_SHUTDOWN_ENOTCONN 1100077
-#define P_OSREL_MAJOR(x) ((x) / 100000)
+#define P_OSREL_MAJOR(x) ((x) / 100000)
#endif
#ifndef LOCORE
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 13, 1:59 AM (12 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25240194
Default Alt Text
D3039.id6838.diff (1 KB)
Attached To
Mode
D3039: Make shutdown() return ENOTCONN as required by POSIX, part deux.
Attached
Detach File
Event Timeline
Log In to Comment