diff options
-rw-r--r-- | pjnath/include/pjnath/stun_msg.h | 6 | ||||
-rw-r--r-- | pjnath/src/pjturn-client/client_main.c | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/pjnath/include/pjnath/stun_msg.h b/pjnath/include/pjnath/stun_msg.h index 15114808..5cf0f6c9 100644 --- a/pjnath/include/pjnath/stun_msg.h +++ b/pjnath/include/pjnath/stun_msg.h @@ -872,11 +872,17 @@ typedef struct pj_stun_uint_attr pj_stun_channel_number_attr; /** * Get 16bit channel number from 32bit integral value. + * Note that uint32 attributes are always stored in host byte order + * after they have been parsed from the PDU, so no need to do ntohs() + * here. */ #define PJ_STUN_GET_CH_NB(u32) ((pj_uint16_t)(u32>>16)) /** * Convert 16bit channel number into 32bit integral value. + * Note that uint32 attributes will be converted to network byte order + * when the attribute is written to packet, so no need to do htons() + * here. */ #define PJ_STUN_SET_CH_NB(chnum) (((pj_uint32_t)chnum) << 16) diff --git a/pjnath/src/pjturn-client/client_main.c b/pjnath/src/pjturn-client/client_main.c index 9c428fcf..117da1c0 100644 --- a/pjnath/src/pjturn-client/client_main.c +++ b/pjnath/src/pjturn-client/client_main.c @@ -190,7 +190,7 @@ static int worker_thread(void *unused) while (!g.quit) { const pj_time_val delay = {0, 10}; - int i; + int i, n=0; pj_fd_set_t readset; /* Poll ioqueue for the TURN client */ @@ -203,9 +203,11 @@ static int worker_thread(void *unused) PJ_FD_ZERO(&readset); for (i=0; i<PJ_ARRAY_SIZE(g.peer); ++i) { PJ_FD_SET(g.peer[i].sock, &readset); + if (g.peer[i].sock > n) + n = g.peer[i].sock; } - if (pj_sock_select(64, &readset, NULL, NULL, &delay) <= 0) + if (pj_sock_select(n+1, &readset, NULL, NULL, &delay) <= 0) continue; /* Handle incoming data on peer socket */ |