Skip to content

Commit a07ad33

Browse files
dependabot[bot]amokfa
authored andcommitted
* allow clients to publish directly (with non zero pkid)
* ignore pkids that are beyond max_inflight (to be handled by library users as per their logic)
1 parent 9671983 commit a07ad33

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rumqttc/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl From<TrySendError<Request>> for ClientError {
4141
/// from the broker, i.e. move ahead.
4242
#[derive(Clone, Debug)]
4343
pub struct AsyncClient {
44-
request_tx: Sender<Request>,
44+
pub request_tx: Sender<Request>,
4545
}
4646

4747
impl AsyncClient {

rumqttc/src/state.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ impl MqttState {
221221
}
222222

223223
fn handle_incoming_puback(&mut self, puback: &PubAck) -> Result<Option<Packet>, StateError> {
224+
if puback.pkid > self.max_inflight {
225+
return Ok(None);
226+
}
227+
224228
let publish = self
225229
.outgoing_pub
226230
.get_mut(puback.pkid as usize)
@@ -319,7 +323,7 @@ impl MqttState {
319323
/// Adds next packet identifier to QoS 1 and 2 publish packets and returns
320324
/// it buy wrapping publish in packet
321325
fn outgoing_publish(&mut self, mut publish: Publish) -> Result<Option<Packet>, StateError> {
322-
if publish.qos != QoS::AtMostOnce {
326+
if publish.qos != QoS::AtMostOnce || publish.pkid > self.max_inflight {
323327
if publish.pkid == 0 {
324328
publish.pkid = self.next_pkid();
325329
}

0 commit comments

Comments
 (0)