You can import this changeset into BK by piping this whole message to: '| bk receive [path to repository]' or apply the patch as usual. =================================================================== ChangeSet@1.1422.1.17, 2003-11-14 21:41:48-02:00, acme@conectiva.com.br o SCTP: use sk_wait_error socket.c | 90 +++++++++++++++++---------------------------------------------- 1 files changed, 25 insertions(+), 65 deletions(-) diff -Nru a/net/sctp/socket.c b/net/sctp/socket.c --- a/net/sctp/socket.c Sat Nov 15 17:00:41 2003 +++ b/net/sctp/socket.c Sat Nov 15 17:00:41 2003 @@ -3936,7 +3936,7 @@ */ static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p) { - int error; + int error = 0; DEFINE_WAIT(wait); prepare_to_wait_exclusive(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); @@ -3950,10 +3950,9 @@ * MSG_DONTWAIT realistically. */ if (sk_wait_event(sk, timeo_p, !skb_queue_empty(&sk->sk_receive_queue))) - goto ready; + goto out; - /* Socket errors? */ - error = sock_error(sk); + error = sk_wait_error(sk, *timeo_p); if (error) goto out; @@ -3969,17 +3968,7 @@ /* Is there a good reason to think that we may receive some data? */ if (list_empty(&sctp_sk(sk)->ep->asocs) && !sctp_sstate(sk, LISTENING)) goto out; - - /* Handle signals. */ - if (signal_pending(current)) - goto interrupted; -ready: - finish_wait(sk->sk_sleep, &wait); - return 0; - -interrupted: - error = sock_intr_errno(*timeo_p); - + error = 0; out: finish_wait(sk->sk_sleep, &wait); *err = error; @@ -4157,7 +4146,7 @@ int msg_len) { struct sock *sk = asoc->base.sk; - int err = 0; + int err; DEFINE_WAIT(wait); SCTP_DEBUG_PRINTK("wait_for_sndbuf: asoc=%p, timeo=%ld, msg_len=%d\n", @@ -4170,17 +4159,18 @@ for (;;) { prepare_to_wait_exclusive(&asoc->wait, &wait, TASK_INTERRUPTIBLE); - if (!*timeo_p) - goto do_nonblock; - if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING || + err = sk_wait_error(sk, *timeo_p); + if (err) + goto out; + err = -EPIPE; + if (asoc->state >= SCTP_STATE_SHUTDOWN_PENDING || asoc->base.dead) - goto do_error; - if (signal_pending(current)) - goto do_interrupted; + goto out; if (sk_wait_event(sk, timeo_p, msg_len <= sctp_wspace(asoc))) break; } + err = 0; out: finish_wait(&asoc->wait, &wait); @@ -4188,18 +4178,6 @@ sctp_association_put(asoc); return err; - -do_error: - err = -EPIPE; - goto out; - -do_interrupted: - err = sock_intr_errno(*timeo_p); - goto out; - -do_nonblock: - err = -EAGAIN; - goto out; } /* If socket sndbuf has changed, wake up all per association waiters. */ @@ -4242,7 +4220,7 @@ static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p) { struct sock *sk = asoc->base.sk; - int err = 0; + int err; DEFINE_WAIT(wait); SCTP_DEBUG_PRINTK("%s: asoc=%p, timeo=%ld\n", __FUNCTION__, asoc, @@ -4254,20 +4232,18 @@ for (;;) { prepare_to_wait_exclusive(&asoc->wait, &wait, TASK_INTERRUPTIBLE); - if (!*timeo_p) - goto do_nonblock; - if (sk->sk_shutdown & RCV_SHUTDOWN) - break; - if (sk->sk_err || asoc->state >= SCTP_STATE_SHUTDOWN_PENDING || + err = sk_wait_error(sk, *timeo_p); + if (err || (sk->sk_shutdown & RCV_SHUTDOWN)) + goto out; + err = -ECONNREFUSED; + if (asoc->state >= SCTP_STATE_SHUTDOWN_PENDING || asoc->base.dead) - goto do_error; - if (signal_pending(current)) - goto do_interrupted; - + goto out; if (sk_wait_event(sk, timeo_p, sctp_state(asoc, ESTABLISHED))) break; } + err = 0; out: finish_wait(&asoc->wait, &wait); @@ -4275,18 +4251,6 @@ sctp_association_put(asoc); return err; - -do_error: - err = -ECONNREFUSED; - goto out; - -do_interrupted: - err = sock_intr_errno(*timeo_p); - goto out; - -do_nonblock: - err = -EINPROGRESS; - goto out; } static int sctp_wait_for_accept(struct sock *sk, long timeo) @@ -4304,6 +4268,10 @@ sk_wait_event(sk, &timeo, !list_empty(&ep->asocs)); + err = sk_wait_error(sk, timeo); + if (err) + break; + err = -EINVAL; if (!sctp_sstate(sk, LISTENING)) break; @@ -4311,14 +4279,6 @@ err = 0; if (!list_empty(&ep->asocs)) break; - - err = sock_intr_errno(timeo); - if (signal_pending(current)) - break; - - err = -EAGAIN; - if (!timeo) - break; } finish_wait(sk->sk_sleep, &wait); @@ -4335,7 +4295,7 @@ if (sk_wait_event(sk, &timeout, list_empty(&sctp_sk(sk)->ep->asocs))) break; - } while (!signal_pending(current) && timeout); + } while (!__sk_wait_error(timeout)); finish_wait(sk->sk_sleep, &wait); } =================================================================== This BitKeeper patch contains the following changesets: 1.1422.1.17 ## Wrapped with gzip_uu ## M'XL( -EWMC\ [U5;6_:,!#^'/^*FRI-[3:"SW9>H*+J!JQ%FRB"=OLR*4J# M*1D-9HEI-2G[[W-,R^@+FUIM@XA#>7QWS_/QFZC,/<\-,%3* /6IRF2].EL_G['Z7.H:+0VO$6J4O(._*Z--$E P M:I\.FK L)!2SZ#I.=23S7.7D U2\/3+XY22I/?%%"(TI.8"O%WF:98=:+6>I M^RU=N/&RT.G<3<\SR]R,N%XD>F$_HD(E,ZG=9"4CQ 9#CPLLJ4"_4<:"X@2# ML2^"($3N/6[91LF-:M54!#.UT"\%#5#837EPM-J8?TEYRP)MI8Q5349+YC4, M9;M(%.^O$/J_7R'F0=":05JJ5>8!\QB?H7=YMUAOUO,WL KG69218L]FQ4P M0%LR9)MI53LS:5JUNXFW="P2<. 5$GC@&2+F]I]Z.4XZ@5T#[9FO&\QODVO= M06_0O3T7&Q]K!X6.M82#EIU&-#I]>]J-1L=GIYV3S_UHT.UW>OTC*$M+*+@A M9)W;;&!NAOQ&VUI9 P'-+YA@PK,25W%3(O,"(\T@/CY9HN$$!C0"9E$Q7>JQ MNI[#2QBV/ZWI[VVUH7W2[P^[[\]&W)Y-)0TS(3P$[&1UN!P