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-22 11:25:41 +0300
commit4f4213c541d61f910cc2316abd3bd213fe56935c (patch)
treed82819e6588b5b86b65e0fcda9039791e6ffb99b /examples
parentbfc3aea354bdb0034f9f4b32e155f1c33f87a327 (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.
Diffstat (limited to 'examples')
-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)