diff --git a/conf/vanilla/autoload_configs/event_socket.conf.xml b/conf/vanilla/autoload_configs/event_socket.conf.xml index 5ea2e09788..28e0f46837 100644 --- a/conf/vanilla/autoload_configs/event_socket.conf.xml +++ b/conf/vanilla/autoload_configs/event_socket.conf.xml @@ -5,5 +5,6 @@ <param name="listen-port" value="8021"/> <param name="password" value="ClueCon"/> <!--<param name="apply-inbound-acl" value="lan"/>--> + <!--<param name="stop-on-bind-error" value="true"/>--> </settings> </configuration> diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index 12bf9a21b0..8ba47adfd6 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -127,6 +127,7 @@ static struct { uint32_t acl_count; uint32_t id; int nat_map; + int stop_on_bind_error; } prefs; @@ -2740,6 +2741,8 @@ static int config(void) } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Max acl records of %d reached\n", MAX_ACL); } + } else if (!strcasecmp(var, "stop-on-bind-error")) { + prefs.stop_on_bind_error = switch_true(val) ? 1 : 0; } } } @@ -2819,6 +2822,10 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime) break; sock_fail: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error! Could not listen on %s:%u\n", prefs.ip, prefs.port); + if (prefs.stop_on_bind_error) { + prefs.done = 1; + goto fail; + } switch_yield(100000); }