1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

dmeventd: minimize locking time for get_imeout

Don't hold lock when creating message (allocating memory).
Thread cannot dissapear as it's only the same thread which
may clean it.
This commit is contained in:
Zdenek Kabelac 2015-10-22 12:38:26 +02:00
parent e2ea2a8147
commit 15dbd4b56a

View File

@ -1292,18 +1292,18 @@ static int _get_timeout(struct message_data *message_data)
struct thread_status *thread;
struct dm_event_daemon_message *msg = message_data->msg;
dm_free(msg->data);
_lock_mutex();
if ((thread = _lookup_thread_status(message_data))) {
msg->size = dm_asprintf(&(msg->data), "%s %" PRIu32,
message_data->id, thread->timeout);
} else
msg->data = NULL;
thread = _lookup_thread_status(message_data);
_unlock_mutex();
return thread ? 0 : -ENODEV;
if (!thread)
return -ENODEV;
dm_free(msg->data);
msg->size = dm_asprintf(&(msg->data), "%s %" PRIu32,
message_data->id, thread->timeout);
return (msg->data && msg->size) ? 0 : -ENOMEM;
}
/* Open fifos used for client communication. */