diff --git a/rumqttd/CHANGELOG.md b/rumqttd/CHANGELOG.md index e05da5cea..ba5c627eb 100644 --- a/rumqttd/CHANGELOG.md +++ b/rumqttd/CHANGELOG.md @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - MQTT keep alive interval - record client id for remote link's span - session present flag in connack +- Make write method return the number of bytes written correctly everywhere ### Security diff --git a/rumqttd/src/protocol/v4/connect.rs b/rumqttd/src/protocol/v4/connect.rs index 5b8bbbe7d..5064da6e5 100644 --- a/rumqttd/src/protocol/v4/connect.rs +++ b/rumqttd/src/protocol/v4/connect.rs @@ -92,7 +92,7 @@ pub fn write( // update connect flags buffer[flags_index] = connect_flags; - Ok(len) + Ok(1 + count + len) } mod will { diff --git a/rumqttd/src/protocol/v4/publish.rs b/rumqttd/src/protocol/v4/publish.rs index e9bcd2c85..b64cb3143 100644 --- a/rumqttd/src/protocol/v4/publish.rs +++ b/rumqttd/src/protocol/v4/publish.rs @@ -63,6 +63,5 @@ pub fn write(publish: &Publish, buffer: &mut BytesMut) -> Result { buffer.extend_from_slice(&publish.payload); - // TODO: Returned length is wrong in other packets. Fix it Ok(1 + count + len) } diff --git a/rumqttd/src/protocol/v5/connect.rs b/rumqttd/src/protocol/v5/connect.rs index f6dbdc4bc..be348e8aa 100644 --- a/rumqttd/src/protocol/v5/connect.rs +++ b/rumqttd/src/protocol/v5/connect.rs @@ -122,7 +122,7 @@ pub fn write( // update connect flags buffer[flags_index] = connect_flags; - Ok(len) + Ok(1 + count + len) } mod will {