Changeset 2130 for pjproject/trunk
- Timestamp:
- Jul 13, 2008 12:24:55 PM (16 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r2094 r2130 3797 3797 3798 3798 /* Create pool for application */ 3799 app_config.pool = pjsua_pool_create("pjsua ", 1000, 1000);3799 app_config.pool = pjsua_pool_create("pjsua-app", 1000, 1000); 3800 3800 3801 3801 /* Initialize default config */ -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r2079 r2130 99 99 typedef struct pjsua_acc 100 100 { 101 pj_pool_t *pool; /**< Pool for this account. */ 101 102 pjsua_acc_config cfg; /**< Account configuration. */ 102 103 pj_bool_t valid; /**< Is this account valid? */ … … 156 157 typedef struct pjsua_buddy 157 158 { 159 pj_pool_t *pool; /**< Pool for this buddy. */ 158 160 unsigned index; /**< Buddy index. */ 159 161 pj_str_t uri; /**< Buddy URI. */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r2039 r2130 109 109 110 110 name_addr = (pjsip_name_addr*) 111 pjsip_parse_uri( pjsua_var.pool, acc_cfg->id.ptr,111 pjsip_parse_uri(acc->pool, acc_cfg->id.ptr, 112 112 acc_cfg->id.slen, 113 113 PJSIP_PARSE_URI_AS_NAMEADDR); … … 137 137 pjsip_uri *reg_uri; 138 138 139 reg_uri = pjsip_parse_uri( pjsua_var.pool, acc_cfg->reg_uri.ptr,139 reg_uri = pjsip_parse_uri(acc->pool, acc_cfg->reg_uri.ptr, 140 140 acc_cfg->reg_uri.slen, 0); 141 141 if (reg_uri == NULL) { … … 188 188 pj_str_t tmp; 189 189 190 pj_strdup_with_null( pjsua_var.pool, &tmp,190 pj_strdup_with_null(acc->pool, &tmp, 191 191 &pjsua_var.ua_cfg.outbound_proxy[i]); 192 192 r = (pjsip_route_hdr*) 193 pjsip_parse_hdr( pjsua_var.pool, &hname, tmp.ptr, tmp.slen, NULL);193 pjsip_parse_hdr(acc->pool, &hname, tmp.ptr, tmp.slen, NULL); 194 194 if (r == NULL) { 195 195 pjsua_perror(THIS_FILE, "Invalid outbound proxy URI", … … 205 205 pj_str_t tmp; 206 206 207 pj_strdup_with_null( pjsua_var.pool, &tmp, &acc_cfg->proxy[i]);207 pj_strdup_with_null(acc->pool, &tmp, &acc_cfg->proxy[i]); 208 208 r = (pjsip_route_hdr*) 209 pjsip_parse_hdr( pjsua_var.pool, &hname, tmp.ptr, tmp.slen, NULL);209 pjsip_parse_hdr(acc->pool, &hname, tmp.ptr, tmp.slen, NULL); 210 210 if (r == NULL) { 211 211 pjsua_perror(THIS_FILE, "Invalid URI in account route set", … … 257 257 pjsua_acc_id *p_acc_id) 258 258 { 259 pjsua_acc *acc; 259 260 unsigned id; 260 261 pj_status_t status; … … 278 279 {PJSUA_UNLOCK(); return PJ_EBUG;}); 279 280 281 acc = &pjsua_var.acc[id]; 282 283 /* Create pool for this account. */ 284 if (acc->pool) 285 pj_pool_reset(acc->pool); 286 else 287 acc->pool = pjsua_pool_create("acc%p", 512, 256); 288 280 289 /* Copy config */ 281 pjsua_acc_config_dup( pjsua_var.pool, &pjsua_var.acc[id].cfg, cfg);290 pjsua_acc_config_dup(acc->pool, &pjsua_var.acc[id].cfg, cfg); 282 291 283 292 /* Normalize registration timeout */ … … 291 300 if (status != PJ_SUCCESS) { 292 301 pjsua_perror(THIS_FILE, "Error adding account", status); 302 pj_pool_release(acc->pool); 303 acc->pool = NULL; 293 304 PJSUA_UNLOCK(); 294 305 return status; … … 400 411 pjsua_pres_delete_acc(acc_id); 401 412 413 /* Release account pool */ 414 if (pjsua_var.acc[acc_id].pool) { 415 pj_pool_release(pjsua_var.acc[acc_id].pool); 416 pjsua_var.acc[acc_id].pool = NULL; 417 } 418 402 419 /* Invalidate */ 403 420 pjsua_var.acc[acc_id].valid = PJ_FALSE; … … 472 489 PJ_ASSERT_RETURN(pjsua_var.acc[acc_id].valid, PJ_EINVALIDOP); 473 490 491 PJSUA_LOCK(); 474 492 pjsua_var.acc[acc_id].online_status = is_online; 475 pjrpid_element_dup(pjsua_var.pool, &pjsua_var.acc[acc_id].rpid, pr); 493 pjrpid_element_dup(pjsua_var.acc[acc_id].pool, &pjsua_var.acc[acc_id].rpid, pr); 494 PJSUA_UNLOCK(); 495 476 496 pjsua_pres_update_acc(acc_id, PJ_TRUE); 477 497 return PJ_SUCCESS; … … 595 615 return PJ_FALSE; 596 616 } 597 pj_strdup2( pjsua_var.pool, &acc->contact, tmp);617 pj_strdup2(acc->pool, &acc->contact, tmp); 598 618 } 599 619 … … 703 723 /* Then append the Service-Route URIs */ 704 724 for (i=0; i<uri_cnt; ++i) { 705 hr = pjsip_route_hdr_create( pjsua_var.pool);706 hr->name_addr.uri = (pjsip_uri*)pjsip_uri_clone( pjsua_var.pool, uri[i]);725 hr = pjsip_route_hdr_create(acc->pool); 726 hr->name_addr.uri = (pjsip_uri*)pjsip_uri_clone(acc->pool, uri[i]); 707 727 pj_list_push_back(&acc->route_set, hr); 708 728 } … … 983 1003 } 984 1004 985 pj_strdup_with_null( pjsua_var.pool, &acc->contact, &tmp_contact);1005 pj_strdup_with_null(acc->pool, &acc->contact, &tmp_contact); 986 1006 } 987 1007 … … 1268 1288 pjsip_uri *uri; 1269 1289 pjsip_sip_uri *sip_uri; 1290 pj_pool_t *tmp_pool; 1270 1291 unsigned i; 1271 1292 1272 1293 PJSUA_LOCK(); 1273 1294 1274 PJ_TODO(dont_use_pjsua_pool);1275 1276 pj_strdup_with_null( pjsua_var.pool, &tmp, url);1277 1278 uri = pjsip_parse_uri( pjsua_var.pool, tmp.ptr, tmp.slen, 0);1295 tmp_pool = pjsua_pool_create("tmpacc10", 256, 256); 1296 1297 pj_strdup_with_null(tmp_pool, &tmp, url); 1298 1299 uri = pjsip_parse_uri(tmp_pool, tmp.ptr, tmp.slen, 0); 1279 1300 if (!uri) { 1301 pj_pool_release(tmp_pool); 1280 1302 PJSUA_UNLOCK(); 1281 1303 return pjsua_var.default_acc; … … 1295 1317 if (i != PJ_ARRAY_SIZE(pjsua_var.acc)) { 1296 1318 /* Found rather matching account */ 1319 pj_pool_release(tmp_pool); 1297 1320 PJSUA_UNLOCK(); 1298 return 0;1321 return i; 1299 1322 } 1300 1323 1301 1324 /* Not found, use default account */ 1325 pj_pool_release(tmp_pool); 1302 1326 PJSUA_UNLOCK(); 1303 1327 return pjsua_var.default_acc; … … 1312 1336 pjsua_var.acc[acc_id].srv_port == sip_uri->port) 1313 1337 { 1338 pj_pool_release(tmp_pool); 1314 1339 PJSUA_UNLOCK(); 1315 1340 return acc_id; … … 1322 1347 if (pj_stricmp(&pjsua_var.acc[acc_id].srv_domain, &sip_uri->host)==0) 1323 1348 { 1349 pj_pool_release(tmp_pool); 1324 1350 PJSUA_UNLOCK(); 1325 1351 return acc_id; … … 1329 1355 1330 1356 /* Still no match, just use default account */ 1357 pj_pool_release(tmp_pool); 1331 1358 PJSUA_UNLOCK(); 1332 1359 return pjsua_var.default_acc; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r2079 r2130 331 331 pjsua_call_id *p_call_id) 332 332 { 333 pj_pool_t *tmp_pool; 333 334 pjsip_dialog *dlg = NULL; 334 335 pjmedia_sdp_session *offer; … … 383 384 call = &pjsua_var.calls[call_id]; 384 385 386 /* Create temporary pool */ 387 tmp_pool = pjsua_pool_create("tmpcall10", 512, 256); 388 385 389 /* Verify that destination URI is valid before calling 386 390 * pjsua_acc_create_uac_contact, or otherwise there … … 389 393 */ 390 394 if (1) { 391 pj_pool_t *pool;392 395 pjsip_uri *uri; 393 396 pj_str_t dup; 394 397 395 pool = pjsua_pool_create("tmp-uri", 4000, 4000); 396 if (!pool) { 397 pjsua_perror(THIS_FILE, "Unable to create pool", PJ_ENOMEM); 398 PJSUA_UNLOCK(); 399 return PJ_ENOMEM; 400 } 401 402 pj_strdup_with_null(pool, &dup, dest_uri); 403 uri = pjsip_parse_uri(pool, dup.ptr, dup.slen, 0); 404 pj_pool_release(pool); 398 pj_strdup_with_null(tmp_pool, &dup, dest_uri); 399 uri = pjsip_parse_uri(tmp_pool, dup.ptr, dup.slen, 0); 405 400 406 401 if (uri == NULL) { 407 402 pjsua_perror(THIS_FILE, "Unable to make call", 408 403 PJSIP_EINVALIDREQURI); 404 pj_pool_release(tmp_pool); 409 405 PJSUA_UNLOCK(); 410 406 return PJSIP_EINVALIDREQURI; … … 427 423 contact = acc->contact; 428 424 } else { 429 status = pjsua_acc_create_uac_contact( pjsua_var.pool, &contact,425 status = pjsua_acc_create_uac_contact(tmp_pool, &contact, 430 426 acc_id, dest_uri); 431 427 if (status != PJ_SUCCESS) { 432 428 pjsua_perror(THIS_FILE, "Unable to generate Contact header", 433 429 status); 430 pj_pool_release(tmp_pool); 434 431 PJSUA_UNLOCK(); 435 432 return status; … … 443 440 if (status != PJ_SUCCESS) { 444 441 pjsua_perror(THIS_FILE, "Dialog creation failed", status); 442 pj_pool_release(tmp_pool); 445 443 PJSUA_UNLOCK(); 446 444 return status; … … 550 548 *p_call_id = call_id; 551 549 550 pj_pool_release(tmp_pool); 552 551 PJSUA_UNLOCK(); 553 552 … … 567 566 } 568 567 568 pj_pool_release(tmp_pool); 569 569 PJSUA_UNLOCK(); 570 570 return status; … … 2618 2618 { 2619 2619 pj_status_t status; 2620 pj_pool_t *pool; 2620 2621 pjmedia_sdp_conn *conn; 2621 2622 pjmedia_sdp_attr *attr; … … 2623 2624 pjmedia_sdp_session *sdp; 2624 2625 2626 /* Use call's pool */ 2627 pool = call->inv->pool; 2628 2625 2629 /* Get media socket info */ 2626 2630 pjmedia_transport_info_init(&tp_info); … … 2628 2632 2629 2633 /* Create new offer */ 2630 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, p jsua_var.pool, 1,2634 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, pool, 1, 2631 2635 &tp_info.sock_info, &sdp); 2632 2636 if (status != PJ_SUCCESS) { … … 2650 2654 2651 2655 /* Add inactive attribute */ 2652 attr = pjmedia_sdp_attr_create(p jsua_var.pool, "inactive", NULL);2656 attr = pjmedia_sdp_attr_create(pool, "inactive", NULL); 2653 2657 pjmedia_sdp_media_add_attr(sdp->media[0], attr); 2654 2658 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r2039 r2130 581 581 582 582 /* Create memory pool for application. */ 583 pjsua_var.pool = pjsua_pool_create("pjsua", 4000, 4000);583 pjsua_var.pool = pjsua_pool_create("pjsua", 1000, 1000); 584 584 585 585 PJ_ASSERT_RETURN(pjsua_var.pool, PJ_ENOMEM); … … 1070 1070 pjsua_pres_shutdown(); 1071 1071 1072 /* Unregister, if required: */ 1072 /* Destroy pool in the buddy object */ 1073 for (i=0; i<(int)PJ_ARRAY_SIZE(pjsua_var.buddy); ++i) { 1074 if (pjsua_var.buddy[i].pool) { 1075 pj_pool_release(pjsua_var.buddy[i].pool); 1076 pjsua_var.buddy[i].pool = NULL; 1077 } 1078 } 1079 1080 /* Destroy accounts */ 1073 1081 for (i=0; i<(int)PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 1074 1082 if (!pjsua_var.acc[i].valid) … … 1077 1085 if (pjsua_var.acc[i].regc) { 1078 1086 pjsua_acc_set_registration(i, PJ_FALSE); 1087 } 1088 1089 if (pjsua_var.acc[i].pool) { 1090 pj_pool_release(pjsua_var.acc[i].pool); 1091 pjsua_var.acc[i].pool = NULL; 1079 1092 } 1080 1093 } -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r2118 r2130 174 174 static void reset_buddy(pjsua_buddy_id id) 175 175 { 176 pj_pool_t *pool = pjsua_var.buddy[id].pool; 176 177 pj_bzero(&pjsua_var.buddy[id], sizeof(pjsua_var.buddy[id])); 178 pjsua_var.buddy[id].pool = pool; 177 179 pjsua_var.buddy[id].index = id; 178 180 } … … 186 188 { 187 189 pjsip_name_addr *url; 190 pjsua_buddy *buddy; 188 191 pjsip_sip_uri *sip_uri; 189 192 int index; … … 210 213 } 211 214 215 buddy = &pjsua_var.buddy[index]; 216 217 /* Create pool for this buddy */ 218 if (buddy->pool) { 219 pj_pool_reset(buddy->pool); 220 } else { 221 char name[PJ_MAX_OBJ_NAME]; 222 pj_ansi_snprintf(name, sizeof(name), "buddy%03d", index); 223 buddy->pool = pjsua_pool_create(name, 512, 256); 224 } 212 225 213 226 /* Get name and display name for buddy */ 214 pj_strdup_with_null( pjsua_var.pool, &tmp, &cfg->uri);215 url = (pjsip_name_addr*)pjsip_parse_uri( pjsua_var.pool, tmp.ptr, tmp.slen,227 pj_strdup_with_null(buddy->pool, &tmp, &cfg->uri); 228 url = (pjsip_name_addr*)pjsip_parse_uri(buddy->pool, tmp.ptr, tmp.slen, 216 229 PJSIP_PARSE_URI_AS_NAMEADDR); 217 230 218 231 if (url == NULL) { 219 232 pjsua_perror(THIS_FILE, "Unable to add buddy", PJSIP_EINVALIDURI); 233 pj_pool_release(buddy->pool); 234 buddy->pool = NULL; 220 235 PJSUA_UNLOCK(); 221 236 return PJSIP_EINVALIDURI; … … 223 238 224 239 /* Only support SIP schemes */ 225 if (!PJSIP_URI_SCHEME_IS_SIP(url) && !PJSIP_URI_SCHEME_IS_SIPS(url)) 240 if (!PJSIP_URI_SCHEME_IS_SIP(url) && !PJSIP_URI_SCHEME_IS_SIPS(url)) { 241 pj_pool_release(buddy->pool); 242 buddy->pool = NULL; 243 PJSUA_UNLOCK(); 226 244 return PJSIP_EINVALIDSCHEME; 245 } 227 246 228 247 /* Reset buddy, to make sure everything is cleared with default … … 1050 1069 1051 1070 buddy->contact.ptr = (char*) 1052 pj_pool_alloc( pjsua_var.pool, PJSIP_MAX_URL_SIZE);1071 pj_pool_alloc(buddy->pool, PJSIP_MAX_URL_SIZE); 1053 1072 buddy->contact.slen = pjsip_uri_print( PJSIP_URI_IN_CONTACT_HDR, 1054 1073 contact_hdr->uri, … … 1117 1136 static void subscribe_buddy_presence(unsigned index) 1118 1137 { 1138 pj_pool_t *tmp_pool = NULL; 1119 1139 pjsua_buddy *buddy; 1120 1140 int acc_id; … … 1138 1158 contact = acc->contact; 1139 1159 } else { 1140 status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact, 1160 tmp_pool = pjsua_pool_create("tmpbuddy", 512, 256); 1161 1162 status = pjsua_acc_create_uac_contact(tmp_pool, &contact, 1141 1163 acc_id, &buddy->uri); 1142 1164 if (status != PJ_SUCCESS) { 1143 1165 pjsua_perror(THIS_FILE, "Unable to generate Contact header", 1144 1166 status); 1167 pj_pool_release(tmp_pool); 1145 1168 return; 1146 1169 } … … 1156 1179 pjsua_perror(THIS_FILE, "Unable to create dialog", 1157 1180 status); 1181 if (tmp_pool) pj_pool_release(tmp_pool); 1158 1182 return; 1159 1183 } … … 1166 1190 status); 1167 1191 pjsip_dlg_terminate(buddy->dlg); 1192 if (tmp_pool) pj_pool_release(tmp_pool); 1168 1193 return; 1169 1194 } … … 1203 1228 pjsua_perror(THIS_FILE, "Unable to create initial SUBSCRIBE", 1204 1229 status); 1230 if (tmp_pool) pj_pool_release(tmp_pool); 1205 1231 return; 1206 1232 } … … 1216 1242 pjsua_perror(THIS_FILE, "Unable to send initial SUBSCRIBE", 1217 1243 status); 1244 if (tmp_pool) pj_pool_release(tmp_pool); 1218 1245 return; 1219 1246 } 1247 1248 if (tmp_pool) pj_pool_release(tmp_pool); 1220 1249 } 1221 1250
Note: See TracChangeset
for help on using the changeset viewer.