aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2010-02-08 17:01:30 -0200
committerAnthony Liguori <aliguori@us.ibm.com>2010-02-10 13:46:17 -0600
commit47116d1c90cdac94cb9da270320dcf0d5ce1cfe2 (patch)
treefe8e5304f0049ed1506bbd3d0130f5d13f35e2c2
parent27a749fb733dc64b7a215998be7f228a09bb27a7 (diff)
QMP: Don't leak on connection close
QMP's chardev event callback doesn't call json_message_parser_destroy() on CHR_EVENT_CLOSED. As the call to json_message_parser_init() on CHR_EVENT_OPENED allocates memory, we'are leaking on close. Fix that by just calling json_message_parser_destroy() on CHR_EVENT_CLOSED. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--monitor.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/monitor.c b/monitor.c
index 23c0661aa8..ae125b8230 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4404,16 +4404,20 @@ static QObject *get_qmp_greeting(void)
*/
static void monitor_control_event(void *opaque, int event)
{
- if (event == CHR_EVENT_OPENED) {
- QObject *data;
- Monitor *mon = opaque;
+ QObject *data;
+ Monitor *mon = opaque;
+ switch (event) {
+ case CHR_EVENT_OPENED:
mon->mc->command_mode = 0;
json_message_parser_init(&mon->mc->parser, handle_qmp_command);
-
data = get_qmp_greeting();
monitor_json_emitter(mon, data);
qobject_decref(data);
+ break;
+ case CHR_EVENT_CLOSED:
+ json_message_parser_destroy(&mon->mc->parser);
+ break;
}
}