@@ -9,6 +9,7 @@ use libc::size_t;
99use rand:: { thread_rng, Rng } ;
1010use std:: collections:: HashMap ;
1111use std:: sync:: mpsc:: channel;
12+ use std:: thread;
1213use std:: { ptr, slice} ;
1314
1415type U2FAppIds = Vec < crate :: AppId > ;
@@ -233,7 +234,16 @@ pub unsafe extern "C" fn rust_u2f_mgr_register(
233234 let application = from_raw ( application_ptr, application_len) ;
234235 let key_handles = ( * khs) . clone ( ) ;
235236
236- let ( tx, _rx) = channel :: < crate :: StatusUpdate > ( ) ;
237+ let ( status_tx, status_rx) = channel :: < crate :: StatusUpdate > ( ) ;
238+ thread:: spawn ( move || loop {
239+ // Issue https://github.com/mozilla/authenticator-rs/issues/132 will
240+ // plumb the status channel through to the actual C API signatures
241+ match status_rx. recv ( ) {
242+ Ok ( _) => { }
243+ Err ( _recv_error) => return ,
244+ }
245+ } ) ;
246+
237247 let tid = new_tid ( ) ;
238248
239249 let state_callback =
@@ -261,7 +271,7 @@ pub unsafe extern "C" fn rust_u2f_mgr_register(
261271 challenge,
262272 application,
263273 key_handles,
264- tx ,
274+ status_tx ,
265275 state_callback,
266276 ) ;
267277
@@ -306,7 +316,15 @@ pub unsafe extern "C" fn rust_u2f_mgr_sign(
306316 let app_ids = ( * app_ids) . clone ( ) ;
307317 let key_handles = ( * khs) . clone ( ) ;
308318
309- let ( tx, _rx) = channel :: < crate :: StatusUpdate > ( ) ;
319+ let ( status_tx, status_rx) = channel :: < crate :: StatusUpdate > ( ) ;
320+ thread:: spawn ( move || loop {
321+ // Issue https://github.com/mozilla/authenticator-rs/issues/132 will
322+ // plumb the status channel through to the actual C API signatures
323+ match status_rx. recv ( ) {
324+ Ok ( _) => { }
325+ Err ( _recv_error) => return ,
326+ }
327+ } ) ;
310328
311329 let tid = new_tid ( ) ;
312330 let state_callback =
@@ -336,7 +354,7 @@ pub unsafe extern "C" fn rust_u2f_mgr_sign(
336354 challenge,
337355 app_ids,
338356 key_handles,
339- tx ,
357+ status_tx ,
340358 state_callback,
341359 ) ;
342360
0 commit comments