-
Notifications
You must be signed in to change notification settings - Fork 365
Clean up main loop child and timer code, and deprecate their public API #4167
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
Open
nrwahl2
wants to merge
70
commits into
ClusterLabs:main
Choose a base branch
from
nrwahl2:nrwahl2-mainloop_first
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,318
−775
Open
Changes from all commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
ae9a754
Refactor: libcrmcommon: Use bool for crm_trigger_t:running
nrwahl2 e880914
Refactor: libcrmcommon: Use bool for crm_trigger_t:trigger
nrwahl2 624f79b
Refactor: libcrmcommon: Best practices for child_free()
nrwahl2 cf1b668
Refactor: libcrmcommon: Use bool for mainloop_child_t:timeout
nrwahl2 67590c3
Refactor: libcrmcommon: Best practices for mainloop_child_add_with_flags
nrwahl2 ef61e5c
Refactor: libcrmcommon: Best practices for child_signal_init()
nrwahl2 8486d01
Doc: libcrmcommon: Document struct mainloop_child_s
nrwahl2 bbf7369
Refactor: libcrmcommon: Rename mainloop_child_t:timerid to timer_id
nrwahl2 c64f173
Refactor: libcrmcommon: Rename mainloop_child_t:timeout to timed_out
nrwahl2 be572ab
Refactor: libcrmcommon: Rename mainloop_child_t:privatedata to user_data
nrwahl2 b5b3e49
Refactor: libcrmcommon: Replace mainloop_child_t:flags with kill_group
nrwahl2 09e3fc5
Refactor: pacemakerd: Drop mainloop_child_name() internally
nrwahl2 7ff8c3f
Refactor: libcrmservice: Drop mainloop_child_timeout() internally
nrwahl2 937f6e3
Refactor: various: Drop mainloop_child_userdata() internally
nrwahl2 d7e043d
Refactor: libcrmservice: Drop mainloop_clear_child_userdata() internally
nrwahl2 fb1e807
Refactor: libcrmcommon: New compare_children_by_pid()
nrwahl2 f83391b
Refactor: libcrmcommon: Use g_list_delete_link() in mainloop_child_kill
nrwahl2 5a105f3
Doc: libcrmcommon: Add Doxygen for mainloop_child_kill()
nrwahl2 26393f7
Refactor: libcrmcommon: Best practices in child_timeout_callback()
nrwahl2 2c952da
Refactor: libcrmcommon: Drop five-second hung child check
nrwahl2 04b1024
Refactor: libcrmcommon: Always set timed_out in child_timeout_callback()
nrwahl2 786738b
Refactor: libcrmcommon: Clean up child_kill_helper()
nrwahl2 a5bbf75
Refactor: libcrmcommon: Clean up child_death_dispatch()
nrwahl2 f9037f4
Refactor: libcrmcommon: Move duplicated functionality to child_waitpid()
nrwahl2 589a217
Refactor: libcrmcommon: CRM_CHECK() else case in child_waitpid()
nrwahl2 8f04db4
Refactor: libcrmcommon: child_waitpid() takes a bool argument
nrwahl2 767f966
Log: libcrmcommon: child_waitpid() logs more specific messages
nrwahl2 b6221c6
Low: libcrmcommon: Fix core dumped logic in child_waitpid()
nrwahl2 8985333
Low: libcrmcommon: Don't set signo/exitcode for nonpositive child->pid
nrwahl2 273ab09
Doc: libcrmcommon: Add Doxygen to child_waitpid()
nrwahl2 40fb285
Low: libcrmcommon: Fix child_waitpid() return values
nrwahl2 7657ae3
Low: libcrmcommon: Don't set signo to SIGCHLD for waitpid() ECHILD
nrwahl2 437c07b
Refactor: libcrmcommon: New pcmk__main_loop_child_create()
nrwahl2 6f38b70
Refactor: libcrmservice: Use bool variable in services_action_cancel()
nrwahl2 bed681b
Refactor: libcrmcommon: New pcmk__main_loop_child_kill()
nrwahl2 1d0b82c
API: libcrmcommon: Deprecate mainloop_child_t API
nrwahl2 840bbec
Refactor: libcrmcommon: Make free_main_loop_child() a GDestroyNotify
nrwahl2 051ca95
Refactor: libcrmcommon: Reorder some mainloop.c functions
nrwahl2 1df7e28
Refactor: libcrmcommon: Move pcmk__mainloop_child_exit_fn_t
nrwahl2 4de76fc
Refactor: libcrmcommon: mainloop_child_t -> pcmk__main_loop_child_t
nrwahl2 a96a196
Refactor: libcrmcommon: Rename pcmk__mainloop_child_exit_fn_t
nrwahl2 db80ae4
Refactor: libcrmcommon: Rename pcmk__main_loop_child_t:exit_fn
nrwahl2 f692591
Refactor: libcrmcommon: Drop pcmk__mainloop_timer_get_period()
nrwahl2 f699c94
Refactor: libcrmcommon: Lightly reformat main loop timer functions
nrwahl2 eb9c522
Refactor: libcrmcommon: Don't start main loop timer if callback is NULL
nrwahl2 3991bf9
Refactor: libcrmcommon: Drop repeat variable from mainloop_timer_cb()
nrwahl2 2a47ae9
Refactor: various: Always pass repeat=true to mainloop_timer_add()
nrwahl2 cca1f56
Refactor: various: Use G_SOURCE_{CONTINUE,REMOVE} in GSourceFuncs
nrwahl2 b0200f1
Refactor: controller: Drop fsa_timer_t:callback
nrwahl2 abcdf2e
Refactor: controller: Drop redundant inits in controld_init_fsa_timers()
nrwahl2 70dfac4
Refactor: controller: controld_init_fsa_timers() returns void
nrwahl2 2c186de
Refactor: controller: Drop overridden set of finalization timer input
nrwahl2 de2b2b6
Refactor: controller: Drop get_timer_desc()
nrwahl2 8fd6ebe
Refactor: controller: New new_fsa_timer()
nrwahl2 8876cdc
Refactor: controller: New free_fsa_timer()
nrwahl2 245d5d3
Refactor: attrd, pacemakerd: Rename two main loop timers
nrwahl2 aa00961
Refactor: libcrmcommon: New pcmk__main_loop_timer_new()
nrwahl2 c0226e3
Refactor: libcrmcommon: New pcmk__main_loop_timer_running()
nrwahl2 2c3f5e1
Refactor: libcrmcommon: New pcmk__main_loop_timer_free()
nrwahl2 5d3aa11
Refactor: various: Drop mainloop_timer_set_period() internally
nrwahl2 22e782b
Refactor: fencer: Drop dead code from get_agent_metadata_cb()
nrwahl2 454fef1
Refactor: libcrmcommon: New pcmk__main_loop_timer_start()
nrwahl2 c2f5eaf
Refactor: libcrmcommon: New pcmk__main_loop_timer_stop()
nrwahl2 bf19a0c
Refactor: libcrmcommon: New main_loop_timer_cb()
nrwahl2 8280f33
Refactor: controller: Use "interval" instead of "period" for timers
nrwahl2 4541343
Refactor: libcrmcommon: Use "interval" instead of "period" for timers
nrwahl2 2ed962f
Refactor: libcrmcommon: Rename mainloop_timer_t:userdata to user_data
nrwahl2 cad6acb
Refactor: libcrmcommon: Rename mainloop_timer_t:id to source_id
nrwahl2 cafad30
Refactor: libcrmcommon: New pcmk__main_loop_timer_t
nrwahl2 85bd3ea
API: libcrmcommon: Deprecate mainloop_timer_t API
nrwahl2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -386,7 +386,7 @@ controld_execute_fencing_cleanup(void) | |
| */ | ||
|
|
||
| static stonith_t *fencer_api = NULL; | ||
| static mainloop_timer_t *controld_fencer_connect_timer = NULL; | ||
| static pcmk__main_loop_timer_t *controld_fencer_connect_timer = NULL; | ||
| static char *te_client_id = NULL; | ||
|
|
||
| static bool | ||
|
|
@@ -443,8 +443,8 @@ destroy_fencer_connection(stonith_t *st, stonith_event_t *e) | |
|
|
||
| if (pcmk__is_set(controld_globals.fsa_input_register, R_ST_REQUIRED)) { | ||
| pcmk__err("Lost fencer connection (will attempt to reconnect)"); | ||
| if (!mainloop_timer_running(controld_fencer_connect_timer)) { | ||
| mainloop_timer_start(controld_fencer_connect_timer); | ||
| if (!pcmk__main_loop_timer_running(controld_fencer_connect_timer)) { | ||
| pcmk__main_loop_timer_start(controld_fencer_connect_timer); | ||
| } | ||
| } else { | ||
| pcmk__info("Disconnected from fencer"); | ||
|
|
@@ -674,9 +674,9 @@ controld_timer_fencer_connect(void *user_data) | |
|
|
||
| if (controld_fencer_connect_timer == NULL) { | ||
| controld_fencer_connect_timer = | ||
| mainloop_timer_add("controld_fencer_connect", 1000, | ||
| TRUE, controld_timer_fencer_connect, | ||
| GINT_TO_POINTER(TRUE)); | ||
| pcmk__main_loop_timer_new("controld_fencer_connect", 1000, | ||
| controld_timer_fencer_connect, | ||
| GINT_TO_POINTER(TRUE)); | ||
| } | ||
|
|
||
| if (rc != pcmk_ok) { | ||
|
|
@@ -686,8 +686,8 @@ controld_timer_fencer_connect(void *user_data) | |
| QB_XS " rc=%d", | ||
| pcmk_strerror(rc), rc); | ||
|
|
||
| if (!mainloop_timer_running(controld_fencer_connect_timer)) { | ||
| mainloop_timer_start(controld_fencer_connect_timer); | ||
| if (!pcmk__main_loop_timer_running(controld_fencer_connect_timer)) { | ||
| pcmk__main_loop_timer_start(controld_fencer_connect_timer); | ||
| } | ||
|
|
||
| return G_SOURCE_CONTINUE; | ||
|
|
@@ -735,7 +735,8 @@ controld_disconnect_fencer(bool destroy) | |
| g_clear_pointer(&fencer_api, fencer_api->cmds->free); | ||
| } | ||
|
|
||
| g_clear_pointer(&controld_fencer_connect_timer, mainloop_timer_del); | ||
| g_clear_pointer(&controld_fencer_connect_timer, | ||
| pcmk__main_loop_timer_free); | ||
| g_clear_pointer(&te_client_id, free); | ||
| } | ||
| } | ||
|
|
@@ -1011,19 +1012,21 @@ controld_validate_fencing_watchdog_timeout(const char *value) | |
| */ | ||
|
|
||
| static crm_trigger_t *fencing_history_sync_trigger = NULL; | ||
| static mainloop_timer_t *fencing_history_sync_timer_short = NULL; | ||
| static mainloop_timer_t *fencing_history_sync_timer_long = NULL; | ||
| static pcmk__main_loop_timer_t *fencing_history_sync_timer_short = NULL; | ||
| static pcmk__main_loop_timer_t *fencing_history_sync_timer_long = NULL; | ||
|
|
||
| void | ||
| controld_cleanup_fencing_history_sync(stonith_t *st, bool free_timers) | ||
| { | ||
| if (free_timers) { | ||
| g_clear_pointer(&fencing_history_sync_timer_short, mainloop_timer_del); | ||
| g_clear_pointer(&fencing_history_sync_timer_long, mainloop_timer_del); | ||
| g_clear_pointer(&fencing_history_sync_timer_short, | ||
| pcmk__main_loop_timer_free); | ||
| g_clear_pointer(&fencing_history_sync_timer_long, | ||
| pcmk__main_loop_timer_free); | ||
|
Contributor
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. Indentation on both of these |
||
|
|
||
| } else { | ||
| mainloop_timer_stop(fencing_history_sync_timer_short); | ||
| mainloop_timer_stop(fencing_history_sync_timer_long); | ||
| pcmk__main_loop_timer_stop(fencing_history_sync_timer_short); | ||
| pcmk__main_loop_timer_stop(fencing_history_sync_timer_long); | ||
| } | ||
|
|
||
| if (st) { | ||
|
|
@@ -1042,7 +1045,7 @@ static gboolean | |
| fencing_history_sync_set_trigger(void *user_data) | ||
| { | ||
| mainloop_set_trigger(fencing_history_sync_trigger); | ||
| return FALSE; | ||
| return G_SOURCE_REMOVE; | ||
| } | ||
|
|
||
| void | ||
|
|
@@ -1074,24 +1077,24 @@ controld_trigger_fencing_history_sync(bool long_timeout) | |
| if (long_timeout) { | ||
| if (fencing_history_sync_timer_long == NULL) { | ||
| fencing_history_sync_timer_long = | ||
| mainloop_timer_add("history_sync_long", 30000, | ||
| FALSE, fencing_history_sync_set_trigger, | ||
| NULL); | ||
| pcmk__main_loop_timer_new("history_sync_long", 30000, | ||
| fencing_history_sync_set_trigger, | ||
| NULL); | ||
| } | ||
| pcmk__info("Fence history will be synchronized cluster-wide within 30 " | ||
| "seconds"); | ||
| mainloop_timer_start(fencing_history_sync_timer_long); | ||
| pcmk__main_loop_timer_start(fencing_history_sync_timer_long); | ||
|
|
||
| } else { | ||
| if (fencing_history_sync_timer_short == NULL) { | ||
| fencing_history_sync_timer_short = | ||
| mainloop_timer_add("history_sync_short", 5000, | ||
| FALSE, fencing_history_sync_set_trigger, | ||
| NULL); | ||
| pcmk__main_loop_timer_new("history_sync_short", 5000, | ||
| fencing_history_sync_set_trigger, | ||
| NULL); | ||
| } | ||
| pcmk__info("Fence history will be synchronized cluster-wide within 5 " | ||
| "seconds"); | ||
| mainloop_timer_start(fencing_history_sync_timer_short); | ||
| pcmk__main_loop_timer_start(fencing_history_sync_timer_short); | ||
| } | ||
|
|
||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation