Skip to content

Commit 474ed1a

Browse files
committed
bump version to 0.2.86 and refactor new timer
1 parent 533401a commit 474ed1a

4 files changed

Lines changed: 192 additions & 133 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rsipstack"
3-
version = "0.2.85"
3+
version = "0.2.86"
44
edition = "2021"
55
description = "SIP Stack Rust library for building SIP applications"
66
license = "MIT"

src/dialog/dialog.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -184,45 +184,6 @@ pub struct DialogInner {
184184
pub(super) initial_request: Request,
185185
}
186186

187-
// pub struct DialogStateReceiver {
188-
// pub(super) dialog_layer_inner: DialogLayerInnerRef,
189-
// pub(super) receiver: UnboundedReceiver<DialogState>,
190-
// pub(super) dialog_id: Option<DialogId>,
191-
// }
192-
193-
// impl DialogStateReceiver {
194-
// pub async fn recv(&mut self) -> Option<DialogState> {
195-
// let state = self.receiver.recv().await;
196-
// if let Some(ref s) = state {
197-
// self.dialog_id = Some(s.id().clone());
198-
// }
199-
// state
200-
// }
201-
// }
202-
203-
// impl Drop for DialogStateReceiver {
204-
// fn drop(&mut self) {
205-
// let id = match self.dialog_id.take() {
206-
// Some(id) => id,
207-
// None => return,
208-
// };
209-
210-
// match self.dialog_layer_inner.dialogs.write().as_mut() {
211-
// Ok(dialogs) => {
212-
// if let Some(dialog) = dialogs.remove(&id) {
213-
// info!(%id, "dialog removed on state receiver drop");
214-
// tokio::spawn(async move {
215-
// if let Err(e) = dialog.hangup().await {
216-
// warn!(%id, "error hanging up dialog on drop: {}", e);
217-
// }
218-
// });
219-
// }
220-
// }
221-
// Err(_) => {}
222-
// }
223-
// }
224-
// }
225-
226187
pub type DialogStateReceiver = UnboundedReceiver<DialogState>;
227188
pub type DialogStateSender = UnboundedSender<DialogState>;
228189

src/transaction/endpoint.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rsip::{prelude::HeadersExt, SipMessage};
1515
use std::{
1616
collections::HashMap,
1717
sync::{Arc, Mutex, RwLock},
18-
time::{Duration, Instant},
18+
time::Duration,
1919
};
2020
use tokio::{
2121
select,
@@ -108,6 +108,7 @@ pub struct EndpointInner {
108108
incoming_sender: TransactionSender,
109109
incoming_receiver: Mutex<Option<TransactionReceiver>>,
110110
cancel_token: CancellationToken,
111+
#[allow(dead_code)]
111112
timer_interval: Duration,
112113
pub(super) message_inspector: Option<Box<dyn MessageInspector>>,
113114
pub(super) locator: Option<Box<dyn TargetLocator>>,
@@ -235,13 +236,10 @@ impl EndpointInner {
235236

236237
pub async fn serve(self: &Arc<Self>) -> Result<()> {
237238
select! {
238-
_ = self.cancel_token.cancelled() => {
239-
},
240-
r = self.process_timer() => {
241-
_ = r?
242-
},
239+
_ = self.cancel_token.cancelled() => {},
240+
_ = self.process_timer() => {},
243241
r = self.clone().process_transport_layer() => {
244-
_ = r?
242+
_ = r?;
245243
},
246244
}
247245
Ok(())
@@ -290,10 +288,9 @@ impl EndpointInner {
290288
Ok(())
291289
}
292290

293-
pub async fn process_timer(&self) -> Result<()> {
294-
let mut ticker = tokio::time::interval(self.timer_interval);
291+
pub async fn process_timer(&self) {
295292
loop {
296-
for t in self.timers.poll(Instant::now()) {
293+
for t in self.timers.wait_for_ready().await.into_iter() {
297294
match t {
298295
TransactionTimer::TimerCleanup(key) => {
299296
trace!(%key, "TimerCleanup");
@@ -326,7 +323,6 @@ impl EndpointInner {
326323
}
327324
}
328325
}
329-
ticker.tick().await;
330326
}
331327
}
332328

0 commit comments

Comments
 (0)