core/sip/trans_layer.cpp
... | ... |
@@ -1836,13 +1836,24 @@ int _trans_layer::update_uac_reply(trans_bucket* bucket, sip_trans* t, sip_msg* |
1836 | 1836 |
|
1837 | 1837 |
if(reply_code >= 300){ |
1838 | 1838 |
|
1839 |
- if(reply_code == 503) { |
|
1840 |
- if(default_bl_ttl) { |
|
1839 |
+ bool forget_reply = false; |
|
1840 |
+ if(reply_code == 503 && |
|
1841 |
+ (t->state == TS_CALLING || |
|
1842 |
+ t->state == TS_PROCEEDING)) { |
|
1843 |
+ |
|
1844 |
+ if(!(t->flags & TR_FLAG_DISABLE_BL)) { |
|
1841 | 1845 |
tr_blacklist::instance()->insert(&t->msg->remote_ip, |
1842 | 1846 |
default_bl_ttl,"503"); |
1843 | 1847 |
} |
1844 |
- if(!try_next_ip(bucket,t,false)) |
|
1845 |
- goto end; |
|
1848 |
+ |
|
1849 |
+ if(msg->local_socket) { // remote reply |
|
1850 |
+ if(!try_next_ip(bucket,t,true)) |
|
1851 |
+ forget_reply = true; |
|
1852 |
+ } |
|
1853 |
+ else { // local reply |
|
1854 |
+ if(!try_next_ip(bucket,t,false)) |
|
1855 |
+ goto end; |
|
1856 |
+ } |
|
1846 | 1857 |
} |
1847 | 1858 |
|
1848 | 1859 |
// Final error reply |
... | ... |
@@ -1860,6 +1871,9 @@ int _trans_layer::update_uac_reply(trans_bucket* bucket, sip_trans* t, sip_msg* |
1860 | 1871 |
send_non_200_ack(msg,t); |
1861 | 1872 |
t->reset_timer(STIMER_D, D_TIMER, bucket->get_id()); |
1862 | 1873 |
|
1874 |
+ if(forget_reply) |
|
1875 |
+ goto end; |
|
1876 |
+ |
|
1863 | 1877 |
goto pass_reply; |
1864 | 1878 |
|
1865 | 1879 |
case TS_ABANDONED: |
... | ... |
@@ -2488,7 +2502,11 @@ void _trans_layer::timer_expired(trans_timer* t, trans_bucket* bucket, |
2488 | 2502 |
} break; |
2489 | 2503 |
|
2490 | 2504 |
case STIMER_M: { |
2491 |
- try_next_ip(bucket,tr,true); |
|
2505 |
+ if(!try_next_ip(bucket,tr,true)) { |
|
2506 |
+ // Abandon old transaction |
|
2507 |
+ tr->clear_timer(STIMER_A); |
|
2508 |
+ tr->state = TS_ABANDONED; |
|
2509 |
+ } |
|
2492 | 2510 |
} break; |
2493 | 2511 |
|
2494 | 2512 |
case STIMER_BL: |
... | ... |
@@ -2654,10 +2672,6 @@ int _trans_layer::try_next_ip(trans_bucket* bucket, sip_trans* tr, |
2654 | 2672 |
tmp_msg.release(); |
2655 | 2673 |
n_tr->msg = p_msg; |
2656 | 2674 |
|
2657 |
- // Abandon old transaction |
|
2658 |
- tr->clear_timer(STIMER_A); |
|
2659 |
- tr->state = TS_ABANDONED; |
|
2660 |
- |
|
2661 | 2675 |
// take over target set |
2662 | 2676 |
n_tr->targets = tr->targets; |
2663 | 2677 |
tr->targets = NULL; |