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.6, 2003-11-13 01:10:25-02:00, acme@conectiva.com.br o NET: introduce sk_wait_data This abstracts away more struct sock handling that previously was being open coded, in some cases not doing all the required operations, like setting the SOCK_ASYNC_WAITDATA bit on the struct socket flags. include/net/sock.h | 11 +++++++---- net/core/sock.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) diff -Nru a/include/net/sock.h b/include/net/sock.h --- a/include/net/sock.h Sat Nov 15 17:01:58 2003 +++ b/include/net/sock.h Sat Nov 15 17:01:58 2003 @@ -396,14 +396,17 @@ extern void sk_flush_backlog(struct sock *sk); #define sk_wait_event(__sk, __timeo, __condition) \ -({ int rc; \ +({ int __rc; \ release_sock(__sk); \ - rc = __condition; \ - if (!rc) \ + __rc = __condition; \ + if (!__rc) \ *(__timeo) = schedule_timeout(*(__timeo)); \ lock_sock(__sk); \ - rc; \ + __rc; \ }) + +extern int __sk_wait_data(struct sock *sk, long *timeo); +extern int sk_wait_data(struct sock *sk, long timeo); /* IP protocol blocks we attach to sockets. * socket layer -> transport layer interface diff -Nru a/net/core/sock.c b/net/core/sock.c --- a/net/core/sock.c Sat Nov 15 17:01:58 2003 +++ b/net/core/sock.c Sat Nov 15 17:01:58 2003 @@ -905,6 +905,58 @@ EXPORT_SYMBOL(sk_flush_backlog); /* + * Now socket state including sk->sk_err is changed only under lock, + * hence we may omit checks after joining wait queue. + * We check receive queue before schedule() only as optimization; + * it is very likely that release_sock() added new data. + */ +int __sk_wait_data(struct sock *sk, long *timeo) +{ + int rc; + DEFINE_WAIT(wait); + + prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); + set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); + rc = !skb_queue_empty(&sk->sk_receive_queue); + sk_wait_event(sk, timeo, rc); + clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); + finish_wait(sk->sk_sleep, &wait); + return rc; +} + +EXPORT_SYMBOL(__sk_wait_data); + +int sk_wait_data(struct sock *sk, long timeo) +{ + int rc; + + while (1) { + /* + * POSIX 1003.1g mandates this order. + */ + if (sk->sk_err) { + rc = sock_error(sk); + break; + } + rc = 0; + if (sk->sk_shutdown & RCV_SHUTDOWN) + break; + rc = -EAGAIN; + if (!timeo) + break; + rc = sock_intr_errno(timeo); + if (signal_pending(current)) + break; + rc = 0; + if (__sk_wait_data(sk, &timeo)) + break; + } + return rc; +} + +EXPORT_SYMBOL(sk_wait_data); + +/* * Set of default routines for initialising struct proto_ops when * the protocol does not support a particular function. In certain * cases where it makes no sense for a protocol to have a "do nothing" =================================================================== This BitKeeper patch contains the following changesets: 1.1422.1.6 ## Wrapped with gzip_uu ## M'XL( "9XMC\ ^U7:V_:2!3];/^*6U6J2!;,C!^\HE2E"=NB9DD$9-M*E:QA M/ E>C(?:X[#9DO^^=\8DA91L-E$_EB"#?)]SSCW7Y"6HT@'AU2NO4 T([E'3)8DF$- )KX6<28B'90Q% M7@EMKDC;;WJ/]A.G/"DBH255YIENM>2W5GZ[%9 5:Q)&6XPUN1L(WFP^T-/N M=%MMM5J-P,CQ1]_'=?G<=A\0Z(/MDC9I4R]HKE"G7LLHU6_?URAM_K=&FU#S M?VGTYVG43,XIU+*E>:/DSG8,T3.$>^RUVT#M?OE1^68ALA"&&3^PS.N+?>P3 M"J[=]XF+'Y:VP2&Z(.E1K,]YL':TX@NHO-#VO8W80&\[R>D!Y MNY<7RB[ 5(U50##6R,ZC3Y5=\.O9^'-U9QXD]W1WC[]GB*[?)DT(7!OV82"7 MMT5SQ918JUIWG<]JKQ%ED66 P')#&AXS1;"*-!(93C6?5762J4B1D:6 .4(N MYW@J/A5\AAQ=X>_/:X,X>AE6,Y$(9"O4Y\)P%B&1B-H2]*SH MTG7[J5JWO]EF,^'^L*WCWN_]0<_06-'QJ&G]+#8 OG),19J.R8$8R\3618JKTVLZ&CS!Y\ MD<\FH0$N%/.%NJ["9MYHA9]HPN+I#;?/K@ MD4VC0A6X)C5V-XA4[]/9Z7 QTU/\$%!>=0R]Q2E-,BVI6>F/(#&?9,7YUO.J'R/?)+].44.OR M^I[,T$&?R[(FF6 S_>W&7CN1@^T<^;10D5RF\ J&1W^&H_?GX^/3CX.]K6@3 M6>MUWW7[@]OX%^OC_>!GVM![4/>2RLKM8V5=-KY,61+B M,:KO BRY#NO1UY M[CJ]KP/$]U69="OJYA$B?Z 1P;_[C[#