[libesl] Coverity 1589045 Check of thread-shared field evades lock acquisition

This commit is contained in:
Andrey Volk 2025-01-31 19:05:04 +03:00
parent 47a8b48ce6
commit a396dc8789

View File

@ -1167,13 +1167,6 @@ ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle)
esl_event_safe_destroy(&handle->last_ievent);
esl_event_safe_destroy(&handle->info_event);
if (mutex) {
esl_mutex_unlock(mutex);
esl_mutex_lock(mutex);
esl_mutex_unlock(mutex);
esl_mutex_destroy(&mutex);
}
if (handle->packet_buf) {
esl_buffer_destroy(&handle->packet_buf);
}
@ -1181,6 +1174,13 @@ ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle)
memset(handle, 0, sizeof(*handle));
handle->destroyed = 1;
if (mutex) {
esl_mutex_unlock(mutex);
esl_mutex_lock(mutex);
esl_mutex_unlock(mutex);
esl_mutex_destroy(&mutex);
}
return status;
}