File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -171,4 +171,30 @@ mod test {
171
171
}
172
172
}
173
173
}
174
+
175
+ #[ test] #[ ignore]
176
+ fn multiple_connect_serial ( ) {
177
+ do run_in_newsched_task {
178
+ let addr = next_test_ip4 ( ) ;
179
+ let max = 100 ;
180
+
181
+ do spawntask_immediately {
182
+ let mut listener = TcpListener :: bind ( addr) ;
183
+ for max. times {
184
+ let mut stream = listener. accept( ) ;
185
+ let mut buf = [ 0 ] ;
186
+ stream. read( buf) ;
187
+ assert ! ( buf[ 0 ] == 99 ) ;
188
+ }
189
+ }
190
+
191
+ do spawntask_immediately {
192
+ for max. times {
193
+ let mut stream = TcpStream : : connect( addr) ;
194
+ stream. write( [ 99 ] ) ;
195
+ }
196
+ }
197
+ }
198
+ }
199
+
174
200
}
Original file line number Diff line number Diff line change @@ -239,9 +239,10 @@ pub impl TcpWatcher {
239
239
extern fn connection_cb ( handle : * uvll:: uv_stream_t , status : c_int ) {
240
240
rtdebug ! ( "connection_cb" ) ;
241
241
let mut stream_watcher: StreamWatcher = NativeHandle :: from_native_handle ( handle) ;
242
- let cb = stream_watcher. get_watcher_data ( ) . connect_cb . swap_unwrap ( ) ;
243
- let status = status_to_maybe_uv_error ( stream_watcher. native_handle ( ) , status) ;
244
- cb ( stream_watcher, status) ;
242
+ let data = stream_watcher. get_watcher_data ( ) ;
243
+ let cb = data. connect_cb . get_ref ( ) ;
244
+ let status = status_to_maybe_uv_error ( handle, status) ;
245
+ ( * cb) ( stream_watcher, status) ;
245
246
}
246
247
}
247
248
You can’t perform that action at this time.
0 commit comments