Commit d6538729 authored by Sridhar Samudrala's avatar Sridhar Samudrala

[SCTP] Use prepare_to_wait()/finish_wait() interfaces.

parent 0c336e6d
...@@ -3295,10 +3295,9 @@ SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *msg, ...@@ -3295,10 +3295,9 @@ SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *msg,
static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p) static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p)
{ {
int error; int error;
DECLARE_WAITQUEUE(wait, current); DEFINE_WAIT(wait);
__set_current_state(TASK_INTERRUPTIBLE); prepare_to_wait_exclusive(sk->sleep, &wait, TASK_INTERRUPTIBLE);
add_wait_queue_exclusive(sk->sleep, &wait);
/* Socket errors? */ /* Socket errors? */
error = sock_error(sk); error = sock_error(sk);
...@@ -3335,16 +3334,14 @@ static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p) ...@@ -3335,16 +3334,14 @@ static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p)
sctp_lock_sock(sk); sctp_lock_sock(sk);
ready: ready:
remove_wait_queue(sk->sleep, &wait); finish_wait(sk->sleep, &wait);
__set_current_state(TASK_RUNNING);
return 0; return 0;
interrupted: interrupted:
error = sock_intr_errno(*timeo_p); error = sock_intr_errno(*timeo_p);
out: out:
remove_wait_queue(sk->sleep, &wait); finish_wait(sk->sleep, &wait);
__set_current_state(TASK_RUNNING);
*err = error; *err = error;
return error; return error;
} }
...@@ -3522,18 +3519,18 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p, ...@@ -3522,18 +3519,18 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
struct sock *sk = asoc->base.sk; struct sock *sk = asoc->base.sk;
int err = 0; int err = 0;
long current_timeo = *timeo_p; long current_timeo = *timeo_p;
DECLARE_WAITQUEUE(wait, current); DEFINE_WAIT(wait);
SCTP_DEBUG_PRINTK("wait_for_sndbuf: asoc=%p, timeo=%ld, msg_len=%d\n", SCTP_DEBUG_PRINTK("wait_for_sndbuf: asoc=%p, timeo=%ld, msg_len=%d\n",
asoc, (long)(*timeo_p), msg_len); asoc, (long)(*timeo_p), msg_len);
/* Wait on the association specific sndbuf space. */
add_wait_queue_exclusive(&asoc->wait, &wait);
/* Increment the association's refcnt. */ /* Increment the association's refcnt. */
sctp_association_hold(asoc); sctp_association_hold(asoc);
/* Wait on the association specific sndbuf space. */
for (;;) { for (;;) {
set_current_state(TASK_INTERRUPTIBLE); prepare_to_wait_exclusive(&asoc->wait, &wait,
TASK_INTERRUPTIBLE);
if (!*timeo_p) if (!*timeo_p)
goto do_nonblock; goto do_nonblock;
if (sk->err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING || if (sk->err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING ||
...@@ -3555,12 +3552,11 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p, ...@@ -3555,12 +3552,11 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
} }
out: out:
remove_wait_queue(&asoc->wait, &wait); finish_wait(&asoc->wait, &wait);
/* Release the association's refcnt. */ /* Release the association's refcnt. */
sctp_association_put(asoc); sctp_association_put(asoc);
__set_current_state(TASK_RUNNING);
return err; return err;
do_error: do_error:
...@@ -3618,18 +3614,17 @@ static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p) ...@@ -3618,18 +3614,17 @@ static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p)
struct sock *sk = asoc->base.sk; struct sock *sk = asoc->base.sk;
int err = 0; int err = 0;
long current_timeo = *timeo_p; long current_timeo = *timeo_p;
DECLARE_WAITQUEUE(wait, current); DEFINE_WAIT(wait);
SCTP_DEBUG_PRINTK("%s: asoc=%p, timeo=%ld\n", __FUNCTION__, asoc, SCTP_DEBUG_PRINTK("%s: asoc=%p, timeo=%ld\n", __FUNCTION__, asoc,
(long)(*timeo_p)); (long)(*timeo_p));
add_wait_queue_exclusive(&asoc->wait, &wait);
/* Increment the association's refcnt. */ /* Increment the association's refcnt. */
sctp_association_hold(asoc); sctp_association_hold(asoc);
for (;;) { for (;;) {
__set_current_state(TASK_INTERRUPTIBLE); prepare_to_wait_exclusive(&asoc->wait, &wait,
TASK_INTERRUPTIBLE);
if (!*timeo_p) if (!*timeo_p)
goto do_nonblock; goto do_nonblock;
if (sk->shutdown & RCV_SHUTDOWN) if (sk->shutdown & RCV_SHUTDOWN)
...@@ -3654,13 +3649,11 @@ static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p) ...@@ -3654,13 +3649,11 @@ static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p)
} }
out: out:
remove_wait_queue(&asoc->wait, &wait); finish_wait(&asoc->wait, &wait);
/* Release the association's refcnt. */ /* Release the association's refcnt. */
sctp_association_put(asoc); sctp_association_put(asoc);
__set_current_state(TASK_RUNNING);
return err; return err;
do_error: do_error:
...@@ -3680,14 +3673,14 @@ static int sctp_wait_for_accept(struct sock *sk, long timeo) ...@@ -3680,14 +3673,14 @@ static int sctp_wait_for_accept(struct sock *sk, long timeo)
{ {
struct sctp_endpoint *ep; struct sctp_endpoint *ep;
int err = 0; int err = 0;
DECLARE_WAITQUEUE(wait, current); DEFINE_WAIT(wait);
ep = sctp_sk(sk)->ep; ep = sctp_sk(sk)->ep;
add_wait_queue_exclusive(sk->sleep, &wait);
for (;;) { for (;;) {
__set_current_state(TASK_INTERRUPTIBLE); prepare_to_wait_exclusive(sk->sleep, &wait, TASK_INTERRUPTIBLE);
if (list_empty(&ep->asocs)) { if (list_empty(&ep->asocs)) {
sctp_release_sock(sk); sctp_release_sock(sk);
timeo = schedule_timeout(timeo); timeo = schedule_timeout(timeo);
...@@ -3711,8 +3704,7 @@ static int sctp_wait_for_accept(struct sock *sk, long timeo) ...@@ -3711,8 +3704,7 @@ static int sctp_wait_for_accept(struct sock *sk, long timeo)
break; break;
} }
remove_wait_queue(sk->sleep, &wait); finish_wait(sk->sleep, &wait);
__set_current_state(TASK_RUNNING);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment