Skip to content

Commit

Permalink
Driver: Don't trim recv_buffer on MacOS
Browse files Browse the repository at this point in the history
This should fix #193 -- it seems that a zero-size recv buffer is an invalid argument as far as darwin is concerned.

Tested with `cargo make ready`.
  • Loading branch information
FelixMcFelix committed Nov 20, 2023
1 parent 02c9812 commit 019ac27
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/driver/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ impl Connection {
.await?;

loop {
let Some(value) = client.recv_json().await? else { continue };
let Some(value) = client.recv_json().await? else {
continue;
};

match value {
GatewayEvent::Ready(r) => {
Expand Down Expand Up @@ -112,7 +114,10 @@ impl Connection {
udp
} else {
let socket = Socket::from(udp.into_std()?);

#[cfg(not(target_os = "macos"))]
socket.set_recv_buffer_size(0)?;

UdpSocket::from_std(socket.into())?
};

Expand Down Expand Up @@ -279,7 +284,9 @@ impl Connection {
let mut resumed = None;

loop {
let Some(value) = client.recv_json().await? else { continue };
let Some(value) = client.recv_json().await? else {
continue;
};

match value {
GatewayEvent::Resumed => {
Expand Down Expand Up @@ -331,7 +338,9 @@ fn generate_url(endpoint: &mut String) -> Result<Url> {
#[inline]
async fn init_cipher(client: &mut WsStream, mode: CryptoMode) -> Result<Cipher> {
loop {
let Some(value) = client.recv_json().await? else { continue };
let Some(value) = client.recv_json().await? else {
continue;
};

match value {
GatewayEvent::SessionDescription(desc) => {
Expand Down

0 comments on commit 019ac27

Please sign in to comment.