@@ -189,6 +189,12 @@ pub(super) type DialogInnerRef = Arc<DialogInner>;
189189pub ( super ) type TuSenderRef = Mutex < Option < TransactionEventSender > > ;
190190
191191impl DialogState {
192+ pub fn can_cancel ( & self ) -> bool {
193+ matches ! (
194+ self ,
195+ DialogState :: Calling ( _) | DialogState :: Trying ( _) | DialogState :: Early ( _, _)
196+ )
197+ }
192198 pub fn is_confirmed ( & self ) -> bool {
193199 matches ! ( self , DialogState :: Confirmed ( _) )
194200 }
@@ -258,6 +264,9 @@ impl DialogInner {
258264 remote_contact : Mutex :: new ( None ) ,
259265 } )
260266 }
267+ pub fn can_cancel ( & self ) -> bool {
268+ self . state . lock ( ) . unwrap ( ) . can_cancel ( )
269+ }
261270 pub fn is_confirmed ( & self ) -> bool {
262271 self . state . lock ( ) . unwrap ( ) . is_confirmed ( )
263272 }
@@ -440,13 +449,11 @@ impl DialogInner {
440449 Err ( e) => {
441450 warn ! (
442451 id = self . id. lock( ) . unwrap( ) . to_string( ) ,
443- method = %method,
444- destination=?tx. destination, "failed to send request: {}" , e) ;
452+ destination=?tx. destination, "failed to send request error: {}\n {}" , e, tx. original) ;
445453 return Err ( e) ;
446454 }
447455 }
448456 let mut auth_sent = false ;
449-
450457 while let Some ( msg) = tx. receive ( ) . await {
451458 match msg {
452459 SipMessage :: Response ( resp) => match resp. status_code {
@@ -460,7 +467,10 @@ impl DialogInner {
460467 StatusCode :: ProxyAuthenticationRequired | StatusCode :: Unauthorized => {
461468 let id = self . id . lock ( ) . unwrap ( ) . clone ( ) ;
462469 if auth_sent {
463- info ! ( "received {} response after auth sent" , resp. status_code) ;
470+ info ! (
471+ id = self . id. lock( ) . unwrap( ) . to_string( ) ,
472+ "received {} response after auth sent" , resp. status_code
473+ ) ;
464474 self . transition ( DialogState :: Terminated (
465475 id,
466476 TerminatedReason :: ProxyAuthRequired ,
@@ -477,15 +487,22 @@ impl DialogInner {
477487 tx. send ( ) . await ?;
478488 continue ;
479489 } else {
480- info ! ( "received 407 response without auth option" ) ;
490+ info ! (
491+ id = self . id. lock( ) . unwrap( ) . to_string( ) ,
492+ "received 407 response without auth option"
493+ ) ;
481494 self . transition ( DialogState :: Terminated (
482495 id,
483496 TerminatedReason :: ProxyAuthRequired ,
484497 ) ) ?;
485498 }
486499 }
487500 _ => {
488- debug ! ( "dialog do_request done: {:?}" , resp. status_code) ;
501+ debug ! (
502+ id = self . id. lock( ) . unwrap( ) . to_string( ) ,
503+ method = %method,
504+ "dialog do_request done: {:?}" , resp. status_code
505+ ) ;
489506 return Ok ( Some ( resp) ) ;
490507 }
491508 } ,
0 commit comments