}
new_socket:
- while(globals.running) {
+ while(globals.running && !profile->sock) {
char *listening_ip = NULL;
switch_clear_flag_locked(profile, PFLAG_RESPAWN);
rv = switch_sockaddr_info_get(&sa, profile->ip, SWITCH_UNSPEC, profile->port, 0, tmp_pool);
break;
sock_fail:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error! Could not listen on %s:%u\n", profile->ip, profile->port);
+ if (profile->sock) {
+ close_socket(&profile->sock, profile);
+ profile->sock = NULL;
+ }
switch_yield(100000);
}
goto fail;
}
+ assert(profile->sock);
+
if ((rv = switch_socket_accept(&inbound_socket, profile->sock, listener_pool))) {
if (!globals.running) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting Down\n");