MEDIUM: jobs: support unstoppable jobs for soft stop
This patch allows a process to properly quit when some jobs are still
active, this feature is handled by the unstoppable_jobs variable, which
must be atomically incremented.
During each new iteration of run_poll_loop() the break condition of the
loop is now (jobs - unstoppable_jobs) == 0.
The unique usage of this at the moment is to handle the socketpair CLI
of a the worker during the stopping of the process. During the soft
stop, we could mark the CLI listener as an unstoppable job and still
handle new connections till every other jobs are stopped.
diff --git a/include/types/global.h b/include/types/global.h
index 344003a..5210323 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -224,6 +224,7 @@
extern int actconn; /* # of active sessions */
extern int listeners;
extern int jobs; /* # of active jobs (listeners, sessions, open devices) */
+extern int unstoppable_jobs; /* # of active jobs that can't be stopped during a soft stop */
extern int active_peers; /* # of active peers (connection attempts and successes) */
extern int connected_peers; /* # of really connected peers */
extern THREAD_LOCAL struct buffer trash;
diff --git a/include/types/stats.h b/include/types/stats.h
index 7525044..85cc906 100644
--- a/include/types/stats.h
+++ b/include/types/stats.h
@@ -290,6 +290,7 @@
INF_DESCRIPTION,
INF_STOPPING,
INF_JOBS,
+ INF_UNSTOPPABLE_JOBS,
INF_LISTENERS,
INF_ACTIVE_PEERS,
INF_CONNECTED_PEERS,