-/* $OpenBSD: connect.c,v 1.1 2011/09/18 16:36:58 fgsch Exp $ */
+/* $OpenBSD: connect.c,v 1.2 2016/08/09 02:25:35 guenther Exp $ */
/*
* Federico G. Schwindt <fgsch@openbsd.org>, 2011. Public Domain.
*/
sa.sin_port = htons(23);
sa.sin_addr.s_addr = htonl(0xc7b98903); /* cvs.openbsd.org */
ASSERT(connect(s, (struct sockaddr *)&sa, sizeof(sa)) == -1);
- return ((caddr_t)NULL + errno);
+ int err = errno;
+ ASSERT(connect(s, (struct sockaddr *)&sa, sizeof(sa)) == -1);
+ ASSERT(errno == EALREADY);
+ return ((caddr_t)NULL + err);
}
int
-/* $OpenBSD: uipc_syscalls.c,v 1.132 2016/05/18 01:13:13 millert Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.133 2016/08/09 02:25:35 guenther Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
struct file *fp;
struct socket *so;
struct mbuf *nam = NULL;
- int error, s;
+ int error, s, interrupted = 0;
if ((error = getsock(p, SCARG(uap, s), &fp)) != 0)
return (error);
so = fp->f_data;
- if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
+ if (so->so_state & SS_ISCONNECTING) {
FRELE(fp, p);
return (EALREADY);
}
s = splsoftnet();
while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
error = tsleep(&so->so_timeo, PSOCK | PCATCH, "netcon2", 0);
- if (error)
+ if (error) {
+ if (error == EINTR || error == ERESTART)
+ interrupted = 1;
break;
+ }
}
if (error == 0) {
error = so->so_error;
}
splx(s);
bad:
- so->so_state &= ~SS_ISCONNECTING;
+ if (!interrupted)
+ so->so_state &= ~SS_ISCONNECTING;
FRELE(fp, p);
if (nam)
m_freem(nam);