Don't defer errors from sendmmsg(). This matches the linux manpage.

Defer errors from recvmmsg() through so_rerror and
tests and return a deferred error on entry.

Ok: christos@
This commit is contained in:
hannken 2018-11-07 09:59:12 +00:00
parent 45fa9d7920
commit b26dcce64a

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_syscalls.c,v 1.197 2018/09/03 16:29:35 riastradh Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.198 2018/11/07 09:59:12 hannken Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.197 2018/09/03 16:29:35 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.198 2018/11/07 09:59:12 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_pipe.h"
@ -806,14 +806,11 @@ sys_sendmmsg(struct lwp *l, const struct sys_sendmmsg_args *uap,
}
*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;
@ -1052,6 +1049,16 @@ sys_recvmmsg(struct lwp *l, const struct sys_recvmmsg_args *uap,
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;
@ -1116,13 +1123,14 @@ sys_recvmmsg(struct lwp *l, const struct sys_recvmmsg_args *uap,
m_free(from);
*retval = dg;
if (error)
so->so_error = error;
so->so_rerror = 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)