From a4e05ead9167489d6c77a2b02e5b998038abdd32 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 16 Mar 2018 01:46:59 +0000 Subject: [PATCH] fixed the hcl server to apply some settings to underlying hcl --- configure | 1 - configure.ac | 2 +- lib/hcl-s.c | 36 ++++++++++++++++++++++++++++++++++++ lib/main.c | 2 +- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 76cb776..5d4ee94 100755 --- a/configure +++ b/configure @@ -17966,7 +17966,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -check some compiler builtins { $as_echo "$as_me:${as_lineno-$LINENO}: checking __builtin_memset" >&5 $as_echo_n "checking __builtin_memset... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext diff --git a/configure.ac b/configure.ac index 016e89c..87cd3b7 100644 --- a/configure.ac +++ b/configure.ac @@ -83,7 +83,7 @@ AC_SUBST(LIBM, $LIBM) AX_PTHREAD() -check some compiler builtins +dnl check some compiler builtins AC_MSG_CHECKING([__builtin_memset]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [__builtin_memset ((void*)1, ' ', 10);])], diff --git a/lib/hcl-s.c b/lib/hcl-s.c index 0b935b9..257eca0 100644 --- a/lib/hcl-s.c +++ b/lib/hcl-s.c @@ -1637,6 +1637,7 @@ hcl_server_t* hcl_server_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_server_p hcl_tmr_t* tmr; dummy_hcl_xtn_t* xtn; int pfd[2], fcv; + unsigned int trait; server = (hcl_server_t*)HCL_MMGR_ALLOC(mmgr, HCL_SIZEOF(*server) + xtnsize); if (!server) @@ -1714,6 +1715,18 @@ hcl_server_t* hcl_server_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_server_p pthread_mutex_init (&server->tmr_mutex, HCL_NULL); pthread_mutex_init (&server->log_mutex, HCL_NULL); + /* the dummy hcl is used for this server to perform primitive operations + * such as getting system time or logging. so the heap size doesn't + * need to be changed from the tiny value set above. */ + hcl_setoption (server->dummy_hcl, HCL_LOG_MASK, &server->cfg.logmask); + hcl_setcmgr (server->dummy_hcl, server->cmgr); + hcl_getoption (server->dummy_hcl, HCL_TRAIT, &trait); +#if defined(HCL_BUILD_DEBUG) + if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_DEBUG_GC; + if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_DEBUG_BIGINT; +#endif + hcl_setoption (server->dummy_hcl, HCL_TRAIT, &trait); + return server; } @@ -2083,10 +2096,33 @@ int hcl_server_setoption (hcl_server_t* server, hcl_server_option_t id, const vo { case HCL_SERVER_TRAIT: server->cfg.trait = *(const unsigned int*)value; + if (server->dummy_hcl) + { + /* setting this affects the dummy hcl immediately. + * existing hcl instances inside worker threads won't get + * affected. new hcl instances to be created later + * is supposed to use the new value */ + unsigned int trait; + + hcl_getoption (server->dummy_hcl, HCL_TRAIT, &trait); + #if defined(HCL_BUILD_DEBUG) + if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_DEBUG_GC; + if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_DEBUG_BIGINT; + #endif + hcl_setoption (server->dummy_hcl, HCL_TRAIT, &trait); + } return 0; case HCL_SERVER_LOG_MASK: server->cfg.logmask = *(const unsigned int*)value; + if (server->dummy_hcl) + { + /* setting this affects the dummy hcl immediately. + * existing hcl instances inside worker threads won't get + * affected. new hcl instances to be created later + * is supposed to use the new value */ + hcl_setoption (server->dummy_hcl, HCL_LOG_MASK, value); + } return 0; case HCL_SERVER_WORKER_STACK_SIZE: diff --git a/lib/main.c b/lib/main.c index 487691b..2a16528 100644 --- a/lib/main.c +++ b/lib/main.c @@ -1676,7 +1676,7 @@ int main (int argc, char* argv[]) } { - int trait = 0; + unsigned int trait = 0; /*trait |= HCL_NOGC;*/ trait |= HCL_AWAIT_PROCS;