Skip to content
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

client: don't hang if detection processes hang #5190

Merged
merged 24 commits into from Apr 12, 2023
Merged

Conversation

davidpanderson
Copy link
Contributor

@davidpanderson davidpanderson commented Apr 10, 2023

The client runs two "detection processes":
- GPU detection
- (Mac) check if in CPU emulation mode
The client was waiting indefinitely for these to exit.
If for some reason they don't exit, the client hangs.

Fix: wait no more than 10 sec for them to exit.
If still running, kill them and move on.

lib/util.cpp had become a landfill of unrelated stuff
    - move the process-related code to lib/proc_control.cpp
    - move file-related code to lib/filesys.cpp
    - move client mutex code to client/main.cpp

The client has 2 unrelated types of mutual exclusion:
thread level (between the main and throttle threads)
and process level (prevent 2 clients from running on a host).
    - Rename "client_mutex" to "client_thread_mutex".

- parse.h: don't declare boinc_is_finite(); include the .h file
The client runs two "detection processes":
- GPU detection
- (Mac) check if in CPU emulation mode
The client was waiting indefinitely for these to exit.
If for some reason they don't exit, the client hangs.

Fix: wait no more than 10 sec for them to exit.
If still running, kill them and move on.

I took the opportunity to clean up the process-related code:

- add a time arg to get_exit_status().
    If zero, wait indefinitely for the child to exit.
    Else wait no more than that amount.
- get_exit_status() return an error code;
    the exit status is returned via a parameter.
- run_program() no longer takes a time argument.
    If you want to check for early exit, use get_exit_status()
- define PROCESS_ID as HANDLE (Win) or int (other)
    so we can unify the process interface
- remove process_exists().  It wasn't used anywhere,
    and get_exit_status(... 0) does the same thing.
- rename kill_program() to kill_process()
- don't use "prog" when you mean "pid"
get_exit_status(): dt<= means wait indefinitely; dt=0 means non-blocking
Note: the unit tests don't really test anything
lib/proc_control.cpp Outdated Show resolved Hide resolved
lib/proc_control.h Outdated Show resolved Hide resolved
Getting boinccas to build required some stuff I don't understand
@codecov
Copy link

codecov bot commented Apr 10, 2023

Codecov Report

Merging #5190 (7af6498) into master (1560a00) will increase coverage by 0.00%.
The diff coverage is 11.11%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #5190   +/-   ##
=========================================
  Coverage     10.86%   10.86%           
  Complexity     1064     1064           
=========================================
  Files           279      279           
  Lines         35993    35980   -13     
  Branches       8258     8257    -1     
=========================================
  Hits           3911     3911           
+ Misses        31690    31677   -13     
  Partials        392      392           
Impacted Files Coverage Δ
lib/filesys.cpp 0.00% <0.00%> (ø)
lib/parse.h 55.20% <ø> (ø)
lib/proc_control.cpp 0.00% <ø> (ø)
lib/str_util.h 0.00% <ø> (ø)
lib/util.h 40.00% <ø> (ø)
sched/sched_types.cpp 0.00% <ø> (ø)
lib/util.cpp 34.82% <21.42%> (+8.99%) ⬆️

davidpanderson and others added 3 commits April 10, 2023 20:24
This required changing a bunch of project files,
and was turning into a rabbit hole.
client/auto_update.cpp Show resolved Hide resolved
clientsetup/win/CACreateProjectInitFile.cpp Outdated Show resolved Hide resolved
BOINC Client/Manager automation moved this from Backlog to In Review Apr 11, 2023
The VS header files have a conflict:
various structures (such as STRING) are defined differently
in ntsecapi.h than in winternl.h

This error appears off and on, for reasons I don't understand.
Changes in lib/str_util.h seem to trigger it.
Earlier in this PR is was happening.
I found a workaround on stackoverflow.com and added it.

But now the error is not happening, even without the workaround.
So, for now, I'm commenting out the workaround.
It's there if we need it in the future.
BOINC Client/Manager automation moved this from In Review to Reviewed Apr 12, 2023
@AenBleidd AenBleidd merged commit e443a36 into master Apr 12, 2023
41 checks passed
BOINC Client/Manager automation moved this from Reviewed to Merged Apr 12, 2023
@AenBleidd AenBleidd deleted the dpa_gpu_detect2 branch August 15, 2023 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants