diff options
author | Michael P | 2011-06-29 23:41:18 +0000 |
---|---|---|
committer | Michael P | 2011-06-29 23:41:18 +0000 |
commit | 091b0e828cf0fd5bbd1f9ae58ab96fc983e55d77 (patch) | |
tree | 30e2748bd04e6b07fdd043a72c434e01c3f7d632 /src/include | |
parent | 9cf414760f30f6fb377f47ced0d0315460bf85a7 (diff) |
Support for GTM-Proxy reconnection
This commit adds support for GTM-Proxy reconnection.
After promoting a GTM-Standby instance, it is possible
to reorientate Proxy worker threads to the newly-promoted
GTM instance.
Implemented in gtm_ctl, GTM reconnection uses USR1/USR2 to signal
GTM-Proxy main thread or worker threads.
If a worker thread receives a USR1 signal, it transmits it to the main thread.
After main thread has received USR1 signal, it signals worker threads with USR2.
Signal handling is managed by longjump.
A new keyword "reconnect" has been added in gtm_ctl.
Ex:
gtm_ctl reconnect -S gtm_proxy -D $PROXY_DATA -o '-s $STANDBY_HOST -t $STANDBY_PORT'
It is expected that new connection parameters to GTM are specified in string -o.
Implementation by Koichi Suzuki
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gtm/gtm_proxy.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/include/gtm/gtm_proxy.h b/src/include/gtm/gtm_proxy.h index ead825320b..d7db891c6a 100644 --- a/src/include/gtm/gtm_proxy.h +++ b/src/include/gtm/gtm_proxy.h @@ -120,6 +120,13 @@ typedef struct GTMProxy_ThreadInfo gtm_List *thr_pending_commands[MSG_TYPE_COUNT]; GTM_Conn *thr_gtm_conn; + + /* Reconnect Info */ + int can_accept_SIGUSR2; + int reconnect_issued; + int can_longjmp; + sigjmp_buf longjmp_env; + } GTMProxy_ThreadInfo; typedef struct GTMProxy_Threads @@ -138,7 +145,7 @@ int GTMProxy_ThreadRemove(GTMProxy_ThreadInfo *thrinfo); int GTMProxy_ThreadJoin(GTMProxy_ThreadInfo *thrinfo); void GTMProxy_ThreadExit(void); -extern GTMProxy_ThreadInfo *GTMProxy_ThreadCreate(void *(* startroutine)(void *)); +extern GTMProxy_ThreadInfo *GTMProxy_ThreadCreate(void *(* startroutine)(void *), int idx); extern GTMProxy_ThreadInfo * GTMProxy_GetThreadInfo(GTM_ThreadID thrid); extern GTMProxy_ThreadInfo *GTMProxy_ThreadAddConnection(GTMProxy_ConnectionInfo *conninfo); extern int GTMProxy_ThreadRemoveConnection(GTMProxy_ThreadInfo *thrinfo, @@ -236,4 +243,23 @@ extern GTM_ThreadID TopMostThreadID; CritSectionCount--; \ } while(0) +/* Signal Handler controller */ +#define SIGUSR2DETECTED() (GetMyThreadInfo->reconnect_issued == TRUE) +#define RECONNECT_LONGJMP() do{longjmp(GetMyThreadInfo->longjmp_env, 1);}while(0) +#if 1 +#define Disable_Longjmp() do{GetMyThreadInfo->can_longjmp = FALSE;}while(0) +#define Enable_Longjmp() \ + do{ \ + if (SIGUSR2DETECTED()) { \ + RECONNECT_LONGJMP(); \ + } \ + else { \ + GetMyThreadInfo->can_longjmp = TRUE; \ + } \ + } while(0) +#else +#define Disable_Longjmp() +#define Enable_Longjmp() +#endif + #endif |