Skip to content

Commit

Permalink
Driver: Fix for busy-wait in WS thread. (#78)
Browse files Browse the repository at this point in the history
Debugging work put forth by JellyWx and jtscuba suggests that this WS thread receive is ending up in a permanent failure loop. This adapts the timeout-less receive such that receive failures are properly propagated.

This was tested using `cargo make ready` and using the `voice_storage` example (although I cannot repro the locking behaviour myself).

Comments in #69 suggest this is fixed -- closes #69.
  • Loading branch information
FelixMcFelix authored Jun 14, 2021
1 parent c97f23e commit b925309
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/ws.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// FIXME: this is copied from serenity/src/internal/ws_impl.rs
// To prevent this duplication, we either need to expose this on serenity's API
// (not desirable) or break the common WS elements into a subcrate.
// I believe that decisions is outside of the scope of the voice subcrate PR.

use crate::model::Event;

use async_trait::async_trait;
Expand Down Expand Up @@ -101,7 +96,7 @@ impl ReceiverExt for WsStream {
}

async fn recv_json_no_timeout(&mut self) -> Result<Option<Event>> {
convert_ws_message(self.try_next().await.ok().flatten())
convert_ws_message(self.try_next().await?)
}
}

Expand Down

0 comments on commit b925309

Please sign in to comment.