Skip to content

Commit

Permalink
Fix initial next outgoing id value
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Mar 12, 2024
1 parent 3921603 commit 3247915
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [1.2.0] - 2024-03-12

* Fix initial next outgoing id value

## [1.0.1] - 2024-01-18

* Fix SenderLink closed state, if link is closed remotely
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-amqp"
version = "1.0.1"
version = "1.2.0"
authors = ["ntex contributors <[email protected]>"]
description = "AMQP 1.0 Client/Server framework"
documentation = "https://docs.rs/ntex-amqp"
Expand Down Expand Up @@ -35,7 +35,7 @@ slab = "0.4"
uuid = { version = "1", features = ["v4"] }

[dev-dependencies]
env_logger = "0.10"
env_logger = "0.11"
ntex = { version = "1.0", features = ["tokio"] }

[patch.crates-io]
Expand Down
4 changes: 2 additions & 2 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ntex::util::{HashMap, PoolRef, Ready};
use crate::codec::protocol::{self as codec, Begin, Close, End, Error, Frame, Role};
use crate::codec::{AmqpCodec, AmqpFrame};
use crate::dispatcher::ControlQueue;
use crate::session::{Session, SessionInner};
use crate::session::{Session, SessionInner, INITIAL_NEXT_OUTGOING_ID};
use crate::sndlink::{SenderLink, SenderLinkInner};
use crate::{cell::Cell, error::AmqpProtocolError, types::Action, Configuration};

Expand Down Expand Up @@ -194,7 +194,7 @@ impl ConnectionRef {

let begin = Begin(Box::new(codec::BeginInner {
remote_channel: None,
next_outgoing_id: 1,
next_outgoing_id: INITIAL_NEXT_OUTGOING_ID,
incoming_window: std::u32::MAX,
outgoing_window: std::u32::MAX,
handle_max: std::u32::MAX,
Expand Down
6 changes: 3 additions & 3 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::rcvlink::{ReceiverLink, ReceiverLinkBuilder, ReceiverLinkInner};
use crate::sndlink::{DeliveryPromise, SenderLink, SenderLinkBuilder, SenderLinkInner};
use crate::{cell::Cell, types::Action, ConnectionRef, ControlFrame};

const INITIAL_OUTGOING_ID: TransferNumber = 0;
pub(crate) const INITIAL_NEXT_OUTGOING_ID: TransferNumber = 1;

#[derive(Clone)]
pub struct Session {
Expand Down Expand Up @@ -316,7 +316,7 @@ impl SessionInner {
remote_incoming_window,
remote_outgoing_window,
flags: if local { Flags::LOCAL } else { Flags::empty() },
next_outgoing_id: INITIAL_OUTGOING_ID,
next_outgoing_id: INITIAL_NEXT_OUTGOING_ID,
unsettled_deliveries: HashMap::default(),
links: Slab::new(),
links_by_name: HashMap::default(),
Expand Down Expand Up @@ -1145,7 +1145,7 @@ impl SessionInner {

self.remote_incoming_window = flow
.next_incoming_id()
.unwrap_or(INITIAL_OUTGOING_ID)
.unwrap_or(0)
.wrapping_add(flow.incoming_window())
.wrapping_sub(self.next_outgoing_id);

Expand Down

0 comments on commit 3247915

Please sign in to comment.