From 297d9732504290a1209ae7cf883127fadc1156aa Mon Sep 17 00:00:00 2001 From: Seudin Kasumovic Date: Wed, 13 Apr 2016 00:15:56 +0200 Subject: [PATCH] erlang: fix register server process with the local name server epmd - use correct alive name when number of C nodes greater then 1 - fix error check on register server process (cherry picked from commit 6f268b5a9d0bd07e689c401cb7221bb0f2c5f8be) --- modules/erlang/cnode.c | 2 +- modules/erlang/epmd.c | 4 ++-- modules/erlang/epmd.h | 2 +- modules/erlang/erl_helpers.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/erlang/cnode.c b/modules/erlang/cnode.c index f0f6e03d4ca..1e9b5d67c0c 100644 --- a/modules/erlang/cnode.c +++ b/modules/erlang/cnode.c @@ -226,7 +226,7 @@ int init_cnode_sockets(int cnode_id) io_handler_ins(phandler); /* start epmd handler - publish Kamailo C node */ - if (epmd_init((epmd_handler_t*)phandler) < 0 ) { + if (epmd_init((epmd_handler_t*)phandler, &alivename) < 0 ) { return -1; } diff --git a/modules/erlang/epmd.c b/modules/erlang/epmd.c index 3a47e0fc2b4..43889aa7396 100644 --- a/modules/erlang/epmd.c +++ b/modules/erlang/epmd.c @@ -39,9 +39,9 @@ /** * \brief Initialize EPMD handler */ -int epmd_init(epmd_handler_t *epmd) +int epmd_init(epmd_handler_t *epmd, str *alivename) { - epmd->sockfd = erl_init_node(&epmd->ec, &cnode_alivename, &cnode_host, &cookie); + epmd->sockfd = erl_init_node(&epmd->ec, alivename, &cnode_host, &cookie); epmd->handle_f = handle_epmd; epmd->wait_tmo_f = NULL; epmd->destroy_f = NULL; diff --git a/modules/erlang/epmd.h b/modules/erlang/epmd.h index d5d45078e2e..09b3eb59f0a 100644 --- a/modules/erlang/epmd.h +++ b/modules/erlang/epmd.h @@ -55,7 +55,7 @@ typedef struct epmd_handler_s } epmd_handler_t; -int epmd_init(epmd_handler_t *epmd); +int epmd_init(epmd_handler_t *epmd, str *alivename); int handle_epmd(handler_common_t *phandler); #endif /* EPMD_H_ */ diff --git a/modules/erlang/erl_helpers.c b/modules/erlang/erl_helpers.c index cc43e9277c6..f702a8bb9ae 100644 --- a/modules/erlang/erl_helpers.c +++ b/modules/erlang/erl_helpers.c @@ -307,9 +307,9 @@ int erl_init_node(ei_cnode *ec, const str *alivename, const str *hostname, const sockaddr2ip_addr(&ip, addr); /* publish */ - if ((epmdfd = ei_publish_tmo(ec, port, timeout_ms)) == -1) { + if ((epmdfd = ei_publish_tmo(ec, port, timeout_ms)) < 0) { - LM_ERR("Failed to publish port %u to epmd, check is epmd started\n", port); + LM_DBG("Failed publish %s:%u[%u] as %s: %s (%d)\n",ip_addr2strz(&ip),port,listen_fd,nodename, strerror(erl_errno), epmdfd); erl_close_socket(listen_fd); return -1;