alibaba/ali_kernel — pull request #69 by gnehzuil (2014-08-10 09:57:32+00:00)
Title: tcp: fix FIONREAD/SIOCINQ

tcp_ioctl() tries to take into account if tcp socket received a FIN
to report correct number bytes in receive queue.

But its flaky because if the application ate the last skb,
we return 1 instead of 0.

Correct way to detect that FIN was received is to test SOCK_DONE.

[Note From Zheng Liu]
We must backport this patch because in 2.6.32-358 kernel this bug does
not be fixed and it would cause an infinite loop in MySQL client. So
it will burn some CPU cycles when a user wants to connect to a MySQL
server.

This patch should be removed in next version because in 2.6.32-431
kernel this bug has been fixed.

Reference: a3374c42aa5f7237e87ff3b0622018636b0c847e
Patch-mainline: v3.7-rc1-115-ga3374c4
Reported-by: Elliot Hughes
Signed-off-by: Eric Dumazet
Cc: Neal Cardwell
Cc: Tom Herbert
Signed-off-by: David S. Miller
Signed-off-by: Zheng Liu