Commit 55db9eea authored by Sebastian Smolorz via Xenomai's avatar Sebastian Smolorz via Xenomai Committed by Jan Kiszka

net/tcp: return already copied number of bytes to recv() callers when peer socket terminates

In the following situation a recv() call to a RT-TCP socket returned 0
although there was data already copied to the caller's buffer:

- S1 connects to S2
- S1 calls recv() with buffer size b1
- S2 sends data of size b2 < b1
- S1 receives the data, copies it to its buffer and waits for more data
- S2 terminates the connection
- S1 receives the FIN packet and also starts its shutdown procedure
     which includes returning from the recv() call. But instead of
     returning the number of bytes which were already copied
     it returned 0.
Signed-off-by: 's avatarSebastian Smolorz <sebastian.smolorz@gmx.de>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 1c7ea64d
......@@ -1909,6 +1909,11 @@ static ssize_t rt_tcp_read(struct rtdm_fd *fd, void *buf, size_t nbyte)
return (copied ? copied : ret);
case -EIDRM: /* event is destroyed */
if (ts->is_closed)
return -EBADF;
return copied;
default:
if (ts->is_closed) {
return -EBADF;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment