Fix nasty service matcher bug

In some conditions, typically when the same command is used for multiple
services, e.g. the modules-load plugin, the svc_find() function returned
an existing "similar" entry instead of NULL, causing loss of config.

When creating, and searching for, a run/task/service we must follow the
new name:id paradigm to the letter.  Always create based on name:id and
always search for matching name:id.  The name may be derived from the
command, but they cannot be used interchangably.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2022-05-06 07:57:08 +02:00
1 parent 7e37ac348e
commit d3c6351ed8
5 files changed
+16 -38

No files matched your search

+2 -2
View File
@@ -1352,11 +1352,11 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
next:
svc = svc_find_by_tty(dev);
} else
svc = svc_find(cmd, id);
svc = svc_find(name, id);
if (!svc) {
_d("Creating new svc for %s name %s id %s type %d", cmd, name, id, type);
svc = svc_new(cmd, id, type);
svc = svc_new(cmd, name, id, type);
if (!svc) {
_e("Out of memory, cannot register service %s", cmd);
return errno = ENOMEM;