Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 24aca40

Browse files
authored
association: only reset stored_init once ACK is received (#24)
* association: only reset stored_init once ACK is received BEFORE: after `sent_init` is called, `stored_init` becomes None. Consequently, all retransmit attempts was failing because there's no init anymore. AFTER: after `sent_init` is called, `stored_init` is still Some(v). Closes #23
1 parent ee00381 commit 24aca40

File tree

9 files changed

+29
-15
lines changed

9 files changed

+29
-15
lines changed

src/association/association_internal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl AssociationInternal {
169169

170170
/// caller must hold self.lock
171171
pub(crate) fn send_init(&mut self) -> Result<()> {
172-
if let Some(stored_init) = self.stored_init.take() {
172+
if let Some(stored_init) = self.stored_init.clone() {
173173
log::debug!("[{}] sending INIT", self.name);
174174

175175
self.source_port = 5000; // Spec??

src/chunk/chunk_init.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ pub(crate) struct ChunkInit {
7474
pub(crate) params: Vec<Box<dyn Param + Send + Sync>>,
7575
}
7676

77+
impl Clone for ChunkInit {
78+
fn clone(&self) -> Self {
79+
ChunkInit {
80+
is_ack: self.is_ack,
81+
initiate_tag: self.initiate_tag,
82+
advertised_receiver_window_credit: self.advertised_receiver_window_credit,
83+
num_outbound_streams: self.num_outbound_streams,
84+
num_inbound_streams: self.num_inbound_streams,
85+
initial_tsn: self.initial_tsn,
86+
params: self.params.to_vec(),
87+
}
88+
}
89+
}
90+
7791
pub(crate) const INIT_CHUNK_MIN_LENGTH: usize = 16;
7892
pub(crate) const INIT_OPTIONAL_VAR_HEADER_LENGTH: usize = 4;
7993

src/chunk/chunk_payload_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub(crate) const PAYLOAD_DATA_HEADER_SIZE: usize = 12;
1515
/// PayloadProtocolIdentifier is an enum for DataChannel payload types
1616
/// PayloadProtocolIdentifier enums
1717
/// https://www.iana.org/assignments/sctp-parameters/sctp-parameters.xhtml#sctp-parameters-25
18-
#[derive(Debug, Copy, Clone, PartialEq)]
18+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
1919
#[repr(C)]
2020
pub enum PayloadProtocolIdentifier {
2121
Dcep = 50,

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use thiserror::Error;
33

44
pub type Result<T> = std::result::Result<T, Error>;
55

6-
#[derive(Debug, Error, PartialEq)]
6+
#[derive(Debug, Error, PartialEq, Eq)]
77
#[non_exhaustive]
88
pub enum Error {
99
#[error("raw is too small for a SCTP chunk")]

src/packet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl Packet {
170170

171171
let hasher = Crc::<u32>::new(&CRC_32_ISCSI);
172172
let mut digest = hasher.digest();
173-
digest.update(&writer.to_vec());
173+
digest.update(writer);
174174
digest.update(&FOUR_ZEROES);
175175
digest.update(&raw[..]);
176176
let checksum = digest.finalize();

src/param/param_unknown.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::fmt::{Debug, Display, Formatter};
1010
/// This means we do not really understand the semantics of the param but can represent it.
1111
///
1212
/// This is useful for usage in e.g.`ParamUnrecognized` where we want to report some unrecognized params back to the sender.
13-
#[derive(Clone, Debug, PartialEq)]
13+
#[derive(Clone, Debug, PartialEq, Eq)]
1414
pub struct ParamUnknown {
1515
typ: u16,
1616
value: Bytes,
@@ -33,7 +33,7 @@ impl Param for ParamUnknown {
3333
}
3434

3535
fn as_any(&self) -> &(dyn Any + Send + Sync) {
36-
&*self
36+
self
3737
}
3838

3939
fn unmarshal(raw: &Bytes) -> crate::error::Result<Self>

src/param/param_unrecognized.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl Param for ParamUnrecognized {
3535
}
3636

3737
fn as_any(&self) -> &(dyn Any + Send + Sync) {
38-
&*self
38+
self
3939
}
4040

4141
fn unmarshal(raw: &Bytes) -> crate::error::Result<Self>

src/stream/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::task::{Context, Poll};
2020
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
2121
use tokio::sync::{mpsc, Mutex, Notify};
2222

23-
#[derive(Debug, Copy, Clone, PartialEq)]
23+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
2424
#[repr(C)]
2525
pub enum ReliabilityType {
2626
/// ReliabilityTypeReliable is used for reliable transmission
@@ -795,6 +795,6 @@ impl fmt::Debug for PollStream {
795795

796796
impl AsRef<Stream> for PollStream {
797797
fn as_ref(&self) -> &Stream {
798-
&*self.stream
798+
&self.stream
799799
}
800800
}

src/timer/timer_test.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
use async_trait::async_trait;
2-
use std::sync::atomic::{AtomicU32, Ordering};
3-
use std::sync::Arc;
4-
use std::time::SystemTime;
5-
6-
use tokio::sync::mpsc;
72
use tokio::sync::Mutex;
83
use tokio::time::{sleep, Duration};
94

10-
use crate::error::Result;
5+
use std::sync::atomic::{AtomicU32, Ordering};
6+
use std::sync::Arc;
117

128
///////////////////////////////////////////////////////////////////
139
//ack_timer_test
@@ -165,6 +161,10 @@ mod test_rto_manager {
165161
mod test_rtx_timer {
166162
use super::*;
167163
use crate::association::RtxTimerId;
164+
use crate::error::Result;
165+
166+
use std::time::SystemTime;
167+
use tokio::sync::mpsc;
168168

169169
struct TestTimerObserver {
170170
ncbs: Arc<AtomicU32>,

0 commit comments

Comments
 (0)