Fix STUN issue on Android and iOS
This commit is contained in:
parent
bb40d86943
commit
8a2fd75829
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue