Module Name:    src
Committed By:   hannken
Date:           Wed Nov 14 17:51:37 UTC 2018

Modified Files:
        src/sys/compat/linux/common: linux_socket.c
        src/sys/compat/netbsd32: netbsd32_socket.c

Log Message:
Apply the recent fixes to {send,recv}mmsg() to their compat variants.


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.48 -r1.49 src/sys/compat/netbsd32/netbsd32_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.142 src/sys/compat/linux/common/linux_socket.c:1.143
--- src/sys/compat/linux/common/linux_socket.c:1.142	Thu May 10 01:32:24 2018
+++ src/sys/compat/linux/common/linux_socket.c	Wed Nov 14 17:51:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.142 2018/05/10 01:32:24 ozaki-r Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.143 2018/11/14 17:51:37 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.142 2018/05/10 01:32:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.143 2018/11/14 17:51:37 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1801,14 +1801,11 @@ linux_sys_sendmmsg(struct lwp *l, const 
 	}
 
 	*retval = dg;
-	if (error)
-		so->so_error = error;
 
 	fd_putfile(s);
 
 	/*
-	 * If we succeeded at least once, return 0, hopefully so->so_error
-	 * will catch it next time.
+	 * If we succeeded at least once, return 0.
 	 */
 	if (dg)
 		return 0;
@@ -1849,6 +1846,16 @@ linux_sys_recvmmsg(struct lwp *l, const 
 	if ((error = fd_getsock(s, &so)) != 0)
 		return error;
 
+	/*
+	 * If so->so_rerror holds a deferred error return it now.
+	 */
+	if (so->so_rerror) {
+		error = so->so_rerror;
+		so->so_rerror = 0;
+		fd_putfile(s);
+		return error;
+	}
+
 	vlen = SCARG(uap, vlen);
 	if (vlen > 1024)
 		vlen = 1024;
@@ -1919,17 +1926,17 @@ linux_sys_recvmmsg(struct lwp *l, const 
 		m_free(from);
 
 	*retval = dg;
-	if (error)
-		so->so_error = error;
-
-	fd_putfile(s);
 
 	/*
-	 * If we succeeded at least once, return 0, hopefully so->so_error
+	 * If we succeeded at least once, return 0, hopefully so->so_rerror
 	 * will catch it next time.
 	 */
-	if (dg)
-		return 0;
+	if (error && dg > 0) {
+		so->so_rerror = error;
+		error = 0;
+	}
+
+	fd_putfile(s);
 
 	return error;
 }

Index: src/sys/compat/netbsd32/netbsd32_socket.c
diff -u src/sys/compat/netbsd32/netbsd32_socket.c:1.48 src/sys/compat/netbsd32/netbsd32_socket.c:1.49
--- src/sys/compat/netbsd32/netbsd32_socket.c:1.48	Mon Nov 12 06:53:43 2018
+++ src/sys/compat/netbsd32/netbsd32_socket.c	Wed Nov 14 17:51:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_socket.c,v 1.48 2018/11/12 06:53:43 maxv Exp $	*/
+/*	$NetBSD: netbsd32_socket.c,v 1.49 2018/11/14 17:51:37 hannken Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.48 2018/11/12 06:53:43 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_socket.c,v 1.49 2018/11/14 17:51:37 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -289,6 +289,16 @@ netbsd32_recvmmsg(struct lwp *l, const s
 	if ((error = fd_getsock(s, &so)) != 0)
 		return error;
 
+	/*
+	 * If so->so_rerror holds a deferred error return it now.
+	 */
+	if (so->so_rerror) {
+		error = so->so_rerror;
+		so->so_rerror = 0;
+		fd_putfile(s);
+		return error;
+	}
+
 	vlen = SCARG(uap, vlen);
 	if (vlen > 1024)
 		vlen = 1024;
@@ -350,17 +360,17 @@ netbsd32_recvmmsg(struct lwp *l, const s
 		m_free(from);
 
 	*retval = dg;
-	if (error)
-		so->so_error = error;
-
-	fd_putfile(s);
 
 	/*
-	 * If we succeeded at least once, return 0, hopefully so->so_error
+	 * If we succeeded at least once, return 0, hopefully so->so_rerror
 	 * will catch it next time.
 	 */
-	if (dg)
-		return 0;
+	if (error && dg > 0) {
+		so->so_rerror = error;
+		error = 0;
+	}
+
+	fd_putfile(s);
 
 	return error;
 }
@@ -597,14 +607,11 @@ netbsd32_sendmmsg(struct lwp *l, const s
 	}
 
 	*retval = dg;
-	if (error)
-		so->so_error = error;
 
 	fd_putfile(s);
 
 	/*
-	 * If we succeeded at least once, return 0, hopefully so->so_error
-	 * will catch it next time.
+	 * If we succeeded at least once, return 0.
 	 */
 	if (dg)
 		return 0;

Reply via email to