Changeset 4735 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
- Timestamp:
- Feb 6, 2014 5:09:52 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r4704 r4735 1239 1239 sess->srv[sess->idx].ptr, errmsg)); 1240 1240 1241 sess->status = status;1242 1243 1241 pj_stun_sock_destroy(stun_sock); 1244 1242 sess->stun_sock = NULL; 1245 1243 1246 1244 ++sess->idx; 1245 if (sess->idx >= sess->count) 1246 sess->status = status; 1247 1247 1248 resolve_stun_entry(sess); 1248 1249 … … 1274 1275 static void resolve_stun_entry(pjsua_stun_resolve *sess) 1275 1276 { 1277 pj_status_t status = PJ_EUNKNOWN; 1278 1276 1279 stun_resolve_add_ref(sess); 1277 1280 … … 1291 1294 1292 1295 /* Parse the server entry into host:port */ 1293 s ess->status = pj_sockaddr_parse2(af, 0, &sess->srv[sess->idx],1296 status = pj_sockaddr_parse2(af, 0, &sess->srv[sess->idx], 1294 1297 &hostpart, &port, NULL); 1295 if (s ess->status != PJ_SUCCESS) {1296 PJ_LOG(2,(THIS_FILE, "Invalid STUN server entry %s", target));1298 if (status != PJ_SUCCESS) { 1299 PJ_LOG(2,(THIS_FILE, "Invalid STUN server entry %s", target)); 1297 1300 continue; 1298 1301 } … … 1310 1313 pj_bzero(&stun_sock_cb, sizeof(stun_sock_cb)); 1311 1314 stun_sock_cb.on_status = &test_stun_on_status; 1312 s ess->status = pj_stun_sock_create(&pjsua_var.stun_cfg, "stunresolve",1315 status = pj_stun_sock_create(&pjsua_var.stun_cfg, "stunresolve", 1313 1316 pj_AF_INET(), &stun_sock_cb, 1314 1317 NULL, sess, &sess->stun_sock); 1315 if (s ess->status != PJ_SUCCESS) {1318 if (status != PJ_SUCCESS) { 1316 1319 char errmsg[PJ_ERR_MSG_SIZE]; 1317 pj_strerror(s ess->status, errmsg, sizeof(errmsg));1320 pj_strerror(status, errmsg, sizeof(errmsg)); 1318 1321 PJ_LOG(4,(THIS_FILE, 1319 1322 "Error creating STUN socket for %s: %s", … … 1323 1326 } 1324 1327 1325 s ess->status = pj_stun_sock_start(sess->stun_sock, &hostpart,1328 status = pj_stun_sock_start(sess->stun_sock, &hostpart, 1326 1329 port, pjsua_var.resolver); 1327 if (s ess->status != PJ_SUCCESS) {1330 if (status != PJ_SUCCESS) { 1328 1331 char errmsg[PJ_ERR_MSG_SIZE]; 1329 pj_strerror(s ess->status, errmsg, sizeof(errmsg));1332 pj_strerror(status, errmsg, sizeof(errmsg)); 1330 1333 PJ_LOG(4,(THIS_FILE, 1331 1334 "Error starting STUN socket for %s: %s", … … 1347 1350 if (sess->idx >= sess->count) { 1348 1351 /* No more entries to try */ 1349 PJ_ASSERT_ON_FAIL(sess->status != PJ_SUCCESS, 1350 sess->status = PJ_EUNKNOWN); 1352 pj_assert(status != PJ_SUCCESS || sess->status != PJ_EPENDING); 1353 if (sess->status == PJ_EPENDING) 1354 sess->status = status; 1351 1355 stun_resolve_complete(sess); 1352 1356 } … … 1399 1403 1400 1404 while (sess->status == PJ_EPENDING) { 1401 pjsua_handle_events(50); 1405 /* If there is no worker thread or 1406 * the function is called from the only worker thread, 1407 * we have to handle the events here. 1408 */ 1409 if (pjsua_var.thread[0] == NULL || 1410 (pj_thread_this() == pjsua_var.thread[0] && 1411 pjsua_var.ua_cfg.thread_cnt == 1)) 1412 { 1413 pjsua_handle_events(50); 1414 } else { 1415 pj_thread_sleep(20); 1416 } 1402 1417 } 1403 1418 … … 1485 1500 if (wait) { 1486 1501 while (pjsua_var.stun_status == PJ_EPENDING) { 1487 if (pjsua_var.thread[0] == NULL) 1502 /* If there is no worker thread or 1503 * the function is called from the only worker thread, 1504 * we have to handle the events here. 1505 */ 1506 if (pjsua_var.thread[0] == NULL || 1507 (pj_thread_this() == pjsua_var.thread[0] && 1508 pjsua_var.ua_cfg.thread_cnt == 1)) 1509 { 1488 1510 pjsua_handle_events(10); 1489 else 1511 } else { 1490 1512 pj_thread_sleep(10); 1513 } 1491 1514 } 1492 1515 }
Note: See TracChangeset
for help on using the changeset viewer.