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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user