From d1e229c80a6e51ccc5b21d001271c41d6cda30bf Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Tue, 17 Feb 2026 03:34:47 +0100 Subject: Improve comments in server_register.c Remove a useless comment on an empty branch and add intent comments before the manual event loop startup, the periodic re-registration loop, and the shutdown deregistration block. --- src/server_register.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server_register.c b/src/server_register.c index c90fc31..60a4998 100644 --- a/src/server_register.c +++ b/src/server_register.c @@ -134,7 +134,6 @@ main (int argc, char **argv) if (strcmp (clientAuthMode, "anonymous") == 0) { - /* No extra args needed */ } else if (strcmp (clientAuthMode, "user") == 0) { @@ -187,6 +186,8 @@ main (int argc, char **argv) serverConfig->applicationDescription.applicationType = UA_APPLICATIONTYPE_SERVER; + /* Use run_startup + manual event loop (instead of UA_Server_run) so we + can periodically re-register with the LDS between iterations. */ UA_Server_run_startup (server); /* UA_Server_registerDiscovery consumes (clears) the client config, @@ -215,6 +216,8 @@ main (int argc, char **argv) "Initial register failed: %s", UA_StatusCode_name (retval)); + /* Periodic re-registration loop. Re-register with the LDS every + registerInterval seconds so the LDS does not purge us. */ time_t lastRegister = time (NULL); while (running) @@ -246,6 +249,8 @@ main (int argc, char **argv) } } + /* Deregister from the LDS before shutting down so the LDS removes + our entry immediately rather than waiting for the cleanup timeout. */ memset (&clientConfig, 0, sizeof (UA_ClientConfig)); retval = createSecureClientConfig ( &clientConfig, applicationUri, clientCertPath, clientKeyPath, argv + idx, -- cgit v1.2.3