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.1421.1.2, 2003-11-11 00:11:54-02:00, acme@conectiva.com.br o SCTP: use sk_wait_event primitive socket.c | 60 ++++++++++++++++-------------------------------------------- 1 files changed, 16 insertions(+), 44 deletions(-) diff -Nru a/net/sctp/socket.c b/net/sctp/socket.c --- a/net/sctp/socket.c Sat Nov 15 17:03:03 2003 +++ b/net/sctp/socket.c Sat Nov 15 17:03:03 2003 @@ -3941,14 +3941,22 @@ prepare_to_wait_exclusive(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); + /* + * Let another process have a go if the receive_queue is empty. Since + * we are going to sleep anyway. + * + * Note: This may cause odd behaviors if the message does not fit in + * the user's buffer, but this seems to be the only way to honor + * MSG_DONTWAIT realistically. + */ + if (sk_wait_event(sk, timeo_p, !skb_queue_empty(&sk->sk_receive_queue))) + goto ready; + /* Socket errors? */ error = sock_error(sk); if (error) goto out; - if (!skb_queue_empty(&sk->sk_receive_queue)) - goto ready; - /* Socket shut down? */ if (sk->sk_shutdown & RCV_SHUTDOWN) goto out; @@ -3965,16 +3973,6 @@ /* Handle signals. */ if (signal_pending(current)) goto interrupted; - - /* Let another process have a go. Since we are going to sleep - * anyway. Note: This may cause odd behaviors if the message - * does not fit in the user's buffer, but this seems to be the - * only way to honor MSG_DONTWAIT realistically. - */ - sctp_release_sock(sk); - *timeo_p = schedule_timeout(*timeo_p); - sctp_lock_sock(sk); - ready: finish_wait(sk->sk_sleep, &wait); return 0; @@ -4160,7 +4158,6 @@ { struct sock *sk = asoc->base.sk; int err = 0; - long current_timeo = *timeo_p; DEFINE_WAIT(wait); SCTP_DEBUG_PRINTK("wait_for_sndbuf: asoc=%p, timeo=%ld, msg_len=%d\n", @@ -4180,17 +4177,8 @@ goto do_error; if (signal_pending(current)) goto do_interrupted; - if (msg_len <= sctp_wspace(asoc)) + if (sk_wait_event(sk, timeo_p, msg_len <= sctp_wspace(asoc))) break; - - /* Let another process have a go. Since we are going - * to sleep anyway. - */ - sctp_release_sock(sk); - current_timeo = schedule_timeout(current_timeo); - sctp_lock_sock(sk); - - *timeo_p = current_timeo; } out: @@ -4255,7 +4243,6 @@ { struct sock *sk = asoc->base.sk; int err = 0; - long current_timeo = *timeo_p; DEFINE_WAIT(wait); SCTP_DEBUG_PRINTK("%s: asoc=%p, timeo=%ld\n", __FUNCTION__, asoc, @@ -4277,17 +4264,8 @@ if (signal_pending(current)) goto do_interrupted; - if (sctp_state(asoc, ESTABLISHED)) + if (sk_wait_event(sk, timeo_p, sctp_state(asoc, ESTABLISHED))) break; - - /* Let another process have a go. Since we are going - * to sleep anyway. - */ - sctp_release_sock(sk); - current_timeo = schedule_timeout(current_timeo); - sctp_lock_sock(sk); - - *timeo_p = current_timeo; } out: @@ -4324,11 +4302,7 @@ prepare_to_wait_exclusive(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); - if (list_empty(&ep->asocs)) { - sctp_release_sock(sk); - timeo = schedule_timeout(timeo); - sctp_lock_sock(sk); - } + sk_wait_event(sk, &timeo, !list_empty(&ep->asocs)); err = -EINVAL; if (!sctp_sstate(sk, LISTENING)) @@ -4358,11 +4332,9 @@ do { prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); - if (list_empty(&sctp_sk(sk)->ep->asocs)) + if (sk_wait_event(sk, &timeout, + list_empty(&sctp_sk(sk)->ep->asocs))) break; - sctp_release_sock(sk); - timeout = schedule_timeout(timeout); - sctp_lock_sock(sk); } while (!signal_pending(current) && timeout); finish_wait(sk->sk_sleep, &wait); =================================================================== This BitKeeper patch contains the following changesets: 1.1421.1.2 ## Wrapped with gzip_uu ## M'XL( &=XMC\ \65;V_B1A#&7WL_Q50G7<,5S.[Z#\97HN1"=!IDO,;+Y3?J8+?UK1P+W6--!=Z@*[=6YWNI+=$FU'^K$O&&7<*9LM88>5 M23WA!P]O[&&#J7=__?[S[>4]8X,!7"U5N< 16A@,F-753JUGYD+9Y5J7OJU4 M:0JTKO;Q(?4H.9?TB40OX%%\%#$/>\=,S(10H< 9EV$2AZR6=O%G^8\I@:"+ M"Q&*X,AY'$9L",(7H:2'+X$'72'H!LY3(=(H['"9<@[/DN$' 1W.WL&_NXHK MEH&&T=7X+H6M03"KR5[E=H([+"ULJKS(202RGT $,F9W?SC*.G_S8HPKSL[A MMP51BPNKMZO<_Y)O?+4U-B_]?%JX)=!6=TUF-^XQ,3I;H?6S9CV)Z$L1!:$X M\E#$_:,*N9B+WBP.>[U$!-'SWIT@3VC-[A!3\J.,^B)T'?,DM>Z<_U(R,U5^ ML37/L!YI)91(@ECTCCR)HJ^=1,URVD0\225_H8EBZ(3A_]A&C=.?H%/MW4U] M_ !1GF9H>/L:4:%-"2EH]3C-+'ZWL!T M.Y]CU:9HZ35A#6)A:@53='FZ7!^ 1-2OEKK4E2/\/'H_&7[Z./[E\F9,RU/K MG%HU4^MU([;+/))Q]FB#Z%L;;%Z@GFS:\)U931L_)LZ,L]=FU3FG"8^\:K5: MS/,6FFI3D=GA+?N5#6D+^A#4,4Y <#:DCJ<]J6-2QYNOT7M)0V$6DS66\., MW)':FXW*\$Q1?]2%:UX$?8HR2AQ?)MSQF_@BOSFG5MF&V8;KT?CRW>W-Z,/U ML"D@$^D*!+('$8�#CP4^AK1R7?:J>_68:;SGE--JW6VYH2"R>OCO(OY36D MK6U3AN_P6R)VA[ #!P