From dc8bc06c6497f2a43993af7701ebf0b9ac4d2d24 Mon Sep 17 00:00:00 2001 From: lazedo Date: Wed, 27 Mar 2019 17:55:17 +0000 Subject: [PATCH] FS-11732 [mod_kazoo] check otp version for ei_init --- build/config/erlang.m4 | 5 +++++ src/mod/event_handlers/mod_kazoo/Makefile.am | 2 +- src/mod/event_handlers/mod_kazoo/kazoo_ei_utils.c | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/build/config/erlang.m4 b/build/config/erlang.m4 index 7e4dc35b9b..83a089c8cd 100644 --- a/build/config/erlang.m4 +++ b/build/config/erlang.m4 @@ -75,10 +75,15 @@ then [AC_MSG_ERROR([ei.h is unusable - are the erlang development headers installed?])] ) else + ERLANG_MAJOR="`echo "$ERLANG_VER" | sed 's/\([[^.]][[^.]]*\).*/\1/'`" + ERLANG_MINOR="`echo "$ERLANG_VER" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`" ERLANG_LDFLAGS="$ERLANG_LDFLAGS -lei" AC_MSG_NOTICE([Your erlang seems OK, do not forget to enable mod_erlang_event in modules.conf]) AC_SUBST([ERLANG_CFLAGS], [$ERLANG_CFLAGS]) AC_SUBST([ERLANG_LDFLAGS], [$ERLANG_LDFLAGS]) + AC_SUBST([ERLANG_VERSION], [$ERLANG_VER]) + AC_SUBST([ERLANG_MAJOR], [$ERLANG_MAJOR]) + AC_SUBST([ERLANG_MINOR], [$ERLANG_MINOR]) AM_CONDITIONAL([HAVE_ERLANG],[true]) fi diff --git a/src/mod/event_handlers/mod_kazoo/Makefile.am b/src/mod/event_handlers/mod_kazoo/Makefile.am index 0d7af80177..516c192c93 100644 --- a/src/mod/event_handlers/mod_kazoo/Makefile.am +++ b/src/mod/event_handlers/mod_kazoo/Makefile.am @@ -13,7 +13,7 @@ mod_kazoo_la_SOURCES += kazoo_ei_config.c kazoo_ei_utils.c kazoo_event_stream.c mod_kazoo_la_SOURCES += kazoo_fetch_agent.c kazoo_node.c mod_kazoo_la_SOURCES += kazoo_endpoints.c -mod_kazoo_la_CFLAGS = $(AM_CFLAGS) @ERLANG_CFLAGS@ -D_REENTRANT +mod_kazoo_la_CFLAGS = $(AM_CFLAGS) @ERLANG_CFLAGS@ -D_REENTRANT -DERLANG_VERSION=@ERLANG_VERSION@ -DERLANG_MAJOR=@ERLANG_MAJOR@ -DERLANG_MINOR=@ERLANG_MINOR@ mod_kazoo_la_LIBADD = $(KAZOO_DEFS) $(switch_builddir)/libfreeswitch.la mod_kazoo_la_LDFLAGS = -avoid-version -module -no-undefined -shared @ERLANG_LDFLAGS@ diff --git a/src/mod/event_handlers/mod_kazoo/kazoo_ei_utils.c b/src/mod/event_handlers/mod_kazoo/kazoo_ei_utils.c index 1dcbfa4733..7a2e62c925 100644 --- a/src/mod/event_handlers/mod_kazoo/kazoo_ei_utils.c +++ b/src/mod/event_handlers/mod_kazoo/kazoo_ei_utils.c @@ -519,7 +519,9 @@ switch_status_t create_acceptor() { char ipbuf[48]; const char *ip_addr; +#if ERLANG_MAJOR >= 10 ei_init(); +#endif /* if the config has specified an erlang release compatibility then pass that along to the erlang interface */ if (kazoo_globals.ei_compat_rel) {