Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare release 0.18.2 #175

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Release 0.18.2
- Fix tugstenite dependency adding url feature

## Release 0.18.1
- Update tugstenite version.
- Update minor versions of internal dependencies
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "message-io"
version = "0.18.1"
version = "0.18.2"
authors = ["lemunozm <[email protected]>"]
edition = "2018"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions examples/throughput/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ fn throughput_native_ws(packet_size: usize) {
let (mut sender, _) = ws_connect(Url::parse(&url_addr).unwrap()).unwrap();
let start_time = Instant::now();
while total_sent < EXPECTED_BYTES {
sender.write_message(Message::Binary(message.clone())).unwrap();
sender.send(Message::Binary(message.clone())).unwrap();
total_sent += message.len();
}
start_time
Expand All @@ -245,7 +245,7 @@ fn throughput_native_ws(packet_size: usize) {
let mut receiver = ws_accept(listener.accept().unwrap().0).unwrap();
let mut total_received = 0;
while total_received < EXPECTED_BYTES {
total_received += receiver.read_message().unwrap().len();
total_received += receiver.read().unwrap().len();
}
let end_time = Instant::now();

Expand Down
9 changes: 4 additions & 5 deletions src/adapters/framed_tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use socket2::{Socket};

use std::net::{SocketAddr};
use std::io::{self, ErrorKind, Read, Write};
use std::ops::{Deref};
use std::cell::{RefCell};
use std::mem::{forget, MaybeUninit};
#[cfg(target_os = "windows")]
Expand Down Expand Up @@ -103,8 +102,8 @@ impl Remote for RemoteResource {
let mut input_buffer = unsafe { buffer.assume_init() }; // Avoid to initialize the array

loop {
let stream = &self.stream;
match stream.deref().read(&mut input_buffer) {
let mut stream = &self.stream;
match stream.read(&mut input_buffer) {
Ok(0) => break ReadStatus::Disconnected,
Ok(size) => {
let data = &input_buffer[..size];
Expand Down Expand Up @@ -140,8 +139,8 @@ impl Remote for RemoteResource {
false => &data[total_bytes_sent - encoded_size.len()..],
};

let stream = &self.stream;
match stream.deref().write(data_to_send) {
let mut stream = &self.stream;
match stream.write(data_to_send) {
Ok(bytes_sent) => {
total_bytes_sent += bytes_sent;
if total_bytes_sent == total_bytes {
Expand Down
13 changes: 6 additions & 7 deletions src/adapters/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use std::ffi::{CString};
use std::io::{self, ErrorKind, Read, Write};
#[cfg(target_os = "macos")]
use std::num::NonZeroU32;
use std::ops::{Deref};
use std::mem::{forget, MaybeUninit};
use std::os::raw::c_int;
#[cfg(target_os = "windows")]
Expand Down Expand Up @@ -133,7 +132,7 @@ impl Remote for RemoteResource {

#[cfg(target_os = "macos")]
match NonZeroU32::new(unsafe { libc::if_nametoindex(device.as_ptr()) }) {
Some(index) => socket.bind_device_by_index(Some(index))?,
Some(index) => socket.bind_device_by_index_v4(Some(index))?,
None => {
return Err(io::Error::new(
ErrorKind::NotFound,
Expand Down Expand Up @@ -165,8 +164,8 @@ impl Remote for RemoteResource {
let mut input_buffer = unsafe { buffer.assume_init() }; // Avoid to initialize the array

loop {
let stream = &self.stream;
match stream.deref().read(&mut input_buffer) {
let mut stream = &self.stream;
match stream.read(&mut input_buffer) {
Ok(0) => break ReadStatus::Disconnected,
Ok(size) => process_data(&input_buffer[..size]),
Err(ref err) if err.kind() == ErrorKind::Interrupted => continue,
Expand All @@ -191,8 +190,8 @@ impl Remote for RemoteResource {
// this only occurs in the case when the receiver is full because reads slower that it sends.
let mut total_bytes_sent = 0;
loop {
let stream = &self.stream;
match stream.deref().write(&data[total_bytes_sent..]) {
let mut stream = &self.stream;
match stream.write(&data[total_bytes_sent..]) {
Ok(bytes_sent) => {
total_bytes_sent += bytes_sent;
if total_bytes_sent == data.len() {
Expand Down Expand Up @@ -289,7 +288,7 @@ impl Local for LocalResource {

#[cfg(target_os = "macos")]
match NonZeroU32::new(unsafe { libc::if_nametoindex(device.as_ptr()) }) {
Some(index) => socket.bind_device_by_index(Some(index))?,
Some(index) => socket.bind_device_by_index_v4(Some(index))?,
None => {
return Err(io::Error::new(
ErrorKind::NotFound,
Expand Down
8 changes: 5 additions & 3 deletions src/adapters/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ impl Remote for RemoteResource {
// "emulates" full duplex for the websocket case locking here and not outside the loop.
let mut state = self.state.lock().expect(OTHER_THREAD_ERR);
let deref_state = state.deref_mut();

match deref_state {
RemoteState::WebSocket(web_socket) => match web_socket.read_message() {
RemoteState::WebSocket(web_socket) => match web_socket.read() {
Ok(message) => match message {
Message::Binary(data) => {
// As an optimization.
Expand Down Expand Up @@ -162,12 +163,13 @@ impl Remote for RemoteResource {
match deref_state {
RemoteState::WebSocket(web_socket) => {
let message = Message::Binary(data.to_vec());
let mut result = web_socket.write_message(message);

let mut result = web_socket.send(message);
loop {
match result {
Ok(_) => break SendStatus::Sent,
Err(Error::Io(ref err)) if err.kind() == ErrorKind::WouldBlock => {
result = web_socket.write_pending();
result = web_socket.flush();
}
Err(Error::Capacity(_)) => break SendStatus::MaxPacketSizeExceeded,
Err(err) => {
Expand Down
Loading