summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2018-02-11 21:53:58 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2018-02-11 21:53:58 +0000
commit991f7a496071f2d3cb8d770319afa2b0022e3860 (patch)
treefa0bc23f0997a92e794ed145e6cfa13b2ac7e19d
parent5fc7769b531581717ae10e1e215b139eda584ff5 (diff)
Revert rev 1.163. Causes network issues in Firefox.
ok mpi@ who will investigate.
-rw-r--r--sys/kern/uipc_syscalls.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index fb83d1bc1f6..d63412a6751 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.163 2018/02/09 07:32:35 mpi Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.164 2018/02/11 21:53:57 matthieu Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -83,7 +83,7 @@ sys_socket(struct proc *p, void *v, register_t *retval)
struct file *fp;
int type = SCARG(uap, type);
int domain = SCARG(uap, domain);
- int fd, cloexec, nonblock, fflag, error;
+ int fd, error;
unsigned int ss = 0;
if ((type & SOCK_DNS) && !(domain == AF_INET || domain == AF_INET6))
@@ -95,24 +95,23 @@ sys_socket(struct proc *p, void *v, register_t *retval)
if (error)
return (error);
- type &= ~(SOCK_CLOEXEC | SOCK_NONBLOCK | SOCK_DNS);
- cloexec = (SCARG(uap, type) & SOCK_CLOEXEC) ? UF_EXCLOSE : 0;
- nonblock = SCARG(uap, type) & SOCK_NONBLOCK;
- fflag = FREAD | FWRITE | (nonblock ? FNONBLOCK : 0);
-
- error = socreate(SCARG(uap, domain), &so, type, SCARG(uap, protocol));
+ fdplock(fdp);
+ error = falloc(p, (type & SOCK_CLOEXEC) ? UF_EXCLOSE : 0, &fp, &fd);
+ fdpunlock(fdp);
if (error != 0)
goto out;
- fdplock(fdp);
- error = falloc(p, cloexec, &fp, &fd);
- fdpunlock(fdp);
+ fp->f_flag = FREAD | FWRITE | (type & SOCK_NONBLOCK ? FNONBLOCK : 0);
+ fp->f_type = DTYPE_SOCKET;
+ fp->f_ops = &socketops;
+ error = socreate(SCARG(uap, domain), &so,
+ type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK | SOCK_DNS), SCARG(uap, protocol));
if (error) {
- soclose(so);
+ fdplock(fdp);
+ fdremove(fdp, fd);
+ closef(fp, p);
+ fdpunlock(fdp);
} else {
- fp->f_flag = fflag;
- fp->f_type = DTYPE_SOCKET;
- fp->f_ops = &socketops;
if (type & SOCK_NONBLOCK)
so->so_state |= SS_NBIO;
so->so_state |= ss;