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

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: default avatarSebastian Smolorz <>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
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;
if (ts->is_closed) {
return -EBADF;
Supports Markdown
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