From 8a2fd75829f2bdfc14b8ad88f206f5b9e9b2438e Mon Sep 17 00:00:00 2001 From: bossiel Date: Wed, 7 Dec 2011 02:51:53 +0000 Subject: [PATCH] Fix STUN issue on Android and iOS --- branches/2.0/doubango/tinyNET/src/tnet_transport.c | 14 +++++--------- .../2.0/doubango/tinyNET/src/tnet_transport_poll.c | 3 ++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/branches/2.0/doubango/tinyNET/src/tnet_transport.c b/branches/2.0/doubango/tinyNET/src/tnet_transport.c index 83bc087c..3ec9dc6e 100644 --- a/branches/2.0/doubango/tinyNET/src/tnet_transport.c +++ b/branches/2.0/doubango/tinyNET/src/tnet_transport.c @@ -170,22 +170,18 @@ int tnet_transport_get_public_ip_n_port(const tnet_transport_handle_t *handle, t if(TNET_SOCKET_TYPE_IS_DGRAM(transport->type) && (natt_ctx = tsk_object_ref(transport->natt_ctx))){ tnet_stun_binding_id_t bind_id = TNET_STUN_INVALID_BINDING_ID; - // if the socket is already monitored by the transport we should pause beacuse both the transport and + // if the socket is already monitored by the transport we should pause because both the transport and // NAT binder will try to read from it - tsk_bool_t pause_socket = (TSK_RUNNABLE(transport)->running || TSK_RUNNABLE(transport)->started); // FIXME: change when ICE will be fully implemented TSK_DEBUG_INFO("Getting public address"); + // Pause the soket - if(pause_socket){ - tnet_transport_pause_socket(transport, fd, tsk_true); - } + tnet_transport_pause_socket(transport, fd, tsk_true); // Performs STUN binding bind_id = tnet_nat_stun_bind(transport->natt_ctx, fd); // Resume the socket - if(pause_socket){ - tnet_transport_pause_socket(transport, fd, tsk_false); - } + tnet_transport_pause_socket(transport, fd, tsk_false); if(TNET_STUN_IS_VALID_BINDING_ID(bind_id)){ char* public_ip = tsk_null; @@ -413,7 +409,7 @@ static tsk_object_t* tnet_transport_ctor(tsk_object_t * self, va_list * app) transport->type = type; transport->context = tnet_transport_context_create(); - if((transport->master = tnet_socket_create(local_host, req_local_port, type))){ + if((transport->master = tnet_socket_create(local_host, req_local_port, type))){ transport->local_ip = tsk_strdup(transport->master->ip); transport->bind_local_port = transport->master->port; } diff --git a/branches/2.0/doubango/tinyNET/src/tnet_transport_poll.c b/branches/2.0/doubango/tinyNET/src/tnet_transport_poll.c index 4a34ab76..82f397e6 100644 --- a/branches/2.0/doubango/tinyNET/src/tnet_transport_poll.c +++ b/branches/2.0/doubango/tinyNET/src/tnet_transport_poll.c @@ -688,7 +688,7 @@ void *tnet_transport_mainthread(void *param) if(!len){ TSK_DEBUG_WARN("IOCTLT returned zero for fd=%d", active_socket->fd); -#if !defined(ANDROID) /* FIXME: On Android/MAC OS X this mean that the socket has been closed? For sure this is not true for Android. */ +#if !defined(ANDROID) && !defined(__APPLE__) /* FIXME: On Android/MAC OS X this mean that the socket has been closed? For sure this is not true for Android and iOS */ TSK_RUNNABLE_ENQUEUE(transport, event_closed, transport->callback_data, active_socket->fd); removeSocket(i, context); #else @@ -796,6 +796,7 @@ TNET_POLLIN_DONE:; }/* for */ done: + context->ufds[i].revents = 0; /* unlock context */ tsk_safeobj_unlock(context);