diff options
-rw-r--r-- | include/multiprocessing.h | 3 | ||||
-rw-r--r-- | src/lib/core/multiprocessing.c | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/include/multiprocessing.h b/include/multiprocessing.h index 5919462..ec7c1ad 100644 --- a/include/multiprocessing.h +++ b/include/multiprocessing.h @@ -38,6 +38,9 @@ struct MultiProcessingPool { int status_interval; ///< Report a pooled task is "running" every n seconds }; +/// A multiprocessing task's initial state (i.e. "FAIL") +#define MP_POOL_TASK_STATUS_INITIAL (-1) + /// Maximum number of multiprocessing tasks STASIS can execute #define MP_POOL_TASK_MAX 1000 diff --git a/src/lib/core/multiprocessing.c b/src/lib/core/multiprocessing.c index 484c566..29ea6b0 100644 --- a/src/lib/core/multiprocessing.c +++ b/src/lib/core/multiprocessing.c @@ -98,7 +98,7 @@ struct MultiProcessingTask *mp_pool_task(struct MultiProcessingPool *pool, const } // Set default status to "error" - slot->status = -1; + slot->status = MP_POOL_TASK_STATUS_INITIAL; // Set task identifier string memset(slot->ident, 0, sizeof(slot->ident)); @@ -254,7 +254,7 @@ int mp_pool_join(struct MultiProcessingPool *pool, size_t jobs, size_t flags) { for (size_t i = lower_i; i < upper_i; i++) { struct MultiProcessingTask *slot = &pool->task[i]; - if (slot->status == -1) { + if (slot->status == MP_POOL_TASK_STATUS_INITIAL) { if (mp_task_fork(pool, slot)) { fprintf(stderr, "%s: mp_task_fork failed\n", slot->ident); kill(0, SIGTERM); |