File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,18 @@ pub async fn op_net_accept(
108
108
if rx. is_none ( ) {
109
109
return Err ( bad_resource ( "unix channel receiver is already used" ) ) ;
110
110
}
111
- let mut rx = rx. unwrap ( ) ;
111
+
112
+ let rx = rx. unwrap ( ) ;
113
+ let mut rx = scopeguard:: guard ( rx, {
114
+ let state = state. clone ( ) ;
115
+ move |value| {
116
+ let mut op_state = state. borrow_mut ( ) ;
117
+ op_state. put :: < mpsc:: UnboundedReceiver < (
118
+ tokio:: net:: UnixStream ,
119
+ Option < watch:: Receiver < ConnSync > > ,
120
+ ) > > ( value) ;
121
+ }
122
+ } ) ;
112
123
113
124
let Some ( ( unix_stream, conn_sync) ) = rx. recv ( ) . await else {
114
125
return Err ( bad_resource ( "unix stream channel is closed" ) ) ;
@@ -119,10 +130,9 @@ pub async fn op_net_accept(
119
130
120
131
// since the op state was dropped before,
121
132
// reborrow and add the channel receiver again
122
- let mut op_state = state. borrow_mut ( ) ;
123
-
124
- op_state. put :: < mpsc:: UnboundedReceiver < ( tokio:: net:: UnixStream , Option < watch:: Receiver < ConnSync > > ) > > ( rx) ;
133
+ drop ( rx) ;
125
134
135
+ let mut op_state = state. borrow_mut ( ) ;
126
136
let rid = op_state. resource_table . add ( resource) ;
127
137
128
138
if let Some ( watcher) = conn_sync {
You can’t perform that action at this time.
0 commit comments