Remove 'app_name' global variable

This commit is contained in:
Sukchan Lee 2018-08-14 17:01:46 +09:00
parent d96efc6ea9
commit 0ce11e3a7c
13 changed files with 39 additions and 29 deletions

3
main.c
View File

@ -142,8 +142,7 @@ int main(int argc, char *argv[])
atexit(terminate);
core_initialize();
app_log_pid(pid_path);
rv = app_initialize(config_path, log_path);
rv = app_initialize(config_path, log_path, pid_path);
if (rv != CORE_OK)
{
if (rv == CORE_EAGAIN)

View File

@ -8,10 +8,8 @@
extern "C" {
#endif /* __cplusplus */
extern const char *app_name;
CORE_DECLARE(status_t) app_initialize(
const char *config_path, const char *log_path);
const char *config_path, const char *log_path, const char *pid_path);
CORE_DECLARE(void) app_terminate(void);
CORE_DECLARE(status_t) app_will_initialize(
@ -24,7 +22,7 @@ CORE_DECLARE(status_t) config_initialize(const char *config_path);
CORE_DECLARE(void) config_terminate(void);
CORE_DECLARE(status_t) app_logger_restart(void);
CORE_DECLARE(status_t) app_log_pid(const char *pid_path);
CORE_DECLARE(status_t) app_log_pid(const char *pid_path, const char *app_name);
CORE_DECLARE(status_t) mme_initialize();
CORE_DECLARE(void) mme_terminate(void);

View File

@ -89,7 +89,7 @@ void app_did_terminate(void)
context_final();
}
status_t app_log_pid(const char *pid_path)
status_t app_log_pid(const char *pid_path, const char *app_name)
{
file_t *pid_file = NULL;
file_info_t finfo;

View File

@ -19,14 +19,16 @@ static semaphore_id sgw_sem2 = 0;
static semaphore_id hss_sem1 = 0;
static semaphore_id hss_sem2 = 0;
const char *app_name = "epc";
status_t app_initialize(const char *config_path, const char *log_path)
status_t app_initialize(
const char *config_path, const char *log_path, const char *pid_path)
{
pid_t pid;
status_t rv;
int app = 0;
rv = app_log_pid(pid_path, "epc");
if (rv != CORE_OK) return rv;
rv = app_will_initialize(config_path, log_path);
if (rv != CORE_OK) return rv;

View File

@ -7,13 +7,15 @@
#include "app/context.h"
#include "app/app.h"
const char *app_name = "hss";
status_t app_initialize(const char *config_path, const char *log_path)
status_t app_initialize(
const char *config_path, const char *log_path, const char *pid_path)
{
status_t rv;
int app = 0;
rv = app_log_pid(pid_path, "hss");
if (rv != CORE_OK) return rv;
rv = app_will_initialize(config_path, log_path);
if (rv != CORE_OK) return rv;

View File

@ -7,13 +7,15 @@
#include "app/context.h"
#include "app/app.h"
const char *app_name = "mme";
status_t app_initialize(const char *config_path, const char *log_path)
status_t app_initialize(
const char *config_path, const char *log_path, const char *pid_path)
{
status_t rv;
int app = 0;
rv = app_log_pid(pid_path, "mme");
if (rv != CORE_OK) return rv;
rv = app_will_initialize(config_path, log_path);
if (rv != CORE_OK) return rv;

View File

@ -7,13 +7,15 @@
#include "app/context.h"
#include "app/app.h"
const char *app_name = "pcrf";
status_t app_initialize(const char *config_path, const char *log_path)
status_t app_initialize(
const char *config_path, const char *log_path, const char *pid_path)
{
status_t rv;
int app = 0;
rv = app_log_pid(pid_path, "pcrf");
if (rv != CORE_OK) return rv;
rv = app_will_initialize(config_path, log_path);
if (rv != CORE_OK) return rv;

View File

@ -7,13 +7,15 @@
#include "app/context.h"
#include "app/app.h"
const char *app_name = "pgw";
status_t app_initialize(const char *config_path, const char *log_path)
status_t app_initialize(
const char *config_path, const char *log_path, const char *pid_path)
{
status_t rv;
int app = 0;
rv = app_log_pid(pid_path, "pgw");
if (rv != CORE_OK) return rv;
rv = app_will_initialize(config_path, log_path);
if (rv != CORE_OK) return rv;

View File

@ -7,13 +7,15 @@
#include "app/context.h"
#include "app/app.h"
const char *app_name = "sgw";
status_t app_initialize(const char *config_path, const char *log_path)
status_t app_initialize(
const char *config_path, const char *log_path, const char *pid_path)
{
status_t rv;
int app = 0;
rv = app_log_pid(pid_path, "sgw");
if (rv != CORE_OK) return rv;
rv = app_will_initialize(config_path, log_path);
if (rv != CORE_OK) return rv;

View File

@ -75,7 +75,7 @@ status_t test_initialize(int argc, const char *const argv[], char *config_path)
atexit(test_terminate);
core_initialize();
rv = app_initialize(config_path, NULL);
rv = app_initialize(config_path, NULL, NULL);
if (rv != CORE_OK)
{
d_error("app_initialize() failed");

View File

@ -22,7 +22,8 @@ static semaphore_id hss_sem2 = 0;
static semaphore_id mme_sem1 = 0;
static semaphore_id mme_sem2 = 0;
status_t test_app_initialize(const char *config_path, const char *log_path)
status_t test_app_initialize(
const char *config_path, const char *log_path, const char *pid_path)
{
pid_t pid;
status_t rv;

View File

@ -9,7 +9,7 @@ extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(status_t) test_app_initialize(
const char *config_path, const char *log_path);
const char *config_path, const char *log_path, const char *pid_path);
CORE_DECLARE(void) test_app_terminate(void);
#ifdef __cplusplus

View File

@ -82,7 +82,7 @@ status_t test_initialize(int argc, const char *const argv[], char *config_path)
atexit(test_terminate);
core_initialize();
rv = test_app_initialize(conf, NULL);
rv = test_app_initialize(conf, NULL, NULL);
if (rv != CORE_OK)
{
d_error("test_app_initialize() failed");