diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2019-08-22 11:25:41 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2019-08-27 14:47:14 +0300 |
commit | 0101f7cdaa7be255875de06b9313c1a6e03fcb4d (patch) | |
tree | 7fa36e26738e6fe39e7800552d648b6e985f442f | |
parent | 1effc72370a4331bed0c08a4308e3f1cf38dc86b (diff) |
network_server example: Detect count=0 in read_callback() (#421)
Previously the example code would falsely detect EOF condition if
called with count = 0.
-rw-r--r-- | examples/network_server/common.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/examples/network_server/common.c b/examples/network_server/common.c index 04a5aa8..05048f6 100644 --- a/examples/network_server/common.c +++ b/examples/network_server/common.c @@ -19,6 +19,9 @@ static bool read_callback(pb_istream_t *stream, uint8_t *buf, size_t count) int fd = (intptr_t)stream->state; int result; + if (count == 0) + return true; + result = recv(fd, buf, count, MSG_WAITALL); if (result == 0) |