Skip to content

Commit f7f96e1

Browse files
Merge pull request #71 from narrowlink/DropIpstackHandle
Drop task handle in IpStack
2 parents 1bdbc8b + 5065b61 commit f7f96e1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl IpStackConfig {
8383

8484
pub struct IpStack {
8585
accept_receiver: UnboundedReceiver<IpStackStream>,
86-
_handle: JoinHandle<Result<()>>, // Just hold the task handle
86+
handle: JoinHandle<Result<()>>,
8787
}
8888

8989
impl IpStack {
@@ -94,7 +94,7 @@ impl IpStack {
9494
let (accept_sender, accept_receiver) = mpsc::unbounded_channel::<IpStackStream>();
9595
IpStack {
9696
accept_receiver,
97-
_handle: run(config, device, accept_sender),
97+
handle: run(config, device, accept_sender),
9898
}
9999
}
100100

@@ -103,6 +103,12 @@ impl IpStack {
103103
}
104104
}
105105

106+
impl Drop for IpStack {
107+
fn drop(&mut self) {
108+
self.handle.abort();
109+
}
110+
}
111+
106112
fn run<Device: AsyncRead + AsyncWrite + Unpin + Send + 'static>(
107113
config: IpStackConfig,
108114
mut device: Device,

0 commit comments

Comments
 (0)