Changeset 3138 for pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
- Timestamp:
- Apr 14, 2010 6:57:35 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
r3114 r3138 181 181 static void tsx_timer_callback( pj_timer_heap_t *theap, 182 182 pj_timer_entry *entry); 183 static void tsx_tp_state_callback( 184 pjsip_transport *tp, 185 pjsip_transport_state state, 186 const pjsip_transport_state_info *info); 183 187 static pj_status_t tsx_create( pjsip_module *tsx_user, 184 188 pjsip_transaction **p_tsx); … … 188 192 static int tsx_send_msg( pjsip_transaction *tsx, 189 193 pjsip_tx_data *tdata); 194 static void tsx_update_transport( pjsip_transaction *tsx, 195 pjsip_transport *tp); 190 196 191 197 … … 986 992 struct tsx_lock_data *lck; 987 993 988 /* Decrement transport reference counter. */ 989 if (tsx->transport) { 990 pjsip_transport_dec_ref( tsx->transport ); 991 tsx->transport = NULL; 992 } 994 /* Release the transport */ 995 tsx_update_transport(tsx, NULL); 996 993 997 /* Decrement reference counter in transport selector */ 994 998 pjsip_tpselector_dec_ref(&tsx->tp_sel); … … 1405 1409 */ 1406 1410 if (tsx->res_addr.transport) { 1407 tsx->transport = tsx->res_addr.transport; 1408 pjsip_transport_add_ref(tsx->transport); 1411 tsx_update_transport(tsx, tsx->res_addr.transport); 1409 1412 pj_memcpy(&tsx->addr, &tsx->res_addr.addr, tsx->res_addr.addr_len); 1410 1413 tsx->addr_len = tsx->res_addr.addr_len; … … 1676 1679 if (tsx->transport != send_state->cur_transport) { 1677 1680 /* Update transport. */ 1678 if (tsx->transport) { 1679 pjsip_transport_dec_ref(tsx->transport); 1680 tsx->transport = NULL; 1681 } 1682 tsx->transport = send_state->cur_transport; 1683 pjsip_transport_add_ref(tsx->transport); 1681 tsx_update_transport(tsx, send_state->cur_transport); 1684 1682 1685 1683 /* Update remote address. */ … … 1730 1728 * release the transport. 1731 1729 */ 1732 if (send_state->cur_transport==tsx->transport && 1733 tsx->transport != NULL) 1734 { 1735 pjsip_transport_dec_ref(tsx->transport); 1736 tsx->transport = NULL; 1737 } 1730 if (send_state->cur_transport==tsx->transport) 1731 tsx_update_transport(tsx, NULL); 1738 1732 1739 1733 /* Also stop processing if transaction has been flagged with … … 1837 1831 lock_tsx(tsx, &lck); 1838 1832 1839 /* Dereference transport. */ 1840 pjsip_transport_dec_ref(tsx->transport); 1841 tsx->transport = NULL; 1833 /* Release transport. */ 1834 tsx_update_transport(tsx, NULL); 1842 1835 1843 1836 /* Terminate transaction. */ … … 1849 1842 } 1850 1843 } 1844 1845 1846 /* 1847 * Callback when transport state changes. 1848 */ 1849 static void tsx_tp_state_callback( pjsip_transport *tp, 1850 pjsip_transport_state state, 1851 const pjsip_transport_state_info *info) 1852 { 1853 if (state == PJSIP_TP_STATE_DISCONNECTED) { 1854 pjsip_transaction *tsx; 1855 struct tsx_lock_data lck; 1856 1857 pj_assert(tp && info && info->user_data); 1858 1859 tsx = (pjsip_transaction*)info->user_data; 1860 1861 lock_tsx(tsx, &lck); 1862 1863 /* Terminate transaction when transport disconnected */ 1864 if (tsx->state < PJSIP_TSX_STATE_TERMINATED) { 1865 pj_str_t err; 1866 char errmsg[PJ_ERR_MSG_SIZE]; 1867 1868 err = pj_strerror(info->status, errmsg, sizeof(errmsg)); 1869 tsx_set_status_code(tsx, PJSIP_SC_TSX_TRANSPORT_ERROR, &err); 1870 tsx_set_state( tsx, PJSIP_TSX_STATE_TERMINATED, 1871 PJSIP_EVENT_TRANSPORT_ERROR, NULL); 1872 } 1873 1874 unlock_tsx(tsx, &lck); 1875 } 1876 } 1877 1851 1878 1852 1879 /* … … 1887 1914 * resolution procedure. 1888 1915 */ 1889 if (tsx->transport) { 1890 pjsip_transport_dec_ref(tsx->transport); 1891 tsx->transport = NULL; 1892 } 1916 tsx_update_transport(tsx, NULL); 1917 1893 1918 tsx->addr_len = 0; 1894 1919 tsx->res_addr.transport = NULL; … … 2096 2121 2097 2122 return PJ_SUCCESS; 2123 } 2124 2125 static void tsx_update_transport( pjsip_transaction *tsx, 2126 pjsip_transport *tp) 2127 { 2128 pj_assert(tsx); 2129 2130 if (tsx->transport) { 2131 pjsip_transport_remove_state_listener(tsx->transport, 2132 tsx->tp_st_key, tsx); 2133 pjsip_transport_dec_ref( tsx->transport ); 2134 tsx->transport = NULL; 2135 } 2136 2137 if (tp) { 2138 tsx->transport = tp; 2139 pjsip_transport_add_ref(tp); 2140 pjsip_transport_add_state_listener(tp, &tsx_tp_state_callback, tsx, 2141 &tsx->tp_st_key); 2142 } 2098 2143 } 2099 2144
Note: See TracChangeset
for help on using the changeset viewer.