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

Unallocated pkid passthrough #925

Open
wants to merge 4 commits into
base: rumqttc-uplink-tested
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion rumqttc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl From<TrySendError<Request>> for ClientError {
/// from the broker, i.e. move ahead.
#[derive(Clone, Debug)]
pub struct AsyncClient {
request_tx: Sender<Request>,
pub request_tx: Sender<Request>,
}

impl AsyncClient {
Expand Down
1 change: 1 addition & 0 deletions rumqttc/src/eventloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl EventLoop {
match self.select().await {
Ok(v) => Ok(v),
Err(e) => {
log::error!("connection error : {e}");
self.clean();
Err(e)
}
Expand Down
6 changes: 5 additions & 1 deletion rumqttc/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ impl MqttState {
}

fn handle_incoming_puback(&mut self, puback: &PubAck) -> Result<Option<Packet>, StateError> {
if puback.pkid > self.max_inflight {
return Ok(None);
}

let publish = self
.outgoing_pub
.get_mut(puback.pkid as usize)
Expand Down Expand Up @@ -319,7 +323,7 @@ impl MqttState {
/// Adds next packet identifier to QoS 1 and 2 publish packets and returns
/// it buy wrapping publish in packet
fn outgoing_publish(&mut self, mut publish: Publish) -> Result<Option<Packet>, StateError> {
if publish.qos != QoS::AtMostOnce {
if publish.qos != QoS::AtMostOnce && publish.pkid <= self.max_inflight {
if publish.pkid == 0 {
publish.pkid = self.next_pkid();
}
Expand Down
2 changes: 1 addition & 1 deletion rumqttc/src/v5/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub enum StateError {
#[error("Connection failed with reason '{reason:?}' ")]
ConnFail { reason: ConnectReturnCode },
#[error("Connection closed by peer abruptly")]
ConnectionAborted
ConnectionAborted,
}

impl From<mqttbytes::Error> for StateError {
Expand Down