- Timestamp:
- Sep 18, 2018 12:07:50 PM (6 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/ssl_sock.h
r5821 r5885 606 606 /** 607 607 * This callback is called when new connection arrives as the result 608 * of pj_ssl_sock_start_accept(). 608 * of pj_ssl_sock_start_accept(). If the status of accept operation is 609 * needed use on_accept_complete2 instead of this callback. 609 610 * 610 611 * @param ssock The secure socket. … … 622 623 const pj_sockaddr_t *src_addr, 623 624 int src_addr_len); 625 /** 626 * This callback is called when new connection arrives as the result 627 * of pj_ssl_sock_start_accept(). 628 * 629 * @param asock The active socket. 630 * @param newsock The new incoming socket. 631 * @param src_addr The source address of the connection. 632 * @param addr_len Length of the source address. 633 * @param status The status of the accept operation. This may contain 634 * non-PJ_SUCCESS for example when the TCP listener is in 635 * bad state for example on iOS platform after the 636 * application waking up from background. 637 * 638 * @return PJ_TRUE if further accept() is desired, and PJ_FALSE 639 * when application no longer wants to accept incoming 640 * connection. Application may destroy the active socket 641 * in the callback and return PJ_FALSE here. 642 */ 643 pj_bool_t (*on_accept_complete2)(pj_ssl_sock_t *ssock, 644 pj_ssl_sock_t *newsock, 645 const pj_sockaddr_t *src_addr, 646 int src_addr_len, 647 pj_status_t status); 624 648 625 649 /** -
pjproject/trunk/pjlib/src/pj/ssl_sock_ossl.c
r5821 r5885 1710 1710 errmsg)); 1711 1711 1712 if (*ssock->param.cb.on_accept_complete2) { 1713 (*ssock->param.cb.on_accept_complete2) 1714 (ssock->parent, ssock, (pj_sockaddr_t*)&ssock->rem_addr, 1715 pj_sockaddr_get_len((pj_sockaddr_t*)&ssock->rem_addr), 1716 status); 1717 } 1718 1712 1719 /* Originally, this is a workaround for ticket #985. However, 1713 1720 * a race condition may occur in multiple worker threads … … 1749 1756 } 1750 1757 /* Notify application the newly accepted SSL socket */ 1751 if (ssock->param.cb.on_accept_complete) { 1758 if (ssock->param.cb.on_accept_complete2) { 1759 pj_bool_t ret; 1760 ret = (*ssock->param.cb.on_accept_complete2) 1761 (ssock->parent, ssock, (pj_sockaddr_t*)&ssock->rem_addr, 1762 pj_sockaddr_get_len((pj_sockaddr_t*)&ssock->rem_addr), 1763 status); 1764 if (ret == PJ_FALSE) 1765 return PJ_FALSE; 1766 } else if (ssock->param.cb.on_accept_complete) { 1752 1767 pj_bool_t ret; 1753 1768 ret = (*ssock->param.cb.on_accept_complete) … … 2520 2535 2521 2536 2537 static pj_bool_t asock_on_accept_complete2(pj_activesock_t *asock, 2538 pj_sock_t newsock, 2539 const pj_sockaddr_t *src_addr, 2540 int src_addr_len, 2541 pj_status_t status) 2542 { 2543 pj_bool_t ret = PJ_TRUE; 2544 if (status != PJ_SUCCESS) { 2545 pj_ssl_sock_t *ssock = (pj_ssl_sock_t*) 2546 pj_activesock_get_user_data(asock); 2547 2548 if (ssock->param.cb.on_accept_complete2) { 2549 (*ssock->param.cb.on_accept_complete2) (ssock->parent, ssock, 2550 src_addr, src_addr_len, 2551 status); 2552 } 2553 } else { 2554 ret = asock_on_accept_complete(asock, newsock, src_addr, src_addr_len); 2555 } 2556 return ret; 2557 } 2558 2559 2522 2560 static pj_bool_t asock_on_connect_complete (pj_activesock_t *asock, 2523 2561 pj_status_t status) … … 3426 3464 3427 3465 pj_bzero(&asock_cb, sizeof(asock_cb)); 3428 asock_cb.on_accept_complete = asock_on_accept_complete; 3466 //asock_cb.on_accept_complete = asock_on_accept_complete; 3467 asock_cb.on_accept_complete2 = asock_on_accept_complete2; 3429 3468 3430 3469 status = pj_activesock_create(pool, -
pjproject/trunk/pjsip/include/pjsip/sip_transport_tls.h
r5821 r5885 76 76 77 77 /** 78 * This structure describe the parameter passed from #on_accept_fail_cb(). 79 */ 80 typedef struct pjsip_tls_on_accept_fail_param { 81 /** 82 * Remote address of the fail accept operation of the TLS listener. 83 */ 84 const pj_sockaddr_t *remote_addr; 85 86 /** 87 * Error status of the fail accept operation of the TLS listener. 88 */ 89 pj_status_t status; 90 91 } pjsip_tls_on_accept_fail_param; 92 93 /** 78 94 * TLS transport settings. 79 95 */ … … 307 323 */ 308 324 pj_bool_t sockopt_ignore_error; 325 326 /** 327 * Callback to be called when a accept operation of the TLS listener fails. 328 * 329 * @param param The parameter to the callback. 330 */ 331 void(*on_accept_fail_cb)(const pjsip_tls_on_accept_fail_param *param); 309 332 310 333 } pjsip_tls_setting; -
pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c
r5854 r5885 122 122 123 123 /* This callback is called when pending accept() operation completes. */ 124 static pj_bool_t on_accept_complete (pj_ssl_sock_t *ssock,124 static pj_bool_t on_accept_complete2(pj_ssl_sock_t *ssock, 125 125 pj_ssl_sock_t *new_ssock, 126 126 const pj_sockaddr_t *src_addr, 127 int src_addr_len); 127 int src_addr_len, 128 pj_status_t status); 128 129 129 130 /* Callback on incoming data */ … … 295 296 pj_ssl_sock_param_default(ssock_param); 296 297 ssock_param->sock_af = af; 297 ssock_param->cb.on_accept_complete = &on_accept_complete;298 ssock_param->cb.on_accept_complete2 = &on_accept_complete2; 298 299 ssock_param->async_cnt = listener->async_cnt; 299 300 ssock_param->ioqueue = pjsip_endpt_get_ioqueue(listener->endpt); … … 1301 1302 1302 1303 1303 /* 1304 * This callback is called by SSL socket when pending accept() operation 1305 * has completed. 1306 */ 1307 static pj_bool_t on_accept_complete(pj_ssl_sock_t *ssock, 1308 pj_ssl_sock_t *new_ssock, 1309 const pj_sockaddr_t *src_addr, 1310 int src_addr_len) 1311 { 1304 static pj_bool_t on_accept_complete2(pj_ssl_sock_t *ssock, 1305 pj_ssl_sock_t *new_ssock, 1306 const pj_sockaddr_t *src_addr, 1307 int src_addr_len, 1308 pj_status_t accept_status) 1309 { 1312 1310 struct tls_listener *listener; 1313 1311 struct tls_transport *tls; … … 1324 1322 listener = (struct tls_listener*) pj_ssl_sock_get_user_data(ssock); 1325 1323 1324 if (accept_status != PJ_SUCCESS) { 1325 if (listener->tls_setting.on_accept_fail_cb) { 1326 pjsip_tls_on_accept_fail_param param; 1327 pj_bzero(¶m, sizeof(param)); 1328 param.status = accept_status; 1329 param.remote_addr = src_addr; 1330 (*listener->tls_setting.on_accept_fail_cb) (¶m); 1331 } 1332 1333 return PJ_FALSE; 1334 } 1335 1326 1336 PJ_ASSERT_RETURN(new_ssock, PJ_TRUE); 1327 1337 1328 if (!listener->is_registered) 1338 if (!listener->is_registered) { 1339 if (listener->tls_setting.on_accept_fail_cb) { 1340 pjsip_tls_on_accept_fail_param param; 1341 pj_bzero(¶m, sizeof(param)); 1342 param.status = PJSIP_TLS_EACCEPT; 1343 param.remote_addr = src_addr; 1344 (*listener->tls_setting.on_accept_fail_cb) (¶m); 1345 } 1329 1346 return PJ_FALSE; 1347 } 1330 1348 1331 1349 PJ_LOG(4,(listener->factory.obj_name, … … 1344 1362 if (status != PJ_SUCCESS) { 1345 1363 pj_ssl_sock_close(new_ssock); 1364 1365 if (listener->tls_setting.on_accept_fail_cb) { 1366 pjsip_tls_on_accept_fail_param param; 1367 pj_bzero(¶m, sizeof(param)); 1368 param.status = status; 1369 param.remote_addr = src_addr; 1370 (*listener->tls_setting.on_accept_fail_cb) (¶m); 1371 } 1346 1372 return PJ_TRUE; 1347 1373 } … … 1358 1384 &ssl_info.local_addr, &tmp_src_addr, NULL, &tls); 1359 1385 1360 if (status != PJ_SUCCESS) 1386 if (status != PJ_SUCCESS) { 1387 if (listener->tls_setting.on_accept_fail_cb) { 1388 pjsip_tls_on_accept_fail_param param; 1389 pj_bzero(¶m, sizeof(param)); 1390 param.status = status; 1391 param.remote_addr = src_addr; 1392 (*listener->tls_setting.on_accept_fail_cb) (¶m); 1393 } 1361 1394 return PJ_TRUE; 1395 } 1362 1396 1363 1397 /* Set the "pending" SSL socket user data */ … … 1440 1474 return PJ_TRUE; 1441 1475 } 1476 1477 /* 1478 * This callback is called by SSL socket when pending accept() operation 1479 * has completed. 1480 */ 1481 //static pj_bool_t on_accept_complete(pj_ssl_sock_t *ssock, 1482 // pj_ssl_sock_t *new_ssock, 1483 // const pj_sockaddr_t *src_addr, 1484 // int src_addr_len) 1485 //{ 1486 // PJ_UNUSED_ARG(src_addr_len); 1487 //} 1442 1488 1443 1489
Note: See TracChangeset
for help on using the changeset viewer.