diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2016-07-18 11:02:02 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2016-07-18 11:02:02 +0000 |
commit | a1099feb5d39f65f94946bdabfd3386d3a2291d5 (patch) | |
tree | 3ed9655fd0c37b304f0040c16662cfdd608790dc /pjnath/src/pjnath-test/test.c | |
parent | 7a699191da6f8484d35646dc48162a91545c875f (diff) |
Misc (re #1928): Fixed possible stuck issue in pjnath-test caused by blocking recvfrom() upon concurrent socket events.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5388 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/src/pjnath-test/test.c')
-rw-r--r-- | pjnath/src/pjnath-test/test.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pjnath/src/pjnath-test/test.c b/pjnath/src/pjnath-test/test.c index dd3e192d..e3d1a102 100644 --- a/pjnath/src/pjnath-test/test.c +++ b/pjnath/src/pjnath-test/test.c @@ -19,6 +19,7 @@ */ #include "test.h" #include <pjlib.h> +#include <pj/compat/socket.h> void app_perror(const char *msg, pj_status_t rc) { @@ -30,6 +31,20 @@ void app_perror(const char *msg, pj_status_t rc) PJ_LOG(1,("test", "%s: [pj_status_t=%d] %s", msg, rc, errbuf)); } +/* Set socket to nonblocking. */ +void app_set_sock_nb(pj_sock_t sock) +{ +#if defined(PJ_WIN32) && PJ_WIN32!=0 || \ + defined(PJ_WIN64) && PJ_WIN64 != 0 || \ + defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0 + u_long value = 1; + ioctlsocket(sock, FIONBIO, &value); +#else + pj_uint32_t value = 1; + ioctl(sock, FIONBIO, &value); +#endif +} + pj_status_t create_stun_config(pj_pool_t *pool, pj_stun_config *stun_cfg) { pj_ioqueue_t *ioqueue; |