Skip to content

Commit 8f81b4b

Browse files
committed
Treat recv()==0 as clean EOF instead of a network error (fixes spurious HTTP 'recv() error 0' logs)
1 parent 4bdec7f commit 8f81b4b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Source/IO/Protocol.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,17 @@ namespace Protocol
428428

429429
int received = recv(sock, buffer + total_received, remaining_length, 0);
430430

431-
if (received == 0)
432-
return handleNetworkError("recv()", 0, total_received);
431+
if (received == 0) // peer performed orderly shutdown (EOF), not an error
432+
{
433+
if (persistent)
434+
{
435+
Debug() << "TCP (" << host << ":" << port << "): connection closed by peer, reconnecting.";
436+
reconnect();
437+
}
438+
else
439+
disconnect();
440+
break;
441+
}
433442

434443
if (received < 0)
435444
{

0 commit comments

Comments
 (0)