zephyr-im / zephyr

An institutional/enterprise-scale distributed real-time messaging and notification system
34 stars 11 forks source link

Bad packets may delay timers up to 60s #100

Closed andersk-auto closed 10 years ago

andersk-auto commented 10 years ago

If the server receives certain types of bad packets (specifically, one that Z_ReadWait thinks is "obviously" not a zephyr packet), it may block up to 60s waiting for another packet to arrive. During this time, other events, such as timers and incoming brain dump traffic, will not be processed.

andersk-auto commented 10 years ago

Imported from trac issue 100. Created by jhutz@CS.CMU.EDU on 2013-02-18T15:44:37, last modified: 2013-02-27T00:22:59

andersk-auto commented 10 years ago

Trac comment by Karl Ramm kcr@1ts.org on 2013-02-27 00:22:59:

In [864eb7e746c2d3a1fe03d230d01d74de97160b63/zephyr]: {{{

!CommitTicketReference repository="zephyr" revision="864eb7e746c2d3a1fe03d230d01d74de97160b63"

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 }}}