-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various XHA improvements #18
base: master
Are you sure you want to change the base?
Changes from all commits
cb25181
b276416
3b50a2a
f73bcd6
446f61e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ include/mtcerrno.h | |
scripts/generr | ||
scripts/generr.o | ||
scripts/ha_errnorc | ||
compile_commands.json | ||
.cache/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -808,16 +808,13 @@ | |
} | ||
|
||
|
||
MTC_STATIC void | ||
rendezvous( | ||
SM_PHASE phase1, | ||
SM_PHASE phase2, | ||
SM_PHASE phase3, | ||
MTC_BOOLEAN on_heartbeat, | ||
MTC_BOOLEAN on_statefile) | ||
{ | ||
#if RENDEZVOUS_FAULT_HANDLING | ||
void rendezvous_wait(SM_PHASE p1, SM_PHASE p2) | ||
MTC_STATIC void | ||
rendezvous_wait( | ||
SM_PHASE p1, | ||
SM_PHASE p2, | ||
MTC_BOOLEAN on_heartbeat, | ||
MTC_BOOLEAN on_statefile) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want to de-indent the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add a separate commit that deindents these |
||
PCOM_DATA_SM psm; | ||
PCOM_DATA_HB phb; | ||
|
@@ -898,12 +895,22 @@ | |
hb_SF_cancel_accelerate(); | ||
} | ||
} | ||
#endif | ||
|
||
MTC_STATIC void | ||
rendezvous( | ||
SM_PHASE phase1, | ||
SM_PHASE phase2, | ||
SM_PHASE phase3, | ||
MTC_BOOLEAN on_heartbeat, | ||
MTC_BOOLEAN on_statefile) | ||
{ | ||
#if RENDEZVOUS_FAULT_HANDLING | ||
set_sm_phase(phase1); | ||
rendezvous_wait(phase1, phase2); | ||
rendezvous_wait(phase1, phase2, on_heartbeat, on_statefile); | ||
|
||
set_sm_phase(phase2); | ||
rendezvous_wait(phase2, phase3); | ||
rendezvous_wait(phase2, phase3, on_heartbeat, on_statefile); | ||
#else | ||
set_sm_phase(phase2); | ||
#endif | ||
|
@@ -1863,15 +1870,11 @@ | |
|
||
|
||
MTC_STATIC MTC_BOOLEAN | ||
update_sfdomain() | ||
{ | ||
MTC_CLOCK now; | ||
MTC_S8 hostmap[MAX_HOST_NUM + 1] = {0}; | ||
MTC_BOOLEAN changed = FALSE; | ||
|
||
MTC_BOOLEAN update_sfdomain_sub( | ||
update_sfdomain_sub( | ||
MTC_CLOCK now, | ||
MTC_S8 hostmap[MAX_HOST_NUM + 1], | ||
MTC_BOOLEAN writable) | ||
{ | ||
{ | ||
PCOM_DATA_SF psf; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly here, where you've de-indented the braces but not the rest of the function |
||
MTC_BOOLEAN changed = FALSE; | ||
MTC_S32 index; | ||
|
@@ -1960,14 +1963,21 @@ | |
} | ||
|
||
return changed; | ||
} | ||
} | ||
|
||
MTC_STATIC MTC_BOOLEAN | ||
update_sfdomain() | ||
{ | ||
MTC_CLOCK now; | ||
MTC_S8 hostmap[MAX_HOST_NUM + 1] = {0}; | ||
MTC_BOOLEAN changed = FALSE; | ||
|
||
now = _getms(); | ||
|
||
changed = update_sfdomain_sub(FALSE); | ||
changed = update_sfdomain_sub(now, hostmap, FALSE); | ||
if (changed) | ||
{ | ||
changed = update_sfdomain_sub(TRUE); | ||
changed = update_sfdomain_sub(now, hostmap, TRUE); | ||
if (changed) | ||
{ | ||
log_message(MTC_LOG_DEBUG, | ||
|
@@ -2777,18 +2787,12 @@ | |
} | ||
|
||
|
||
MTC_STATIC MTC_BOOLEAN | ||
sm_wait_signals_sm_hb_sf( | ||
static MTC_BOOLEAN | ||
check_sigs( | ||
MTC_BOOLEAN sm_sig, | ||
MTC_BOOLEAN hb_sig, | ||
MTC_BOOLEAN sf_sig, | ||
MTC_CLOCK timeout) | ||
MTC_BOOLEAN sf_sig) | ||
{ | ||
MTC_BOOLEAN signaled; | ||
MTC_CLOCK start = _getms(); | ||
|
||
MTC_BOOLEAN check_sigs() | ||
{ | ||
MTC_BOOLEAN signaled = FALSE; | ||
|
||
if (sm_sig && smvar.sm_sig) | ||
|
@@ -2808,27 +2812,44 @@ | |
} | ||
|
||
return signaled; | ||
} | ||
} | ||
|
||
#define NSEC_PER_SEC 1000000000 | ||
|
||
MTC_STATIC MTC_BOOLEAN | ||
sm_wait_signals_sm_hb_sf( | ||
MTC_BOOLEAN sm_sig, | ||
MTC_BOOLEAN hb_sig, | ||
MTC_BOOLEAN sf_sig, | ||
MTC_CLOCK timeout) | ||
{ | ||
MTC_BOOLEAN signaled; | ||
|
||
struct timespec deadline; | ||
|
||
if (timeout == 0) | ||
{ | ||
return FALSE; | ||
} | ||
|
||
struct timespec timeout_ts = mstots(timeout); | ||
clock_gettime(CLOCK_REALTIME, &deadline); | ||
Check warning Code scanning / CodeChecker the value returned by this function should not be disregarded; neglecting it may lead to errors Warning
the value returned by this function should not be disregarded; neglecting it may lead to errors
|
||
deadline.tv_nsec += timeout_ts.tv_nsec; | ||
deadline.tv_sec += timeout_ts.tv_sec; | ||
deadline.tv_sec += deadline.tv_nsec / NSEC_PER_SEC; | ||
deadline.tv_nsec %= NSEC_PER_SEC; | ||
|
||
pthread_mutex_lock(&smvar.mutex); | ||
while (!(signaled = check_sigs()) && | ||
((timeout < 0)? TRUE: (_getms() - start < timeout))) | ||
while (!(signaled = check_sigs(sm_sig, hb_sig, sf_sig))) | ||
{ | ||
if (timeout < 0) | ||
{ | ||
pthread_cond_wait(&smvar.cond, &smvar.mutex); | ||
} | ||
else | ||
{ | ||
pthread_mutex_unlock(&smvar.mutex); | ||
mssleep(100); | ||
pthread_mutex_lock(&smvar.mutex); | ||
} | ||
pthread_cond_timedwait(&smvar.cond, &smvar.mutex, &deadline); | ||
} | ||
} | ||
pthread_mutex_unlock(&smvar.mutex); | ||
|
||
|
Check warning
Code scanning / CodeChecker
Value stored to 'pthread_ret' is never read Warning