Repository navigation
upssched: run expired timer commands asynchronously #3769
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
user01010111
wants to merge
6
commits into
networkupstools:master
Choose a base branch
from
user01010111:fix/upssched-async-timers-3115
base: master
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.
+209
−26
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4eab2ce
upssched: run expired timer commands asynchronously
3de757d
NEWS: link asynchronous upssched timer PR
8aa1b5c
docs: link upssched upgrade note to PR 3769
147fbc3
Merge branch 'master' into fix/upssched-async-timers-3115
jimklimov a601520
tests/upssched-async-test.c: change `script` array to `static` [#3769]
jimklimov 6af76f5
upssched: cast timer command allocations explicitly
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* upssched-async-test - timer command ownership and collection | ||
| * | ||
| * Copyright (C) 2026 Network UPS Tools project | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 2 of the License, or | ||
| * (at your option) any later version. | ||
| */ | ||
|
|
||
| #include "config.h" | ||
|
|
||
| /* Include the implementation to test private command ownership. */ | ||
| int upssched_main(int argc, char **argv); | ||
| #define main upssched_main | ||
| #include "upssched.c" | ||
| #undef main | ||
|
|
||
| int main(int argc, char **argv) | ||
| { | ||
| command_t *child; | ||
| int count = 0, attempts; | ||
| static char *script[3]; | ||
|
|
||
| if (argc == 3 && !strcmp(argv[1], "--command")) { | ||
| if (!strcmp(argv[2], "slow")) { | ||
| sleep(8); | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| script[0] = argv[0]; | ||
| script[1] = (char *)"--command"; | ||
| script[2] = NULL; | ||
| cmdscript_argv = script; | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| cmdscript_argc = 2; | ||
| cmdscript_concat = argv[0]; | ||
|
|
||
| exec_cmd("slow", 1); | ||
| exec_cmd("fast", 1); | ||
| for (attempts = 0; attempts < 3; attempts++) { | ||
| sleep(1); | ||
| reap_commands(); | ||
| count = 0; | ||
| for (child = commands; child; child = child->next) { | ||
| count++; | ||
| } | ||
| if (count == 1) { | ||
| break; | ||
| } | ||
| } | ||
| if (count != 1 || strcmp(commands->name, "slow")) { | ||
| fprintf(stderr, "FAIL: fast command must finish while slow command runs\n"); | ||
| return 1; | ||
| } | ||
| for (attempts = 0; commands && attempts < 10; attempts++) { | ||
| sleep(1); | ||
| reap_commands(); | ||
| } | ||
| if (commands) { | ||
| fprintf(stderr, "FAIL: completed commands must be collected\n"); | ||
| return 1; | ||
| } | ||
| puts("PASS: independent timer command execution and collection"); | ||
| return 0; | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.