summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarian Csontos <mcsontos@redhat.com>2015-09-22 12:51:49 +0200
committerMarian Csontos <mcsontos@redhat.com>2015-09-22 21:36:09 +0200
commitead8c23b98ef1e1f6e3e5dac738fe2b0e8e6ea67 (patch)
tree09de9a7d5a04fcc30a71f702e23a49d39ac8c662
parent91cd918ae89e99bcec2b1d3e9ebec8847831a55f (diff)
downloadlvm2-dev-mcsontos-dmeventd-segfault-3.tar.gz
dmeventd: Allocate new thread only when neededdev-mcsontos-dmeventd-segfault-3
-rw-r--r--daemons/dmeventd/dmeventd.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 710f13aa7..9f3f32b8a 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -1044,33 +1044,33 @@ static int _register_for_event(struct message_data *message_data)
goto out;
}
- /* Preallocate thread status struct to avoid deadlock. */
- if (!(thread_new = _alloc_thread_status(message_data, dso_data))) {
- stack;
- ret = -ENOMEM;
- goto out;
- }
-
- if (!_fill_device_data(thread_new)) {
- stack;
- ret = -ENODEV;
- goto out;
- }
-
- /* If creation of timeout thread fails (as it may), we fail
- here completely. The client is responsible for either
- retrying later or trying to register without timeout
- events. However, if timeout thread cannot be started, it
- usually means we are so starved on resources that we are
- almost as good as dead already... */
- if ((thread_new->events & DM_EVENT_TIMEOUT) &&
- (ret = -_register_for_timeout(thread_new)))
- goto out;
-
_lock_mutex();
if (!(thread = _lookup_thread_status(message_data))) {
_unlock_mutex();
+ /* Preallocate thread status struct to avoid deadlock. */
+ if (!(thread_new = _alloc_thread_status(message_data, dso_data))) {
+ stack;
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ if (!_fill_device_data(thread_new)) {
+ stack;
+ ret = -ENODEV;
+ goto out;
+ }
+
+ /* If creation of timeout thread fails (as it may), we fail
+ here completely. The client is responsible for either
+ retrying later or trying to register without timeout
+ events. However, if timeout thread cannot be started, it
+ usually means we are so starved on resources that we are
+ almost as good as dead already... */
+ if ((thread_new->events & DM_EVENT_TIMEOUT) &&
+ (ret = -_register_for_timeout(thread_new)))
+ goto out;
+
if (!(ret = _do_register_device(thread_new)))
goto out;