@@ -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
@@ -1213,7 +1219,6 @@ impl Thread {
12131219 Ok ( work) => inner. push_work ( work) ,
12141220 Err ( code) => inner. push_reply_work ( code) ,
12151221 }
1216-
12171222 } ;
12181223
12191224 // Notify the thread now that we've released the inner lock.
@@ -1357,7 +1362,7 @@ impl Thread {
13571362 // TODO: We need to ensure that there isn't a pending transaction in the work queue. How
13581363 // could this happen?
13591364 let top = self . top_of_transaction_stack ( ) ?;
1360- let list_completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE ) ) ?;
1365+ let list_completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE , self . process . task . pid ( ) ) ) ?;
13611366 let completion = list_completion. clone_arc ( ) ;
13621367 let transaction = Transaction :: new ( node_ref, top, self , info) ?;
13631368
@@ -1415,7 +1420,7 @@ impl Thread {
14151420
14161421 // We need to complete the transaction even if we cannot complete building the reply.
14171422 let out = ( || -> BinderResult < _ > {
1418- let completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE ) ) ?;
1423+ let completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( BR_TRANSACTION_COMPLETE , self . process . task . pid ( ) ) ) ?;
14191424 let process = orig. from . process . clone ( ) ;
14201425 let allow_fds = orig. flags & TF_ACCEPT_FDS != 0 ;
14211426 let reply = Transaction :: new_reply ( self , process, info, allow_fds) ?;
@@ -1456,7 +1461,7 @@ impl Thread {
14561461 } else {
14571462 BR_TRANSACTION_COMPLETE
14581463 } ;
1459- let list_completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( code) ) ?;
1464+ let list_completion = DTRWrap :: arc_try_new ( DeliverCode :: new ( code, self . process . task . pid ( ) ) ) ?;
14601465 let completion = list_completion. clone_arc ( ) ;
14611466 // Not notifying: Reply to current thread.
14621467 let _ = self . inner . lock ( ) . push_work ( list_completion) ;
@@ -1695,14 +1700,16 @@ impl Thread {
16951700#[ pin_data]
16961701struct ThreadError {
16971702 error_code : Atomic < u32 > ,
1703+ pid : i32 ,
16981704 #[ pin]
16991705 links_track : AtomicTracker ,
17001706}
17011707
17021708impl ThreadError {
1703- fn try_new ( ) -> Result < DArc < Self > > {
1709+ fn try_new ( pid : i32 ) -> Result < DArc < Self > > {
17041710 DTRWrap :: arc_pin_init ( pin_init ! ( Self {
17051711 error_code: Atomic :: new( BR_OK ) ,
1712+ pid,
17061713 links_track <- AtomicTracker :: new( ) ,
17071714 } ) )
17081715 . map ( ListArc :: into_arc)
@@ -1729,7 +1736,16 @@ impl DeliverToRead for ThreadError {
17291736 Ok ( true )
17301737 }
17311738
1732- fn cancel ( self : DArc < Self > ) { }
1739+ fn cancel ( self : DArc < Self > ) {
1740+ let code = self . error_code . load ( Relaxed ) ;
1741+ if code != BR_OK {
1742+ binder_debug ! (
1743+ pid=self . pid,
1744+ DeadTransaction ,
1745+ "undelivered TRANSACTION_ERROR: {code}"
1746+ ) ;
1747+ }
1748+ }
17331749
17341750 fn should_sync_wakeup ( & self ) -> bool {
17351751 false
0 commit comments