Skip to content

Commit a69c7a4

Browse files
committed
fix race-condition when remote closes connection while not all outstanding data is read
1 parent 6832d8a commit a69c7a4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

UIPClient.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,14 @@ UIPClient::read(uint8_t *buf, size_t size)
251251
if (uip_stopped(&uip_conns[data->state & UIP_CLIENT_SOCKETS]) && !(data->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_CLOSED)))
252252
data->state |= UIP_CLIENT_RESTART;
253253
if (*p == NOBLOCK)
254-
return size-remain;
254+
{
255+
if (data->state & UIP_CLIENT_CLOSED)
256+
{
257+
data->state = 0;
258+
data = NULL;
259+
}
260+
return size-remain;
261+
}
255262
}
256263
else
257264
{

0 commit comments

Comments
 (0)