提交 3005c2c2 编写于 作者: Y Yuriy Pudgorodskiy 提交者: Michael Roth

qga: fix fd leak with guest-exec i/o channels

Signed-off-by: NYuriy Pudgorodskiy <yur@virtuozzo.com>
Signed-off-by: NDenis V. Lunev <den@openvz.org>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
* squashed in g_io_channel_shutdown() to match cleanup paths for
  input/output
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
上级 e3800238
...@@ -373,6 +373,7 @@ static gboolean guest_exec_output_watch(GIOChannel *ch, ...@@ -373,6 +373,7 @@ static gboolean guest_exec_output_watch(GIOChannel *ch,
return true; return true;
close: close:
g_io_channel_shutdown(ch, true, NULL);
g_io_channel_unref(ch); g_io_channel_unref(ch);
g_atomic_int_set(&p->closed, 1); g_atomic_int_set(&p->closed, 1);
return false; return false;
...@@ -447,6 +448,7 @@ GuestExec *qmp_guest_exec(const char *path, ...@@ -447,6 +448,7 @@ GuestExec *qmp_guest_exec(const char *path,
g_io_channel_set_encoding(in_ch, NULL, NULL); g_io_channel_set_encoding(in_ch, NULL, NULL);
g_io_channel_set_buffered(in_ch, false); g_io_channel_set_buffered(in_ch, false);
g_io_channel_set_flags(in_ch, G_IO_FLAG_NONBLOCK, NULL); g_io_channel_set_flags(in_ch, G_IO_FLAG_NONBLOCK, NULL);
g_io_channel_set_close_on_unref(in_ch, true);
g_io_add_watch(in_ch, G_IO_OUT, guest_exec_input_watch, &gei->in); g_io_add_watch(in_ch, G_IO_OUT, guest_exec_input_watch, &gei->in);
} }
...@@ -462,6 +464,8 @@ GuestExec *qmp_guest_exec(const char *path, ...@@ -462,6 +464,8 @@ GuestExec *qmp_guest_exec(const char *path,
g_io_channel_set_encoding(err_ch, NULL, NULL); g_io_channel_set_encoding(err_ch, NULL, NULL);
g_io_channel_set_buffered(out_ch, false); g_io_channel_set_buffered(out_ch, false);
g_io_channel_set_buffered(err_ch, false); g_io_channel_set_buffered(err_ch, false);
g_io_channel_set_close_on_unref(out_ch, true);
g_io_channel_set_close_on_unref(err_ch, true);
g_io_add_watch(out_ch, G_IO_IN | G_IO_HUP, g_io_add_watch(out_ch, G_IO_IN | G_IO_HUP,
guest_exec_output_watch, &gei->out); guest_exec_output_watch, &gei->out);
g_io_add_watch(err_ch, G_IO_IN | G_IO_HUP, g_io_add_watch(err_ch, G_IO_IN | G_IO_HUP,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册