summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/stellar/module_manager.h4
-rw-r--r--infra/module_manager/module_manager.c12
-rw-r--r--infra/module_manager/module_manager_interna.h2
-rw-r--r--infra/module_manager/test/gtest_module_manager_main.cpp10
-rw-r--r--infra/polling_manager/test/gtest_polling_manager_main.cpp2
-rw-r--r--infra/stellar_core.c2
6 files changed, 19 insertions, 13 deletions
diff --git a/include/stellar/module_manager.h b/include/stellar/module_manager.h
index 283e948..70ee5a5 100644
--- a/include/stellar/module_manager.h
+++ b/include/stellar/module_manager.h
@@ -6,6 +6,7 @@ extern "C"
#endif
#include "stellar/mq.h"
+#include "stellar/log.h"
struct stellar_module;
struct stellar_module *stellar_module_new(const char *name, void *ctx);
@@ -22,7 +23,7 @@ struct stellar_module_manager;
typedef struct stellar_module *module_on_init_func(struct stellar_module_manager *mod_mgr);
typedef void module_on_exit_func(struct stellar_module_manager *mod_mgr, struct stellar_module *mod);
-struct stellar_module_manager *stellar_module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema);
+struct stellar_module_manager *stellar_module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema, struct logger *logger);
void stellar_module_manager_free(struct stellar_module_manager *mod_mgr);
void stellar_module_manager_register_thread(struct stellar_module_manager* mod_mgr, int thread_id, struct mq_runtime *mq_rt);
@@ -36,6 +37,7 @@ struct stellar_module *stellar_module_manager_get_module(struct stellar_module_m
int stellar_module_manager_get_max_thread_num(struct stellar_module_manager* mod_mgr);
const char *stellar_module_manager_get_toml_path(struct stellar_module_manager *mod_mgr);
struct mq_schema *stellar_module_manager_get_mq_schema(struct stellar_module_manager *mod_mgr);
+struct logger *stellar_module_manager_get_logger(struct stellar_module_manager *mod_mgr);
diff --git a/infra/module_manager/module_manager.c b/infra/module_manager/module_manager.c
index 154fa6c..517fdea 100644
--- a/infra/module_manager/module_manager.c
+++ b/infra/module_manager/module_manager.c
@@ -13,16 +13,14 @@
*******************************************/
#include "toml/toml.h"
-#include <fcntl.h>
-#include <unistd.h>
-
-struct stellar_module_manager *stellar_module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema)
+struct stellar_module_manager *stellar_module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema, struct logger *logger)
{
struct stellar_module_manager *mod_mgr = CALLOC(struct stellar_module_manager, 1);
mod_mgr->schema.max_thread_num=max_thread_num;
mod_mgr->schema.mq_schema=mq_schema;
+ mod_mgr->schema.logger=logger;
if(module_spec_toml_path==NULL)return mod_mgr;
FILE *fp = fopen(module_spec_toml_path, "r");
if (fp == NULL)return mod_mgr;
@@ -133,6 +131,12 @@ struct mq_schema *stellar_module_manager_get_mq_schema(struct stellar_module_man
return mod_mgr->schema.mq_schema;
}
+struct logger *stellar_module_manager_get_logger(struct stellar_module_manager *mod_mgr)
+{
+ if(mod_mgr==NULL)return NULL;
+ return mod_mgr->schema.logger;
+}
+
const char *stellar_module_manager_get_toml_path(struct stellar_module_manager *mod_mgr)
{
if(mod_mgr==NULL)return NULL;
diff --git a/infra/module_manager/module_manager_interna.h b/infra/module_manager/module_manager_interna.h
index 0938ad2..96b46a7 100644
--- a/infra/module_manager/module_manager_interna.h
+++ b/infra/module_manager/module_manager_interna.h
@@ -12,7 +12,6 @@ extern "C"
#include <limits.h>
#include <stdbool.h>
-#include <stdio.h>
struct stellar_module
{
@@ -41,6 +40,7 @@ struct stellar_module_manager
{
int max_thread_num;
struct mq_schema *mq_schema;
+ struct logger *logger;
}schema;
}__attribute__((aligned(sizeof(void*))));
diff --git a/infra/module_manager/test/gtest_module_manager_main.cpp b/infra/module_manager/test/gtest_module_manager_main.cpp
index 40a2f21..20d5b6d 100644
--- a/infra/module_manager/test/gtest_module_manager_main.cpp
+++ b/infra/module_manager/test/gtest_module_manager_main.cpp
@@ -31,7 +31,7 @@ TEST(module_manager_internal, stellar_module_manager_new_with_toml) {
write(fd, gtest_mock_spec_toml, strlen(gtest_mock_spec_toml));
close(fd);
- struct stellar_module_manager *mod_mgr=stellar_module_manager_new(toml_template, 10, mq_schema);
+ struct stellar_module_manager *mod_mgr=stellar_module_manager_new(toml_template, 10, mq_schema, NULL);
EXPECT_TRUE(mod_mgr!=NULL);
EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "test")==NULL);
@@ -72,7 +72,7 @@ TEST(stellar_module, basic_new_and_free) {
TEST(stellar_module_manager, new_with_null_toml) {
struct mq_schema *mq_schema=NULL;
- struct stellar_module_manager *mod_mgr = stellar_module_manager_new(NULL, 10, mq_schema);
+ struct stellar_module_manager *mod_mgr = stellar_module_manager_new(NULL, 10, mq_schema, NULL);
EXPECT_TRUE(mod_mgr!=NULL);
EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "test")==NULL);
EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10);
@@ -87,7 +87,7 @@ TEST(stellar_module_manager, new_with_null_toml) {
TEST(stellar_module_manager, new_with_empty_toml) {
struct mq_schema *mq_schema=NULL;
- struct stellar_module_manager *mod_mgr = stellar_module_manager_new("/dev/null", 10, mq_schema);
+ struct stellar_module_manager *mod_mgr = stellar_module_manager_new("/dev/null", 10, mq_schema, NULL);
EXPECT_TRUE(mod_mgr!=NULL);
EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "test")==NULL);
EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10);
@@ -102,7 +102,7 @@ TEST(stellar_module_manager, new_with_empty_toml) {
TEST(stellar_module_manager, register_thread) {
struct mq_schema *mq_schema=(struct mq_schema*)1;
- struct stellar_module_manager *mod_mgr=stellar_module_manager_new(NULL, 10, mq_schema);
+ struct stellar_module_manager *mod_mgr=stellar_module_manager_new(NULL, 10, mq_schema, NULL);
EXPECT_TRUE(mod_mgr!=NULL);
@@ -163,7 +163,7 @@ TEST(module_manager, basic_module) {
write(fd, gtest_module_spec_toml, strlen(gtest_module_spec_toml));
close(fd);
- struct stellar_module_manager *mod_mgr=stellar_module_manager_new(toml_template, 10, mq_schema);
+ struct stellar_module_manager *mod_mgr=stellar_module_manager_new(toml_template, 10, mq_schema, NULL);
EXPECT_TRUE(mod_mgr!=NULL);
EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "gtest")!=NULL);
diff --git a/infra/polling_manager/test/gtest_polling_manager_main.cpp b/infra/polling_manager/test/gtest_polling_manager_main.cpp
index c212934..5738e64 100644
--- a/infra/polling_manager/test/gtest_polling_manager_main.cpp
+++ b/infra/polling_manager/test/gtest_polling_manager_main.cpp
@@ -44,7 +44,7 @@ TEST(polling_manager, basic_polling_module) {
write(fd, gtest_mock_spec_toml, strlen(gtest_mock_spec_toml));
close(fd);
- struct stellar_module_manager *mod_mgr=stellar_module_manager_new(toml_template, 10, mq_schema);
+ struct stellar_module_manager *mod_mgr=stellar_module_manager_new(toml_template, 10, mq_schema, NULL);
EXPECT_TRUE(mod_mgr!=NULL);
struct stellar_polling_manager *polling_mgr=stellar_module_get_polling_manager(mod_mgr);
diff --git a/infra/stellar_core.c b/infra/stellar_core.c
index 8574fd1..c478c85 100644
--- a/infra/stellar_core.c
+++ b/infra/stellar_core.c
@@ -214,7 +214,7 @@ struct stellar *stellar_new(const char *stellar_cfg_file, const char *module_cfg
goto error_out;
}
- st->mod_mgr = stellar_module_manager_new(module_cfg_file, st->thread_num, st->mq_schema);
+ st->mod_mgr = stellar_module_manager_new(module_cfg_file, st->thread_num, st->mq_schema, st->logger);
if (st->mod_mgr == NULL)
{
CORE_LOG_ERROR("unable to create module manager");