aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Nilsson <troglobit@gmail.com>2017-10-11 22:04:17 +0200
committerJoachim Nilsson <troglobit@gmail.com>2017-10-11 22:04:17 +0200
commit8a1015cf3e29ecba09b4d9d211904a0b02a7030e (patch)
treefbc2fa0c96467be19c321d9da78218b1f2bb7c6e
parent586f0a7799a7a7627026b67fc4537bdd95d70f0a (diff)
downloadfinit-8a1015cf3e29ecba09b4d9d211904a0b02a7030e.zip
finit-8a1015cf3e29ecba09b4d9d211904a0b02a7030e.tar.gz
finit-8a1015cf3e29ecba09b4d9d211904a0b02a7030e.tar.bz2
API refactor, allow svc_stop_completed() to return the pending svc
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
-rw-r--r--src/svc.c13
-rw-r--r--src/svc.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/svc.c b/src/svc.c
index 0a9b6dd..f771a3e 100644
--- a/src/svc.c
+++ b/src/svc.c
@@ -307,20 +307,19 @@ void svc_foreach_type(int types, void (*cb)(svc_t *))
* svc_stop_completed - Have all stopped services been collected?
*
* Returns:
- * 1, if all stopped services have been collected. 0 otherwise.
+ * %NULL if all stopped services have been collected, otherwise a
+ * pointer to the first svc_t waiting to be collected.
*/
-int svc_stop_completed(void)
+svc_t *svc_stop_completed(void)
{
svc_t *svc;
for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) {
- if (svc->state == SVC_STOPPING_STATE) {
- _e("Waiting to collect %s(%d) ...", svc->cmd, svc->pid);
- return 0;
- }
+ if (svc->state == SVC_STOPPING_STATE)
+ return svc;
}
- return 1;
+ return NULL;
}
/**
diff --git a/src/svc.h b/src/svc.h
index ec62035..dfe141e 100644
--- a/src/svc.h
+++ b/src/svc.h
@@ -158,7 +158,7 @@ void svc_foreach (void (*cb)(svc_t *));
void svc_foreach_dynamic (void (*cb)(svc_t *));
void svc_foreach_type (int types, void (*cb)(svc_t *));
-int svc_stop_completed (void);
+svc_t *svc_stop_completed (void);
void svc_mark_dynamic (void);
void svc_check_dirty (svc_t *svc, struct timeval *mtime);