[Spice-devel] [PATCH xf86-video-qxl 2/4 v2] Only watch the uinput channel when an agent is connected.
Jeremy White
jwhite at codeweavers.com
Mon Oct 19 12:33:56 PDT 2015
Otherwise, you constantly spin loop, getting a return code of 0,
and pegging CPU usage at 100%.
Signed-off-by: Jeremy White <jwhite at codeweavers.com>
---
src/spiceqxl_uinput.c | 13 ++++++++++++-
src/spiceqxl_uinput.h | 1 +
src/spiceqxl_vdagent.c | 2 ++
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/spiceqxl_uinput.c b/src/spiceqxl_uinput.c
index 1e61907..38ed2ed 100644
--- a/src/spiceqxl_uinput.c
+++ b/src/spiceqxl_uinput.c
@@ -121,6 +121,17 @@ void spiceqxl_uinput_init(qxl_screen_t *qxl)
uinput_filename, strerror(errno));
return;
}
- qxl->core->watch_add(uinput_fd, SPICE_WATCH_EVENT_READ, spiceqxl_uinput_read_cb, qxl);
spice_server_set_agent_mouse(qxl->spice_server, 1);
}
+
+void spiceqxl_uinput_watch(qxl_screen_t *qxl, Bool on)
+{
+ static SpiceWatch *handle = NULL;
+
+ if (on)
+ handle = qxl->core->watch_add(uinput_fd, SPICE_WATCH_EVENT_READ, spiceqxl_uinput_read_cb, qxl);
+ else if (handle) {
+ qxl->core->watch_remove(handle);
+ handle = NULL;
+ }
+}
diff --git a/src/spiceqxl_uinput.h b/src/spiceqxl_uinput.h
index 59c704c..33715a0 100644
--- a/src/spiceqxl_uinput.h
+++ b/src/spiceqxl_uinput.h
@@ -4,5 +4,6 @@
#include "qxl.h"
void spiceqxl_uinput_init(qxl_screen_t *qxl);
+void spiceqxl_uinput_watch(qxl_screen_t *qxl, Bool on);
#endif
diff --git a/src/spiceqxl_vdagent.c b/src/spiceqxl_vdagent.c
index 315ae53..a62c1e6 100644
--- a/src/spiceqxl_vdagent.c
+++ b/src/spiceqxl_vdagent.c
@@ -62,6 +62,7 @@ static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
vdagent_sin.qxl->core->watch_remove(virtio_client_watch);
virtio_client_watch = NULL;
spice_server_remove_interface(&vdagent_sin.base.base);
+ spiceqxl_uinput_watch(vdagent_sin.qxl, FALSE);
}
return nbytes;
}
@@ -123,6 +124,7 @@ static void on_accept(int fd, int event, void *opaque)
/* TODO - SPICE_WATCH_EVENT_WRITE */, on_read_available, qxl);
spice_server_add_interface(qxl->spice_server, &vdagent_sin.base.base);
+ spiceqxl_uinput_watch(qxl, TRUE);
return;
--
2.1.4
More information about the Spice-devel
mailing list