diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-09-13 17:37:20 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-09-18 23:07:13 -0400 |
commit | 7c0b2a96a8c2cff5ddf57186f583125f5a02668b (patch) | |
tree | 516126c8ef0a9fc64a2bfe79ed71312681084f81 | |
parent | fd3b4bddf862fe487ab8f0f860cf388cfadb4294 (diff) | |
download | stasis-7c0b2a96a8c2cff5ddf57186f583125f5a02668b.tar.gz |
Guard against overrun
-rw-r--r-- | src/multiprocessing.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/multiprocessing.c b/src/multiprocessing.c index bdd74ba..70f86be 100644 --- a/src/multiprocessing.c +++ b/src/multiprocessing.c @@ -7,8 +7,12 @@ static struct MultiProcessingTask *mp_pool_next_available(struct MultiProcessing struct MultiProcessingTask *mp_task(struct MultiProcessingPool *pool, const char *ident, char *cmd) { struct MultiProcessingTask *slot = mp_pool_next_available(pool); - //struct MultiProcessingTask *slot = mp_pool_any_available(pool); - pool->num_used++; + if (pool->num_used != pool->num_alloc) { + pool->num_used++; + } else { + fprintf(stderr, "Maximum number of tasks reached\n"); + return NULL; + } memset(slot->ident, 0, sizeof(slot->ident)); strncpy(slot->ident, ident, sizeof(slot->ident) - 1); |