tcp: recv returns 0 without set errno

Issue:
recv return 0  means peer side has already closed the connection according to
man page's description.
0 is returned without set errno when TCP rx timeout happens with current
design.

Solution:
return result instead of ir_result when ir_result is 0, then -1 will be
returned with errno set to EAGAIN for tcp rx buffer empty case.

Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
This commit is contained in:
liangchaozhong 2022-11-23 15:27:15 +08:00 committed by Xiang Xiao
parent 39a567db20
commit 0ec4b0a149
1 changed files with 1 additions and 1 deletions

View File

@ -555,7 +555,7 @@ static ssize_t tcp_recvfrom_result(int result, struct tcp_recvfrom_s *pstate)
* handler error is prioritized over any previous error.
*/
return (pstate->ir_result <= 0) ? pstate->ir_result : result;
return (pstate->ir_result < 0) ? pstate->ir_result : result;
}
/****************************************************************************