Changeset 5884
- Timestamp:
- Sep 14, 2018 1:27:32 AM (6 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_transport.h
r5851 r5884 222 222 * should be used to send request. This structure is used when calling 223 223 * pjsip_tsx_set_transport() and pjsip_dlg_set_transport(). 224 * 225 * If application disables connection reuse and wants to force creating 226 * a new transport, it needs to consider the following couple of things: 227 * - If it still wants to reuse an existing transport (if any), it 228 * needs to keep a reference to that transport and specifically set 229 * the transport to be used for sending requests. 230 * - Delete those existing transports manually when no longer needed. 224 231 */ 225 232 typedef struct pjsip_tpselector … … 227 234 /** The type of data in the union */ 228 235 pjsip_tpselector_type type; 236 237 /** 238 * Whether to disable reuse of an existing connection. 239 * This setting will be ignored if (type == PJSIP_TPSELECTOR_TRANSPORT) 240 * and transport in the union below is set. 241 */ 242 pj_bool_t disable_connection_reuse; 229 243 230 244 /** Union representing the transport/listener criteria to be used. */ -
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r5851 r5884 2120 2120 pjsip_transport_key key; 2121 2121 int key_len; 2122 pjsip_transport *transport ;2122 pjsip_transport *transport = NULL; 2123 2123 2124 2124 /* If listener is specified, verify that the listener type matches … … 2133 2133 } 2134 2134 2135 pj_bzero(&key, sizeof(key)); 2136 key_len = sizeof(key.type) + addr_len; 2137 2138 /* First try to get exact destination. */ 2139 key.type = type; 2140 pj_memcpy(&key.rem_addr, remote, addr_len); 2141 2142 transport = (pjsip_transport*) 2143 pj_hash_get(mgr->table, &key, key_len, NULL); 2144 2145 if (transport == NULL) { 2135 if (!sel || sel->disable_connection_reuse == PJ_FALSE) { 2136 pj_bzero(&key, sizeof(key)); 2137 key_len = sizeof(key.type) + addr_len; 2138 2139 /* First try to get exact destination. */ 2140 key.type = type; 2141 pj_memcpy(&key.rem_addr, remote, addr_len); 2142 2143 transport = (pjsip_transport*) 2144 pj_hash_get(mgr->table, &key, key_len, NULL); 2145 } 2146 2147 if (transport == NULL && 2148 (!sel || sel->disable_connection_reuse == PJ_FALSE)) 2149 { 2146 2150 unsigned flag = pjsip_transport_get_flag_from_type(type); 2147 2151 const pj_sockaddr *remote_addr = (const pj_sockaddr*)remote; … … 2181 2185 /* This will cause a new transport to be created which will be a 2182 2186 * 'duplicate' of the existing transport (same type & remote addr, 2183 * but different factory). Any future hash lookup will return 2184 * the new one, and eventually the old one will still be freed 2185 * (by application or #1774). 2187 * but different factory). 2186 2188 */ 2187 2189 } … … 2201 2203 2202 2204 /* 2203 * Transport not found! 2204 * So we need to create one, find factory that can create 2205 * such transport. 2205 * Either transport not found, or we don't want to use the existing 2206 * transport (such as in the case of different factory or 2207 * if connection reuse is disabled). So we need to create one, 2208 * find factory that can create such transport. 2209 * 2210 * If there's an existing transport, its place in the hash table 2211 * will be replaced by this new one. And eventually the existing 2212 * transport will still be freed (by application or #1774). 2206 2213 */ 2207 2214 if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener)
Note: See TracChangeset
for help on using the changeset viewer.