[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 3/6] monitor: Clean up fd sets on monitor disconn
From: |
Corey Bryant |
Subject: |
[Qemu-devel] [PATCH v6 3/6] monitor: Clean up fd sets on monitor disconnect |
Date: |
Fri, 3 Aug 2012 13:28:06 -0400 |
Each fd set has a boolean that keeps track of whether or not the
fd set is in use by a monitor connection. When a monitor
disconnects, all fds that are members of an fd set with refcount
of zero are closed. This prevents any fd leakage associated with
a client disconnect prior to using a passed fd.
v5:
-This patch is new in v5.
-This support addresses concerns from v4 regarding fd leakage
if the client disconnects unexpectedly. (address@hidden,
address@hidden, address@hidden)
v6:
-No changes
Signed-off-by: Corey Bryant <address@hidden>
---
monitor.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/monitor.c b/monitor.c
index 9aa9f7e..a46ef8d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2559,6 +2559,19 @@ FdsetInfoList *qmp_query_fdsets(Error **errp)
return fdset_list;
}
+static void monitor_fdsets_set_in_use(Monitor *mon, bool in_use)
+{
+ mon_fdset_t *mon_fdset;
+ mon_fdset_t *mon_fdset_next;
+
+ QLIST_FOREACH_SAFE(mon_fdset, &mon->fdsets, next, mon_fdset_next) {
+ mon_fdset->in_use = in_use;
+ if (!in_use) {
+ monitor_fdset_cleanup(mon_fdset);
+ }
+ }
+}
+
/* mon_cmds and info_cmds would be sorted at runtime */
static mon_cmd_t mon_cmds[] = {
#include "hmp-commands.h"
@@ -4763,9 +4776,11 @@ static void monitor_control_event(void *opaque, int
event)
data = get_qmp_greeting();
monitor_json_emitter(mon, data);
qobject_decref(data);
+ monitor_fdsets_set_in_use(mon, true);
break;
case CHR_EVENT_CLOSED:
json_message_parser_destroy(&mon->mc->parser);
+ monitor_fdsets_set_in_use(mon, false);
break;
}
}
--
1.7.10.4
- [Qemu-devel] [PATCH v6 0/6] file descriptor passing using fd sets, Corey Bryant, 2012/08/03
- [Qemu-devel] [PATCH v6 3/6] monitor: Clean up fd sets on monitor disconnect,
Corey Bryant <=
- [Qemu-devel] [PATCH v6 5/6] block: Convert close calls to qemu_close, Corey Bryant, 2012/08/03
- [Qemu-devel] [PATCH v6 6/6] block: Enable qemu_open/close to work with fd sets, Corey Bryant, 2012/08/03
- [Qemu-devel] [PATCH v6 1/6] qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg, Corey Bryant, 2012/08/03
- [Qemu-devel] [PATCH v6 2/6] qapi: Introduce add-fd, remove-fd, query-fdsets, Corey Bryant, 2012/08/03