summaryrefslogtreecommitdiff
path: root/pjlib-util
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2011-12-05 02:12:38 +0000
committerBenny Prijono <bennylp@teluu.com>2011-12-05 02:12:38 +0000
commitbf8c33f65fccc74a14940fa341f55b38e141ab4a (patch)
tree95518921db68f5f1219bd61df096fd735ab6451c /pjlib-util
parentef2cd739964e944a68e01de555c14b41d07fa59b (diff)
Fixed #1418 (Library restart fails with PJLIB_UTIL_ESTUNNOTRESPOND error after several times) due to bug in calling pj_sock_select(). Thanks Régis Montoya for the report and testing the fix
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@3896 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib-util')
-rw-r--r--pjlib-util/src/pjlib-util/stun_simple_client.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/pjlib-util/src/pjlib-util/stun_simple_client.c b/pjlib-util/src/pjlib-util/stun_simple_client.c
index af597fc5..dd798bd6 100644
--- a/pjlib-util/src/pjlib-util/stun_simple_client.c
+++ b/pjlib-util/src/pjlib-util/stun_simple_client.c
@@ -19,6 +19,7 @@
*/
#include <pjlib-util/stun_simple.h>
#include <pjlib-util/errno.h>
+#include <pj/compat/socket.h>
#include <pj/log.h>
#include <pj/os.h>
#include <pj/pool.h>
@@ -44,7 +45,7 @@ PJ_DEF(pj_status_t) pjstun_get_mapped_addr( pj_pool_factory *pf,
{
unsigned srv_cnt;
pj_sockaddr_in srv_addr[2];
- int i, j, send_cnt = 0;
+ int i, j, send_cnt = 0, nfds;
pj_pool_t *pool;
struct query_rec {
struct {
@@ -113,6 +114,17 @@ PJ_DEF(pj_status_t) pjstun_get_mapped_addr( pj_pool_factory *pf,
TRACE_((THIS_FILE, " Done initialization."));
+#if defined(PJ_SELECT_NEEDS_NFDS) && PJ_SELECT_NEEDS_NFDS!=0
+ nfds = -1;
+ for (i=0; i<sock_cnt; ++i) {
+ if (sock[i] > nfds) {
+ nfds = sock[i];
+ }
+ }
+#else
+ nfds = FD_SETSIZE-1;
+#endif
+
/* Main retransmission loop. */
for (send_cnt=0; send_cnt<MAX_REQUEST; ++send_cnt) {
pj_time_val next_tx, now;
@@ -169,7 +181,7 @@ PJ_DEF(pj_status_t) pjstun_get_mapped_addr( pj_pool_factory *pf,
PJ_FD_SET(sock[i], &r);
}
- select_rc = pj_sock_select(PJ_IOQUEUE_MAX_HANDLES, &r, NULL, NULL, &timeout);
+ select_rc = pj_sock_select(nfds+1, &r, NULL, NULL, &timeout);
TRACE_((THIS_FILE, " select() rc=%d", select_rc));
if (select_rc < 1)
continue;