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).
This commit is contained in:
Max Romanov
2018-08-07 15:52:11 +03:00
parent 09268676ef
commit 257283cc38

View File

@@ -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);
}