Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/uipc_syscalls.c
Show First 20 Lines • Show All 478 Lines • ▼ Show 20 Lines | sys_connect(struct thread *td, struct connect_args *uap) | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa) | kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa) | ||||
{ | { | ||||
struct socket *so; | struct socket *so; | ||||
struct file *fp; | struct file *fp; | ||||
int error, interrupted = 0; | int error; | ||||
#ifdef CAPABILITY_MODE | #ifdef CAPABILITY_MODE | ||||
if (IN_CAPABILITY_MODE(td) && (dirfd == AT_FDCWD)) | if (IN_CAPABILITY_MODE(td) && (dirfd == AT_FDCWD)) | ||||
return (ECAPMODE); | return (ECAPMODE); | ||||
#endif | #endif | ||||
AUDIT_ARG_FD(fd); | AUDIT_ARG_FD(fd); | ||||
AUDIT_ARG_SOCKADDR(td, dirfd, sa); | AUDIT_ARG_SOCKADDR(td, dirfd, sa); | ||||
Show All 21 Lines | #endif | ||||
if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) { | if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) { | ||||
error = EINPROGRESS; | error = EINPROGRESS; | ||||
goto done1; | goto done1; | ||||
} | } | ||||
SOCK_LOCK(so); | SOCK_LOCK(so); | ||||
while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { | while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { | ||||
error = msleep(&so->so_timeo, &so->so_lock, PSOCK | PCATCH, | error = msleep(&so->so_timeo, &so->so_lock, PSOCK | PCATCH, | ||||
"connec", 0); | "connec", 0); | ||||
if (error != 0) { | if (error != 0) | ||||
if (error == EINTR || error == ERESTART) | |||||
interrupted = 1; | |||||
break; | break; | ||||
} | } | ||||
} | |||||
if (error == 0) { | if (error == 0) { | ||||
error = so->so_error; | error = so->so_error; | ||||
so->so_error = 0; | so->so_error = 0; | ||||
} | } | ||||
SOCK_UNLOCK(so); | SOCK_UNLOCK(so); | ||||
bad: | bad: | ||||
if (!interrupted) | |||||
so->so_state &= ~SS_ISCONNECTING; | |||||
if (error == ERESTART) | if (error == ERESTART) | ||||
error = EINTR; | error = EINTR; | ||||
done1: | done1: | ||||
fdrop(fp, td); | fdrop(fp, td); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
▲ Show 20 Lines • Show All 1,083 Lines • Show Last 20 Lines |