提交 b8904164 编写于 作者: P Peter Maydell

Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2018-07-31' into staging

Monitor patches for 2018-07-31 (3.0.0-rc3)

# gpg: Signature made Tue 31 Jul 2018 16:46:16 BST
# gpg:                using RSA key 3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-monitor-2018-07-31:
  monitor: temporary fix for dead-lock on event recursion
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
......@@ -633,7 +633,7 @@ static void monitor_qapi_event_handler(void *opaque);
* applying any rate limiting if required.
*/
static void
monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
monitor_qapi_event_queue_no_reenter(QAPIEvent event, QDict *qdict)
{
MonitorQAPIEventConf *evconf;
MonitorQAPIEventState *evstate;
......@@ -688,6 +688,48 @@ monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
qemu_mutex_unlock(&monitor_lock);
}
static void
monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp)
{
/*
* monitor_qapi_event_queue_no_reenter() is not reentrant: it
* would deadlock on monitor_lock. Work around by queueing
* events in thread-local storage.
* TODO: remove this, make it re-enter safe.
*/
typedef struct MonitorQapiEvent {
QAPIEvent event;
QDict *qdict;
QSIMPLEQ_ENTRY(MonitorQapiEvent) entry;
} MonitorQapiEvent;
static __thread QSIMPLEQ_HEAD(, MonitorQapiEvent) event_queue;
static __thread bool reentered;
MonitorQapiEvent *ev;
if (!reentered) {
QSIMPLEQ_INIT(&event_queue);
}
ev = g_new(MonitorQapiEvent, 1);
ev->qdict = qobject_ref(qdict);
ev->event = event;
QSIMPLEQ_INSERT_TAIL(&event_queue, ev, entry);
if (reentered) {
return;
}
reentered = true;
while ((ev = QSIMPLEQ_FIRST(&event_queue)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&event_queue, entry);
monitor_qapi_event_queue_no_reenter(ev->event, ev->qdict);
qobject_unref(ev->qdict);
g_free(ev);
}
reentered = false;
}
/*
* This function runs evconf->rate ns after sending a throttled
* event.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册