mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-23 22:56:00 +00:00
Fix broken MSG_PEEK on TCP sockets (post-2.0.3 bug)
MSG_PEEK on TCP sockets was broken since commit b71d4477ea
from 06.03.2017: recv hung in an endless loop and tcp_recved() was called for peeked data
(which would result in a too large window advertised).
Aded TCP MSG_PEEK to socket unit tests
This commit is contained in:
parent
d99144eef1
commit
f5c37c8cbb
|
@ -926,9 +926,9 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
|
||||||
/* once we have some data to return, only add more if we don't need to wait */
|
/* once we have some data to return, only add more if we don't need to wait */
|
||||||
apiflags |= NETCONN_DONTBLOCK;
|
apiflags |= NETCONN_DONTBLOCK;
|
||||||
/* @todo: do we need to support peeking more than one pbuf? */
|
/* @todo: do we need to support peeking more than one pbuf? */
|
||||||
} while ((recv_left > 0) || (flags & MSG_PEEK));
|
} while ((recv_left > 0) && !(flags & MSG_PEEK));
|
||||||
lwip_recv_tcp_done:
|
lwip_recv_tcp_done:
|
||||||
if (recvd > 0) {
|
if ((recvd > 0) && !(flags & MSG_PEEK)) {
|
||||||
/* ensure window update after copying all data */
|
/* ensure window update after copying all data */
|
||||||
netconn_tcp_recvd(sock->conn, (size_t)recvd);
|
netconn_tcp_recvd(sock->conn, (size_t)recvd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,12 @@ static void test_sockets_allfunctions_basic_domain(int domain)
|
||||||
|
|
||||||
while(tcpip_thread_poll_one());
|
while(tcpip_thread_poll_one());
|
||||||
|
|
||||||
|
ret = lwip_recv(s2, buf, 3, MSG_PEEK);
|
||||||
|
fail_unless(ret == 3);
|
||||||
|
|
||||||
|
ret = lwip_recv(s2, buf, 3, MSG_PEEK);
|
||||||
|
fail_unless(ret == 3);
|
||||||
|
|
||||||
ret = lwip_read(s2, buf, 4);
|
ret = lwip_read(s2, buf, 4);
|
||||||
fail_unless(ret == 4);
|
fail_unless(ret == 4);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user