diff options
author | Pavan Deolasee | 2014-08-01 09:05:36 +0000 |
---|---|---|
committer | Pavan Deolasee | 2014-09-01 14:20:30 +0000 |
commit | fe78f41a8e772851d0a4c8c1e4124de75a49c4b0 (patch) | |
tree | cd3aa3ef16a18d85d7e15c82484e3c106a6bdf26 | |
parent | 1f960c3c7217a36b19d9b502c25346a766478ef0 (diff) |
Move the very first memory context allocation to the first phase of process
startup.
At reported on the XC bugs ML, config file processing logic expects memory
context to be already setup. It also makes sense in any case to have this
infrastructure ready in very beginning because many modules implicitly depend
on it. So move this immediately after starting the main routine.
Per report from [email protected] on XC ML
-rw-r--r-- | src/gtm/common/gtm_opt_handler.c | 2 | ||||
-rw-r--r-- | src/gtm/config/gtm_opt_handler.c | 2 | ||||
-rw-r--r-- | src/gtm/main/main.c | 50 | ||||
-rw-r--r-- | src/gtm/proxy/proxy_main.c | 48 |
4 files changed, 61 insertions, 41 deletions
diff --git a/src/gtm/common/gtm_opt_handler.c b/src/gtm/common/gtm_opt_handler.c index 61c2476599..34415ba2c5 100644 --- a/src/gtm/common/gtm_opt_handler.c +++ b/src/gtm/common/gtm_opt_handler.c @@ -2545,7 +2545,7 @@ set_config_option(const char *name, const char *value, } if (hintmsg) - free(hintmsg); + pfree(hintmsg); return false; } } diff --git a/src/gtm/config/gtm_opt_handler.c b/src/gtm/config/gtm_opt_handler.c index 3c7a585c0f..366b4353b5 100644 --- a/src/gtm/config/gtm_opt_handler.c +++ b/src/gtm/config/gtm_opt_handler.c @@ -2545,7 +2545,7 @@ set_config_option(const char *name, const char *value, } if (hintmsg) - free(hintmsg); + pfree(hintmsg); return false; } } diff --git a/src/gtm/main/main.c b/src/gtm/main/main.c index 2205beb055..8cbddd392b 100644 --- a/src/gtm/main/main.c +++ b/src/gtm/main/main.c @@ -175,17 +175,35 @@ MainThreadInit() return thrinfo; } +/* + * Bare minimum supporting infrastructure. Must be called at the very beginning + * so that further initilization can have it ready + */ static void -BaseInit() +InitGTMProcess() { - GTM_ThreadInfo *thrinfo; - - thrinfo = MainThreadInit(); - + GTM_ThreadInfo *thrinfo = MainThreadInit(); MyThreadID = pthread_self(); - MemoryContextInit(); + /* + * The memory context is now set up. + * Add the thrinfo structure in the global array + */ + if (GTM_ThreadAdd(thrinfo) == -1) + { + fprintf(stderr, "GTM_ThreadAdd for main thread failed: %d", errno); + fflush(stdout); + fflush(stderr); + } +#ifdef XCP + GTM_MutexLockInit(&control_lock); +#endif +} + +static void +BaseInit() +{ checkDataDir(); SetDataDir(); ChangeToDataDir(); @@ -209,19 +227,6 @@ BaseInit() GTM_InitTxnManager(); GTM_InitSeqManager(); - /* - * The memory context is now set up. - * Add the thrinfo structure in the global array - */ - if (GTM_ThreadAdd(thrinfo) == -1) - { - fprintf(stderr, "GTM_ThreadAdd for main thread failed: %d", errno); - fflush(stdout); - fflush(stderr); - } -#ifdef XCP - GTM_MutexLockInit(&control_lock); -#endif } static void @@ -376,6 +381,13 @@ main(int argc, char *argv[]) * At first, initialize options. Also moved something from BaseInit() here. */ InitializeGTMOptions(); + + /* + * Also initialize bare minimum supporting infrastructure such as memory + * context and thread control structure + */ + InitGTMProcess(); + /* * Catch standard options before doing much else */ diff --git a/src/gtm/proxy/proxy_main.c b/src/gtm/proxy/proxy_main.c index 5ac6f5b3e7..698a61b4b2 100644 --- a/src/gtm/proxy/proxy_main.c +++ b/src/gtm/proxy/proxy_main.c @@ -220,8 +220,6 @@ MainThreadInit() memset((char *)thrinfo, 0, sizeof(GTMProxy_ThreadInfo)); - memset((char *)thrinfo, 0, sizeof(GTMProxy_ThreadInfo)); - if (SetMyThreadInfo(thrinfo)) { fprintf(stderr, "SetMyThreadInfo failed: %d", errno); @@ -235,17 +233,32 @@ MainThreadInit() return thrinfo; } +/* + * Bare minimum supporting infrastructure. Must be called at the very beginning + * so that further initilization can have it ready + */ static void -BaseInit() +InitGTMProxyProcess() { - GTMProxy_ThreadInfo *thrinfo; - - thrinfo = MainThreadInit(); - + GTMProxy_ThreadInfo *thrinfo = MainThreadInit(); MyThreadID = pthread_self(); - MemoryContextInit(); + /* + * The memory context is now set up. + * Add the thrinfo structure in the global array + */ + if (GTMProxy_ThreadAdd(thrinfo) == -1) + { + fprintf(stderr, "GTMProxy_ThreadAdd for main thread failed: %d", errno); + fflush(stdout); + fflush(stderr); + } +} + +static void +BaseInit() +{ checkDataDir(); SetDataDir(); ChangeToDataDir(); @@ -268,17 +281,6 @@ BaseInit() RegisterProxy(false); DebugFileOpen(); - - /* - * The memory context is now set up. - * Add the thrinfo structure in the global array - */ - if (GTMProxy_ThreadAdd(thrinfo) == -1) - { - fprintf(stderr, "GTMProxy_ThreadAdd for main thread failed: %d", errno); - fflush(stdout); - fflush(stderr); - } } static char * @@ -580,10 +582,16 @@ main(int argc, char *argv[]) isStartUp = true; /* - * At first, initialize options. Also moved something from BaseInit() here. + * At first, initialize options. */ InitializeGTMOptions(); + /* + * Also initialize bare minimum supporting infrastructure such as memory + * context and thread control structure + */ + InitGTMProxyProcess(); + /* * Catch standard options before doing much else */ |