From a8a95675cba90ecd5ba2b7b36432641d4bf5703d Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 22 May 2007 21:11:10 +0000 Subject: Fixed ticket #285: ICE transport stops receiving packet upon getting ICMP unreach on Windows git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1288 74dad513-b988-da41-8d7b-12977e46ad98 --- pjnath/src/pjnath-test/ice_test.c | 11 +++++++++-- pjnath/src/pjnath-test/test.c | 2 ++ pjnath/src/pjnath/ice_strans.c | 20 +++++++++++++------- 3 files changed, 24 insertions(+), 9 deletions(-) (limited to 'pjnath') diff --git a/pjnath/src/pjnath-test/ice_test.c b/pjnath/src/pjnath-test/ice_test.c index 2933a088..38bb6d02 100644 --- a/pjnath/src/pjnath-test/ice_test.c +++ b/pjnath/src/pjnath-test/ice_test.c @@ -292,8 +292,10 @@ static int perform_ice_test(const char *title, /* Start ICE on im2 */ status = start_ice(im2, im1); - if (status != PJ_SUCCESS) + if (status != PJ_SUCCESS) { + app_perror(" error starting ICE", status); return -30; + } /* Start ICE on im1 */ status = start_ice(im1, im2); @@ -328,8 +330,10 @@ static int perform_ice_test(const char *title, data_from_answerer = pj_str("from answerer"); status = pj_ice_sess_send_data(im2->ice, 1, data_from_answerer.ptr, data_from_answerer.slen); - if (status != PJ_SUCCESS) + if (status != PJ_SUCCESS) { + app_perror(" error sending packet", status); return -48; + } /* Poll to allow data to be received */ for (;;) { @@ -476,9 +480,12 @@ int ice_test(void) goto on_return; /* Failure case (all checks fail) */ +#if 0 + /* Cannot just add an SRFLX candidate; it needs a base */ rc = perform_ice_test("Failure case (all checks fail)", PJ_FALSE, 1, PJ_FALSE, D3, D3, 1, ocand, 1, acand); if (rc != 0) goto on_return; +#endif /* Direct communication with invalid address */ rc = perform_ice_test("With 1 unreachable address", PJ_TRUE, 1, PJ_TRUE, D1, D2, 1, ocand, 0, NULL); diff --git a/pjnath/src/pjnath-test/test.c b/pjnath/src/pjnath-test/test.c index 1542bcdd..b9776539 100644 --- a/pjnath/src/pjnath-test/test.c +++ b/pjnath/src/pjnath-test/test.c @@ -64,6 +64,8 @@ static int test_inner(void) pj_dump_config(); pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0 ); + pjnath_init(); + #if INCLUDE_ICE_TEST DO_TEST(ice_test()); #endif diff --git a/pjnath/src/pjnath/ice_strans.c b/pjnath/src/pjnath/ice_strans.c index 16e8e96e..df5086f9 100644 --- a/pjnath/src/pjnath/ice_strans.c +++ b/pjnath/src/pjnath/ice_strans.c @@ -440,6 +440,8 @@ static void on_read_complete(pj_ioqueue_key_t *key, pj_ioqueue_get_user_data(key); pj_ice_strans *ice_st = comp->ice_st; pj_ssize_t pkt_size; + enum { RETRY = 4 }; + unsigned retry; pj_status_t status; if (bytes_read > 0) { @@ -511,13 +513,17 @@ static void on_read_complete(pj_ioqueue_key_t *key, } /* Read next packet */ - pkt_size = sizeof(comp->pkt); - comp->src_addr_len = sizeof(comp->src_addr); - status = pj_ioqueue_recvfrom(key, op_key, comp->pkt, &pkt_size, - PJ_IOQUEUE_ALWAYS_ASYNC, - &comp->src_addr, &comp->src_addr_len); - if (status != PJ_SUCCESS && status != PJ_EPENDING) { - ice_st_perror(comp->ice_st, "ioqueue recvfrom() error", status); + for (retry=0; retrypkt); + comp->src_addr_len = sizeof(comp->src_addr); + status = pj_ioqueue_recvfrom(key, op_key, comp->pkt, &pkt_size, + PJ_IOQUEUE_ALWAYS_ASYNC, + &comp->src_addr, &comp->src_addr_len); + if (status != PJ_SUCCESS && status != PJ_EPENDING) { + ice_st_perror(comp->ice_st, "ioqueue recvfrom() error", status); + } else { + break; + } } } -- cgit v1.2.3