update it
This commit is contained in:
parent
62950382ae
commit
c70eb89a24
4
main.c
4
main.c
|
@ -145,7 +145,7 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
}
|
||||
|
||||
if (nextepc_initialize(config_path, log_path) != CORE_OK)
|
||||
if (epc_initialize(config_path, log_path) != CORE_OK)
|
||||
{
|
||||
d_fatal("NextEPC initialization failed. Aborted");
|
||||
return EXIT_FAILURE;
|
||||
|
@ -157,7 +157,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
d_info("NextEPC daemon terminating...");
|
||||
|
||||
nextepc_terminate();
|
||||
epc_terminate();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ libepc_la_SOURCES = \
|
|||
init.h
|
||||
|
||||
nodist_libepc_la_SOURCES = \
|
||||
init.c
|
||||
epc.c init.c
|
||||
|
||||
libepc_la_DEPENDENCIES = \
|
||||
$(top_srcdir)/lib/logger/liblogger.la \
|
||||
|
|
78
src/init.c
78
src/init.c
|
@ -1,28 +1,22 @@
|
|||
#define TRACE_MODULE _common_init
|
||||
#define TRACE_MODULE _init
|
||||
|
||||
#include "core_general.h"
|
||||
#include "core_debug.h"
|
||||
#include "core_thread.h"
|
||||
#include "core_net.h"
|
||||
#include "core_signal.h"
|
||||
#include "core_semaphore.h"
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include "init.h"
|
||||
|
||||
static pid_t hss_pid;
|
||||
static pid_t logger_pid;
|
||||
static thread_id net_thread;
|
||||
|
||||
static int check_signal(int signum);
|
||||
void *THREAD_FUNC net_main(thread_id id, void *data);
|
||||
|
||||
status_t nextepc_initialize(char *config_path, char *log_path)
|
||||
status_t will_initialize(char *config_path, char *log_path)
|
||||
{
|
||||
status_t rv;
|
||||
semaphore_id semaphore;
|
||||
|
||||
core_initialize();
|
||||
|
||||
if (config_path)
|
||||
|
@ -36,80 +30,31 @@ status_t nextepc_initialize(char *config_path, char *log_path)
|
|||
d_assert(logger_pid > 0, return -1, "logger_start() failed");
|
||||
}
|
||||
|
||||
rv = semaphore_create(&semaphore, 0);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_create() failed");
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
hss_pid = fork();
|
||||
d_assert(hss_pid >= 0, _exit(EXIT_FAILURE), "fork() failed");
|
||||
status_t did_initialize()
|
||||
{
|
||||
status_t rv;
|
||||
|
||||
if (hss_pid == 0)
|
||||
{
|
||||
/* Child */
|
||||
rv = semaphore_wait(semaphore);
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "semaphore_wait() failed");
|
||||
rv = semaphore_delete(semaphore);
|
||||
d_assert(rv == CORE_OK, _exit(EXIT_FAILURE), "semaphore_delete() failed");
|
||||
|
||||
rv = hss_initialize();
|
||||
if (rv != CORE_OK) _exit(EXIT_FAILURE);
|
||||
|
||||
signal_thread(check_signal);
|
||||
hss_terminate();
|
||||
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Parent */
|
||||
rv = pgw_initialize();
|
||||
if (rv != CORE_OK) return rv;
|
||||
rv = sgw_initialize();
|
||||
if (rv != CORE_OK) return rv;
|
||||
rv = mme_initialize();
|
||||
if (rv != CORE_OK) return rv;
|
||||
rv = thread_create(&net_thread, NULL, net_main, NULL);
|
||||
if (rv != CORE_OK) return rv;
|
||||
|
||||
rv = semaphore_post(semaphore);
|
||||
d_assert(rv == CORE_OK, return -1, "semaphore_post() failed");
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
void nextepc_terminate(void)
|
||||
void will_terminate(void)
|
||||
{
|
||||
thread_delete(net_thread);
|
||||
mme_terminate();
|
||||
sgw_terminate();
|
||||
pgw_terminate();
|
||||
}
|
||||
|
||||
core_kill(hss_pid, SIGTERM);
|
||||
void did_terminate(void)
|
||||
{
|
||||
core_kill(logger_pid, SIGTERM);
|
||||
|
||||
core_terminate();
|
||||
}
|
||||
|
||||
static int check_signal(int signum)
|
||||
{
|
||||
switch (signum)
|
||||
{
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
{
|
||||
d_info("%s received",
|
||||
signum == SIGTERM ? "SIGTERM" : "SIGINT");
|
||||
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
{
|
||||
d_error("Unknown signal number = %d\n", signum);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *THREAD_FUNC net_main(thread_id id, void *data)
|
||||
{
|
||||
while (!thread_should_stop())
|
||||
|
@ -119,4 +64,3 @@ void *THREAD_FUNC net_main(thread_id id, void *data)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
13
src/init.h
13
src/init.h
|
@ -1,5 +1,5 @@
|
|||
#ifndef __COMMON_INIT_H__
|
||||
#define __COMMON_INIT_H__
|
||||
#ifndef __INIT_H__
|
||||
#define __INIT_H__
|
||||
|
||||
#include "core.h"
|
||||
#include "core_errno.h"
|
||||
|
@ -8,8 +8,13 @@
|
|||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
CORE_DECLARE(status_t) nextepc_initialize(char *config_path, char *log_path);
|
||||
CORE_DECLARE_NONSTD(void) nextepc_terminate(void);
|
||||
CORE_DECLARE(status_t) will_initialize(char *config_path, char *log_path);
|
||||
CORE_DECLARE(status_t) did_initialize(char *config_path, char *log_path);
|
||||
CORE_DECLARE_NONSTD(void) will_terminate(void);
|
||||
CORE_DECLARE_NONSTD(void) did_terminate(void);
|
||||
|
||||
CORE_DECLARE(status_t) epc_initialize(char *config_path, char *log_path);
|
||||
CORE_DECLARE_NONSTD(void) epc_terminate(void);
|
||||
|
||||
CORE_DECLARE(status_t) mme_initialize();
|
||||
CORE_DECLARE_NONSTD(void) mme_terminate(void);
|
||||
|
|
|
@ -38,12 +38,12 @@ void core_assert_ok(abts_case* tc, const char* context, status_t rv,
|
|||
|
||||
void test_terminate(void)
|
||||
{
|
||||
nextepc_terminate();
|
||||
epc_terminate();
|
||||
}
|
||||
|
||||
void test_initialize(void)
|
||||
{
|
||||
nextepc_initialize(NULL, NULL);
|
||||
epc_initialize(NULL, NULL);
|
||||
|
||||
#if 0
|
||||
inet_pton(AF_INET, "10.1.35.215", &mme_self()->s1ap_addr);
|
||||
|
|
Loading…
Reference in New Issue