summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jeffrey Hutzelman <jhutz@cmu.edu>2013-02-18 17:06:38 -0500
committerGravatar Karl Ramm <kcr@1ts.org>2013-02-27 00:08:24 -0500
commit864eb7e746c2d3a1fe03d230d01d74de97160b63 (patch)
tree363e85afa9839655a3fd4bc2c8258666ed4f15ce
parenta323589383be38de2f76b564c5edc493bf7f9ec2 (diff)
Treat obviously non-zephyr packets as bad
When Z_ReadWait receives a packet which doesn't start with a zephyr version header, it considers the packet to be "obviously non-zephyr". Such packets are discarded and, previously, caused Z_ReadWait to return ZERR_NONE. Unfortunately, this can cause things to block for up to 60s when a caller was expecting a non-blocking call to pick up a new packet if there is one. This changes Z_ReadWait to return ZERR_BADPKT in this situation, eliminating the potential wait. This fixes #100
-rw-r--r--lib/Zinternal.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Zinternal.c b/lib/Zinternal.c
index 8e902c3..8ed5c0c 100644
--- a/lib/Zinternal.c
+++ b/lib/Zinternal.c
@@ -314,7 +314,7 @@ Z_ReadWait(void)
zvlen = sizeof(ZVERSIONHDR) - 1;
if (packet_len < zvlen || memcmp(packet, ZVERSIONHDR, zvlen) != 0) {
Z_discarded_packets++;
- return (ZERR_NONE);
+ return (ZERR_BADPKT);
}
/* Parse the notice */