diff mbox

net/net: Bugfix for net_fill_rstate()

Message ID 1471437202-6134-1-git-send-email-zhangchen.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhang Chen Aug. 17, 2016, 12:33 p.m. UTC
When network is busy, we will receive multiple packets
at one time. this bug will lost packets that comes late.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
 net/net.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Li Zhijian Aug. 18, 2016, 1:31 a.m. UTC | #1
> /*
>  * Returns
>  * 0: SocketReadState is not ready
>  * 1: SocketReadState is ready
>  * otherwise error occurs
>  */
> int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size)

it seems you need to fix the returns and comments too.
simply, just remove the 'return 1;' would be OK ?
because the callers only concern about the error case.
Zhang Chen Aug. 18, 2016, 3:13 a.m. UTC | #2
On 08/18/2016 09:31 AM, Li Zhijian wrote:
>> /*
>>  * Returns
>>  * 0: SocketReadState is not ready
>>  * 1: SocketReadState is ready
>>  * otherwise error occurs
>>  */
>> int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size)
>
> it seems you need to fix the returns and comments too.
> simply, just remove the 'return 1;' would be OK ?
> because the callers only concern about the error case.

OK, I got your point, will fix it in V2.
diff mbox

Patch

diff --git a/net/net.c b/net/net.c
index a8e2e6b..8f3237e 100644
--- a/net/net.c
+++ b/net/net.c
@@ -1636,7 +1636,9 @@  int net_fill_rstate(SocketReadState *rs, const uint8_t *buf, int size)
                 if (rs->finalize) {
                     rs->finalize(rs);
                 }
-                return 1;
+                if (!size) {
+                    return 1;
+                }
             }
             break;
         }