Changeset 5152 for pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c
- Timestamp:
- Aug 7, 2015 9:00:52 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c
r5105 r5152 259 259 pj_sockaddr *listener_addr; 260 260 int addr_len; 261 pj_bool_t has_listener = PJ_FALSE; 261 262 pj_status_t status; 262 263 … … 279 280 } 280 281 281 pool = pjsip_endpt_create_pool(endpt, "tcp lis", POOL_LIS_INIT,282 pool = pjsip_endpt_create_pool(endpt, "tcptp", POOL_LIS_INIT, 282 283 POOL_LIS_INC); 283 284 PJ_ASSERT_RETURN(pool, PJ_ENOMEM); … … 298 299 sizeof(cfg->sockopt_params)); 299 300 300 pj_ansi_strcpy(listener->factory.obj_name, "tcp lis");301 pj_ansi_strcpy(listener->factory.obj_name, "tcptp"); 301 302 if (listener->factory.type==PJSIP_TRANSPORT_TCP6) 302 303 pj_ansi_strcat(listener->factory.obj_name, "6"); … … 307 308 goto on_error; 308 309 310 #if !(defined(PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER) && \ 311 PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER != 0) 309 312 310 313 /* Create socket */ … … 333 336 status = pj_sock_setsockopt_params(sock, &cfg->sockopt_params); 334 337 338 #else 339 PJ_UNUSED_ARG(addr_len); 340 #endif 341 335 342 /* Bind address may be different than factory.local_addr because 336 343 * factory.local_addr will be resolved below. … … 341 348 listener_addr = &listener->factory.local_addr; 342 349 pj_sockaddr_cp(listener_addr, &cfg->bind_addr); 350 351 #if !(defined(PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER) && \ 352 PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER != 0) 343 353 344 354 status = pj_sock_bind(sock, listener_addr, … … 352 362 if (status != PJ_SUCCESS) 353 363 goto on_error; 364 365 #endif 354 366 355 367 /* If published host/IP is specified, then use that address as the … … 393 405 pj_ansi_snprintf(listener->factory.obj_name, 394 406 sizeof(listener->factory.obj_name), 395 "tcplis:%d", listener->factory.addr_name.port); 396 407 "tcptp:%d", listener->factory.addr_name.port); 408 409 410 #if !(defined(PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER) && \ 411 PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER != 0) 397 412 398 413 /* Start listening to the address */ … … 409 424 asock_cfg.async_cnt = cfg->async_cnt; 410 425 426 #endif 427 411 428 /* Create group lock */ 412 429 status = pj_grp_lock_create(pool, NULL, &listener->grp_lock); … … 422 439 pj_bzero(&listener_cb, sizeof(listener_cb)); 423 440 listener_cb.on_accept_complete = &on_accept_complete; 441 442 #if !(defined(PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER) && \ 443 PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER != 0) 444 424 445 status = pj_activesock_create(pool, sock, pj_SOCK_STREAM(), &asock_cfg, 425 446 pjsip_endpt_get_ioqueue(endpt), 426 447 &listener_cb, listener, 427 448 &listener->asock); 449 450 #endif 428 451 429 452 /* Register to transport manager */ … … 440 463 } 441 464 465 #if !(defined(PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER) && \ 466 PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER != 0) 467 442 468 /* Start pending accept() operations */ 443 469 status = pj_activesock_start_accept(listener->asock, pool); 444 470 if (status != PJ_SUCCESS) 445 471 goto on_error; 446 447 PJ_LOG(4,(listener->factory.obj_name, 448 "SIP TCP listener ready for incoming connections at %.*s:%d", 449 (int)listener->factory.addr_name.host.slen, 450 listener->factory.addr_name.host.ptr, 451 listener->factory.addr_name.port)); 472 473 has_listener = PJ_TRUE; 474 475 #endif 476 477 if (has_listener) { 478 PJ_LOG(4,(listener->factory.obj_name, 479 "SIP TCP listener ready for incoming connections at %.*s:%d", 480 (int)listener->factory.addr_name.host.slen, 481 listener->factory.addr_name.host.ptr, 482 listener->factory.addr_name.port)); 483 } else { 484 PJ_LOG(4,(listener->factory.obj_name, "SIP TCP is ready " 485 "(client only)")); 486 } 452 487 453 488 /* Return the pointer to user */ … … 519 554 pj_pool_t *pool = listener->factory.pool; 520 555 521 PJ_LOG(4,(listener->factory.obj_name, "SIP TCP listenerdestroyed"));556 PJ_LOG(4,(listener->factory.obj_name, "SIP TCP transport destroyed")); 522 557 523 558 listener->factory.pool = NULL;
Note: See TracChangeset
for help on using the changeset viewer.