Add support run/task/service 'conflict:foo' handling

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-02-28 00:49:55 +01:00
1 parent a613ee908f
commit 56a89db889
4 files changed
+82 -1

No files matched your search

+45
View File
@@ -619,6 +619,51 @@ int svc_enabled(svc_t *svc)
return 1;
}
/**
* svc_conflicts - Check if svc conflicts with any other running svc
* @svc:
*
* Returns:
* %TRUE(1) or %FALSE(0)
*/
int svc_conflicts(svc_t *svc)
{
char *ptr, *nm;
int rc = 0;
if (!svc->conflict[0])
return 0;
ptr = strdup(svc->conflict);
if (!ptr)
return 0;
nm = strtok(ptr, ",");
while (nm) {
char *name, *id;
svc_t *s;
name = strdupa(nm);
id = strchr(name, ':');
if (id)
id++ = 0;
else
id = "";
s = svc_find(name, id);
if (s) {
if (s->state >= SVC_STOPPING_STATE)
rc = 1;
break;
}
nm = strtok(NULL, ",");
}
free(ptr);
return rc;
}
/* break up "job:id job:id job:id ..." into several "job:id" tokens */
static char *tokstr(char *str, size_t len)
{