From 864eb7e746c2d3a1fe03d230d01d74de97160b63 Mon Sep 17 00:00:00 2001 From: Jeffrey Hutzelman Date: Mon, 18 Feb 2013 17:06:38 -0500 Subject: 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 --- lib/Zinternal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ -- cgit v1.2.3