提交 7d3a1c8b 编写于 作者: D Daniel P. Berrange

Fix race leading to crash when setting up dbus watches

Currently the virDBusAddWatch does

  virEventAddHandle(fd, flags,
                    virDBusWatchCallback,
                    watch, NULL);
  dbus_watch_set_data(watch, info, virDBusWatchFree);

Unfortunately this is racy - since the event loop is in a
different thread, the virDBusWatchCallback method may be
run before we get to calling dbus_watch_set_data. We must
reverse the order of these calls

See https://bugzilla.redhat.com/show_bug.cgi?id=885445Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 284d2fc2
......@@ -238,15 +238,15 @@ static dbus_bool_t virDBusAddWatch(DBusWatch *watch,
# else
fd = dbus_watch_get_fd(watch);
# endif
dbus_watch_set_data(watch, info, virDBusWatchFree);
info->bus = (DBusConnection *)data;
info->watch = virEventAddHandle(fd, flags,
virDBusWatchCallback,
watch, NULL);
if (info->watch < 0) {
VIR_FREE(info);
dbus_watch_set_data(watch, NULL, NULL);
return 0;
}
dbus_watch_set_data(watch, info, virDBusWatchFree);
return 1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册