Skip to main content

request_watched_sifted

Function request_watched_sifted 

Source
pub fn request_watched_sifted(
    ctx: &ServiceContext,
    peer: &str,
    msg: &Message,
    secs: i64,
    watch: &dyn Watch,
    mine: &mut dyn FnMut(&Message) -> bool,
) -> Result<Message, Error>
Expand description

request_watched that takes only the reply mine accepts, and drops any other while it waits. When the watch is not active it is request_within, which does not sift.

Why a quittable wait needs this. Quitting abandons a request whose reply is still on its way. The next request’s wait would take that late reply as its own, and the next command fails for nothing - found by osdev test quit on a slow fs, where every command after a q failed (“storage unavailable”, “see fs’s log”). A caller that tags its requests passes a test for its own tag, so a late answer to a question already given up on is recognised and dropped.