Skip to content

Conversation

@rasapala
Copy link
Collaborator

@rasapala rasapala commented Nov 4, 2025

🛠 Summary

JIRA CVS-175101

🧪 Checklist

  • Unit tests added.
  • The documentation updated.
  • Change follows security best practices.
    ``

@rasapala rasapala changed the title Registry read and service errors handling [WIP] Registry read and service errors handling Nov 4, 2025
@rasapala rasapala changed the title [WIP] Registry read and service errors handling Registry read and service errors handling Nov 7, 2025
src/server.cpp Outdated
Comment on lines 446 to 449
} catch (const std::exception& e) {
SPDLOG_ERROR("Exception; {}", e.what());
result = OVMS_EX_FAILURE;
shutdown_request = 3;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate variable - for now it serves as comunnication from user to ovms to request stop. It would be better to have sth else to signal the other way arround -> that ovms stopped and ovms wrapper (service) needs to know. Ensure its reset when ovms is starting


using ovms::Server;

OvmsWindowsServiceManager manager;
Copy link
Collaborator

@atobiszei atobiszei Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static inside function or singleton?

@dtrawins dtrawins added this to the 2025.4rc milestone Nov 7, 2025
int Server::getShutdownStatus() {
std::unique_lock lock{Server::shutdownMtx, std::defer_lock};
auto locked = lock.try_lock();
// Wait in windows thread until we can get the lock and check if ovms exited
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we could not get mtx we return 0, otherwise shutdown_request which could also be 0?

Copy link
Collaborator Author

@rasapala rasapala Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 for ShutdownStatus and ExitStatus means that the ovms thread - work - is still running. We can call the methods next time to check if anything changed, and if we got the mutex this time and we can read the specific variable - check if it is not 0.

return statusToExitCode(ret);
}
while (!shutdown_request &&
while (!getShutdownStatus() &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
while (!getShutdownStatus() &&
while (!getRequestedShutdown() &&

Comment on lines +505 to +506
int Server::start(int argc, char** argv) {
auto paramsOrExit = parseArgs(argc, argv);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this could be decoupled with Server:
we would have in main:

CLIParser parser;
parser.parse(argc,argv)

Then

server.start(serverSettings, modelsSettings)

bool isReady() const;
bool isLive(const std::string& moduleName) const;

int getShutdownStatus();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Private:

int getShutdownStatus();
void setShutdownRequest(int i);
int getExitStatus();
void setExitStatus(int i);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Private:

Copy link
Collaborator

@atobiszei atobiszei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To lower release delay risk change is accepted as is with comments to be addressed after release.

@atobiszei atobiszei merged commit 0603267 into main Nov 13, 2025
1 check passed
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.

4 participants