Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iscsi/icl_soft_proxy.c
Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | |||||
static MALLOC_DEFINE(M_ICL_PROXY, "ICL_PROXY", "iSCSI common layer proxy"); | static MALLOC_DEFINE(M_ICL_PROXY, "ICL_PROXY", "iSCSI common layer proxy"); | ||||
int | int | ||||
icl_soft_proxy_connect(struct icl_conn *ic, int domain, int socktype, | icl_soft_proxy_connect(struct icl_conn *ic, int domain, int socktype, | ||||
int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa) | int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa) | ||||
{ | { | ||||
struct socket *so; | struct socket *so; | ||||
int error; | int error; | ||||
int interrupted = 0; | |||||
error = socreate(domain, &so, socktype, protocol, | error = socreate(domain, &so, socktype, protocol, | ||||
curthread->td_ucred, curthread); | curthread->td_ucred, curthread); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
if (from_sa != NULL) { | if (from_sa != NULL) { | ||||
error = sobind(so, from_sa, curthread); | error = sobind(so, from_sa, curthread); | ||||
if (error != 0) { | if (error != 0) { | ||||
soclose(so); | soclose(so); | ||||
return (error); | return (error); | ||||
} | } | ||||
} | } | ||||
error = soconnect(so, to_sa, curthread); | error = soconnect(so, to_sa, curthread); | ||||
if (error != 0) { | if (error != 0) { | ||||
soclose(so); | soclose(so); | ||||
return (error); | return (error); | ||||
} | } | ||||
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, SOCK_MTX(so), PSOCK | PCATCH, | error = msleep(&so->so_timeo, SOCK_MTX(so), PSOCK | PCATCH, | ||||
"icl_connect", 0); | "icl_connect", 0); | ||||
if (error) { | if (error) | ||||
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); | ||||
if (error != 0) { | if (error != 0) { | ||||
▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines |