Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2019-08-22 11:25:41 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2019-08-27 14:47:14 +0300
commit0101f7cdaa7be255875de06b9313c1a6e03fcb4d (patch)
tree7fa36e26738e6fe39e7800552d648b6e985f442f
parent1effc72370a4331bed0c08a4308e3f1cf38dc86b (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.c3
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)