why arriving packets just before tcp_data_wait() will not be ignored?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I am reading 2.4.22 kernel code on TCP/IP networking. And I don't
understand why the following scenario will not occur:

1. user thread calls read which in turn calls tcp_recvmsg() on an
established socket
2. tcp_recvmsg() sees that no data is available on receive_queue,
installs prequeue
3. tcp_recvmsg() continues and prepare to sleep because it has not
seen any data, but it has not entered tcp_data_wait() yet.
4. suddenly at this moment a packet comes in
5. the bottom half calls bh_lock_sock, see that sock->lock.users == 1,
adds the packet to  backlog queue
6. the bottom half exits
7. tcp_recvmsg calls tcp_data_wait() to sleep
8. in release_sock() of tcp_data_wait, backlog queue is processed by
tcp_v4_do_rcv() which calls tcp_rcv_established()
9. in tcp_rcv_established(), as prequeue is installed, packets are
directly copied to user context and nothing gets queued to
sk->receive_queue, so eaten == 1
10.  at the end of tcp_rcv_established(), because eaten == 1,
sk->data_ready(sk, 0); is *not* called
11. backlog queue processing finished, return to release_sock in step 8.
12. continue tcp_data_wait() in step 7, see that receive_queue is
NULL, goes to sleep

If the above situation occurs, the user thread waiting for data will
go to sleep even though incoming packets have been processed and data
have been copied. Obviously it was not the case. I wonder at which
step did I miss something.

Thanks a lot.
Wen

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux