@@ -281,7 +281,7 @@ const LOOPER_WAITING_PROC: u32 = 0x20;
281281const LOOPER_POLL : u32 = 0x40 ;
282282
283283impl InnerThread {
284- fn new ( ) -> Result < Self > {
284+ fn new ( pid : i32 ) -> Result < Self > {
285285 fn next_err_id ( ) -> u32 {
286286 static EE_ID : Atomic < u32 > = Atomic :: new ( 0 ) ;
287287 EE_ID . fetch_add ( 1 , Relaxed )
@@ -292,8 +292,8 @@ impl InnerThread {
292292 looper_need_return : false ,
293293 is_dead : false ,
294294 process_work_list : false ,
295- reply_work : ThreadError :: try_new ( ) ?,
296- return_work : ThreadError :: try_new ( ) ?,
295+ reply_work : ThreadError :: try_new ( pid ) ?,
296+ return_work : ThreadError :: try_new ( pid ) ?,
297297 work_list : List :: new ( ) ,
298298 current_transaction : None ,
299299 extended_error : ExtendedError :: new ( next_err_id ( ) , BR_OK , 0 ) ,
@@ -452,7 +452,7 @@ kernel::list::impl_list_item! {
452452
453453impl Thread {
454454 pub ( crate ) fn new ( id : i32 , process : Arc < Process > ) -> Result < Arc < Self > > {
455- let inner = InnerThread :: new ( ) ?;
455+ let inner = InnerThread :: new ( process . task . pid ( ) ) ?;
456456
457457 Arc :: pin_init (
458458 try_pin_init ! ( Thread {
@@ -1154,6 +1154,12 @@ impl Thread {
11541154 let mut inner = thread. inner . lock ( ) ;
11551155 inner. pop_transaction_to_reply ( thread. as_ref ( ) )
11561156 } {
1157+ binder_debug ! (
1158+ DeadTransaction ,
1159+ "release transaction {} in, still active" ,
1160+ transaction. debug_id
1161+ ) ;
1162+
11571163 let reply = Err ( BR_DEAD_REPLY ) ;
11581164 if !transaction
11591165 . from
@@ -1354,7 +1360,7 @@ impl Thread {
13541360 // TODO: We need to ensure that there isn't a pending transaction in the work queue. How
13551361 // could this happen?
13561362 let top = self . top_of_transaction_stack ( ) ?;
1357- let list_completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE ) ) ?;
1363+ let list_completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE , self . process . task . pid ( ) ) ) ?;
13581364 let completion = list_completion. clone_arc ( ) ;
13591365 let transaction = Transaction :: new ( node_ref, top, self , info) ?;
13601366
@@ -1412,7 +1418,7 @@ impl Thread {
14121418
14131419 // We need to complete the transaction even if we cannot complete building the reply.
14141420 let out = ( || -> BinderResult < _ > {
1415- let completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE ) ) ?;
1421+ let completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE , self . process . task . pid ( ) ) ) ?;
14161422 let process = orig. from . process . clone ( ) ;
14171423 let allow_fds = orig. flags & TF_ACCEPT_FDS != 0 ;
14181424 let reply = Transaction :: new_reply ( self , process, info, allow_fds) ?;
@@ -1453,7 +1459,7 @@ impl Thread {
14531459 } else {
14541460 BR_TRANSACTION_COMPLETE
14551461 } ;
1456- let list_completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( code) ) ?;
1462+ let list_completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( code, self . process . task . pid ( ) ) ) ?;
14571463 let completion = list_completion. clone_arc ( ) ;
14581464 // Not notifying: Reply to current thread.
14591465 let _ = self . inner . lock ( ) . push_work ( list_completion) ;
@@ -1692,14 +1698,16 @@ impl Thread {
16921698#[ pin_data]
16931699struct ThreadError {
16941700 error_code : Atomic < u32 > ,
1701+ pid : i32 ,
16951702 #[ pin]
16961703 links_track : AtomicTracker ,
16971704}
16981705
16991706impl ThreadError {
1700- fn try_new ( ) -> Result < DArc < Self > > {
1707+ fn try_new ( pid : i32 ) -> Result < DArc < Self > > {
17011708 DTRWrap :: arc_pin_init ( pin_init ! ( Self {
17021709 error_code: Atomic :: new( BR_OK ) ,
1710+ pid,
17031711 links_track <- AtomicTracker :: new( ) ,
17041712 } ) )
17051713 . map ( ListArc :: into_arc)
@@ -1726,7 +1734,16 @@ impl DeliverToRead for ThreadError {
17261734 Ok ( true )
17271735 }
17281736
1729- fn cancel ( self : DArc < Self > ) { }
1737+ fn cancel ( self : DArc < Self > ) {
1738+ let code = self . error_code . load ( Relaxed ) ;
1739+ if code != BR_OK {
1740+ binder_debug ! (
1741+ pid=self . pid,
1742+ DeadTransaction ,
1743+ "undelivered TRANSACTION_ERROR: {code}"
1744+ ) ;
1745+ }
1746+ }
17301747
17311748 fn should_sync_wakeup ( & self ) -> bool {
17321749 false
0 commit comments