Driver: Don't trim recv_buffer on MacOS

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`.
This commit is contained in:
Kyle Simpson
2023-08-08 20:48:46 +01:00
parent 02c9812c3e
commit 019ac27a85

View File

@@ -75,7 +75,9 @@ impl Connection {
.await?; .await?;
loop { loop {
let Some(value) = client.recv_json().await? else { continue }; let Some(value) = client.recv_json().await? else {
continue;
};
match value { match value {
GatewayEvent::Ready(r) => { GatewayEvent::Ready(r) => {
@@ -112,7 +114,10 @@ impl Connection {
udp udp
} else { } else {
let socket = Socket::from(udp.into_std()?); let socket = Socket::from(udp.into_std()?);
#[cfg(not(target_os = "macos"))]
socket.set_recv_buffer_size(0)?; socket.set_recv_buffer_size(0)?;
UdpSocket::from_std(socket.into())? UdpSocket::from_std(socket.into())?
}; };
@@ -279,7 +284,9 @@ impl Connection {
let mut resumed = None; let mut resumed = None;
loop { loop {
let Some(value) = client.recv_json().await? else { continue }; let Some(value) = client.recv_json().await? else {
continue;
};
match value { match value {
GatewayEvent::Resumed => { GatewayEvent::Resumed => {
@@ -331,7 +338,9 @@ fn generate_url(endpoint: &mut String) -> Result<Url> {
#[inline] #[inline]
async fn init_cipher(client: &mut WsStream, mode: CryptoMode) -> Result<Cipher> { async fn init_cipher(client: &mut WsStream, mode: CryptoMode) -> Result<Cipher> {
loop { loop {
let Some(value) = client.recv_json().await? else { continue }; let Some(value) = client.recv_json().await? else {
continue;
};
match value { match value {
GatewayEvent::SessionDescription(desc) => { GatewayEvent::SessionDescription(desc) => {