Re: Bug with FIONREAD for TCP?

From: kuznet@ms2.inr.ac.ru
Date: Tue Apr 11 2000 - 13:28:54 EST


Hello!

> I've been using this technique for nearly 10 years, and FIONREAD has
> always yielded 0 bytes readable on close

Please, check this.

Alexey

--- ../vger3-000409/linux/net/ipv4/tcp.c Sun Apr 9 18:45:19 2000
+++ linux/net/ipv4/tcp.c Tue Apr 11 21:43:40 2000
@@ -583,9 +583,13 @@
                         answ = 0;
                 else if (sk->urginline || !tp->urg_data ||
                          before(tp->urg_seq,tp->copied_seq) ||
- !before(tp->urg_seq,tp->rcv_nxt))
+ !before(tp->urg_seq,tp->rcv_nxt)) {
                         answ = tp->rcv_nxt - tp->copied_seq;
- else
+
+ /* Subtract 1, if FIN is in queue. */
+ if (answ && !skb_queue_empty(&sk->receive_queue))
+ answ -= ((struct sk_buff*)sk->receive_queue.prev)->h.th->fin;
+ } else
                         answ = tp->urg_seq - tp->copied_seq;
                 release_sock(sk);
                 break;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:16 EST