diff options
author | Max Romanov <max.romanov@nginx.com> | 2018-08-07 15:52:11 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2018-08-07 15:52:11 +0300 |
commit | 257283cc389a8f453cbf4ebd028af79e9b23258b (patch) | |
tree | c466cca23d07ab0569c20e6faea1735d5345d9ee /src | |
parent | 09268676ef9f80291c554431b15495afd63177af (diff) | |
download | unit-257283cc389a8f453cbf4ebd028af79e9b23258b.tar.gz unit-257283cc389a8f453cbf4ebd028af79e9b23258b.tar.bz2 |
Fixed unit library mutex usage.
For the optimization purpose, function nxt_unit_remove_process() expects
lib->mutex to be locked. The function then moves ports queue into temporary
queue and releases mutex. In nxt_unit_done() there were two errors: mutex was
not locked before nxt_unit_remove_process() call and mutex was not destroyed.
It is hard to tell what was possible negative impact of this errors.
Found by Coverity (CID 308517).
Diffstat (limited to '')
-rw-r--r-- | src/nxt_unit.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nxt_unit.c b/src/nxt_unit.c index 2694de7d..b7ac9b61 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -2728,14 +2728,20 @@ nxt_unit_done(nxt_unit_ctx_t *ctx) } nxt_queue_loop; for ( ;; ) { + pthread_mutex_lock(&lib->mutex); + process = nxt_unit_process_pop_first(lib); if (process == NULL) { + pthread_mutex_unlock(&lib->mutex); + break; } nxt_unit_remove_process(ctx, process); } + pthread_mutex_destroy(&lib->mutex); + free(lib); } |