Skip to content

Automate seed data cleanup on exit #46

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

Merged
merged 3 commits into from
Feb 6, 2025
Merged

Conversation

SaSukiTB
Copy link
Contributor

@SaSukiTB SaSukiTB commented Feb 4, 2025

Implemented std::atexit() to automatically delete seed-related files and registry entries when the program exits, preventing the accumulation of unused seed data over time.

Implemented std::atexit() to automatically delete seed-related files and registry entries when the program exits, preventing the accumulation of unused seed data over time.
Copy link

github-actions bot commented Feb 4, 2025

The KeyAuth owner has been notified of your pull request. Please wait for him to review it. This could take several days.

Moved the Sleep interval inside the loop in checkRegistry() to ensure the registry key is checked periodically. Previously, the Sleep call was outside the loop, causing the check to run only once. Now, the function checks the registry at regular intervals and exits if the key is not found.
In the init() function, you create a thread, which runs runChecks this function, in turn, calls checkAtoms, checkFiles, and checkRegistry in sequence. 
so checkAtoms, checkFiles, and checkRegistry are called from both init() (within runChecks) and license (as individual threads).
now you will get Multiple threads running the same functions, you are calling the same functions (checkAtoms, checkFiles, and checkRegistry) twice in parallel 
once from runChecks (which is called in init()) and once from license(), this leads to multiple threads working on the same task, potentially doing redundant 
work and introducing unnecessary complexity and overhead. it will consume more system resources (CPU, memory) than necessary.

One more thing when you call runChecks from the init() function, it first calls checkAtoms, then checkFiles, and finally checkRegistry.
the key point here is that runChecks doesn't return until checkAtoms finishes its work, since checkAtoms has an infinite loop (while(true))
it will never return control to runChecks, you are checking only for GlobalFindAtomA, which mean GetFileAttributesA and RegOpenKeyExA will never be called until you return from checkAtoms.

One solution would be to move each of the checkAtoms, checkFiles, and checkRegistry functions into separate threads so they run concurrently, 
instead of running one after the other in runChecks, and no need to call them again in License() function since they gonna keep working till the program exit

I Added a simple mechanism to interrupt the sleep if the user logs in before the 45 seconds have passed, the function waits in a loop, checking every second 
if the user has logged in, if the user logs in before the 45s timeout, the loop breaks, and the checks begin.
if the user hasn’t logged in by the time the 45s pass, it simply proceeds with the checks.
@Its-Networking Its-Networking merged commit fbe3a83 into KeyAuth:main Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants