@@ -79,6 +79,17 @@ impl FeltIpcClient {
7979 }
8080 }
8181
82+ pub fn notify_signout ( & self ) {
83+ trace ! ( "FeltIpcClient::notify_signout()" ) ;
84+ let msg = FeltMessage :: LogoutShutdown ;
85+ if let Some ( tx) = & self . tx {
86+ match tx. send ( msg) {
87+ Ok ( ( ) ) => trace ! ( "FeltIpcClient::notify_signout() SENT" ) ,
88+ Err ( err) => trace ! ( "FeltIpcClient::notify_signout() TX ERROR: {}" , err) ,
89+ }
90+ }
91+ }
92+
8293 pub fn report_version ( & self ) -> bool {
8394 trace ! ( "FeltIpcClient::report_version()" ) ;
8495 let msg = FeltMessage :: VersionProbe ( FELT_IPC_VERSION ) ;
@@ -262,19 +273,34 @@ impl FeltClientThread {
262273 let profile_ready_internal = profile_ready. clone ( ) ;
263274 let thread_stop_internal = thread_stop. clone ( ) ;
264275 let notify_restart_internal = notify_restart. clone ( ) ;
265- let mut felt_client = self . ipc_client . take ( ) ;
276+
277+ // Clone the tx: one for the background thread to signal existing,
278+ // one for us to immediately notify Felt is ready (to receive URLs etc),
279+ // this works because ipc-channel::ipc::IpcSender is Send + Sync.
280+ // Take the rx, only needed in the receive thread (and it's not Sync).
281+ let mut client = self . ipc_client . borrow_mut ( ) ;
282+ let tx_for_thread = client. tx . clone ( ) ;
283+ let rx_for_thread = client. rx . take ( ) ;
284+ drop ( client) ;
285+
286+ // Reconstruct a client instance for the thread to send stuff
287+ let thread_client = FeltIpcClient {
288+ tx : tx_for_thread,
289+ rx : rx_for_thread,
290+ } ;
291+
266292 trace ! ( "FeltClientThread::start_thread(): started thread: build runnable" ) ;
267293 let _ = moz_task:: RunnableBuilder :: new ( "felt_client::ipc_loop" , move || {
268294 trace ! ( "FeltClientThread::start_thread(): felt_client thread runnable" ) ;
269295 trace ! ( "FeltClientThread::start_thread(): felt_client version OK" ) ;
270- if let Some ( rx) = felt_client . rx . take ( ) {
296+ if let Some ( rx) = thread_client . rx . as_ref ( ) {
271297 let mut pending_cookies: Vec < String > = Vec :: new ( ) ;
272298
273299 loop {
274300 if notify_restart_internal. load ( Ordering :: Relaxed ) {
275301 notify_restart_internal. store ( false , Ordering :: Relaxed ) ;
276302 trace ! ( "FeltClientThread::felt_client::ipc_loop(): restart notification required!" ) ;
277- felt_client . notify_restart ( ) ;
303+ thread_client . notify_restart ( ) ;
278304 }
279305
280306 if pending_cookies. len ( ) > 0 && profile_ready_internal. load ( Ordering :: Relaxed ) {
@@ -355,4 +381,11 @@ impl FeltClientThread {
355381 // Wait for the thread to start up.
356382 self . startup_ready . load ( Ordering :: Acquire )
357383 }
384+
385+ pub fn notify_signout ( & self ) {
386+ trace ! ( "FeltClientThread::notify_signout()" ) ;
387+ let client = self . ipc_client . borrow ( ) ;
388+ client. notify_signout ( ) ;
389+ }
390+
358391}
0 commit comments