fix possible socket connection race
This commit is contained in:
parent
91065543b2
commit
a65a7f322b
|
@ -2701,10 +2701,18 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
|
|||
switch_mutex_init(&listener->filter_mutex, SWITCH_MUTEX_NESTED, listener->pool);
|
||||
|
||||
switch_core_hash_init(&listener->event_hash, listener->pool);
|
||||
switch_socket_addr_get(&listener->sa, SWITCH_TRUE, listener->sock);
|
||||
|
||||
if (switch_socket_addr_get(&listener->sa, SWITCH_TRUE, listener->sock) == SWITCH_STATUS_SUCCESS && listener->sa) {
|
||||
switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), listener->sa);
|
||||
listener->remote_port = switch_sockaddr_get_port(listener->sa);
|
||||
if (listener->sa && (listener->remote_port = switch_sockaddr_get_port(listener->sa))) {
|
||||
launch_listener_thread(listener);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error initilizing connection\n");
|
||||
close_socket(&listener->sock);
|
||||
expire_listener(&listener);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue