qemu/0402-iohandlers-Add-enable-disable_write_fd_handler-funct.patch

78 lines
1.9 KiB
Diff
Raw Normal View History

2012-10-28 18:05:07 +00:00
From 2ac23d2134611b4e5b0fb389911bd03baa685df3 Mon Sep 17 00:00:00 2001
2012-01-13 19:46:23 +00:00
From: Amit Shah <amit.shah@redhat.com>
Date: Mon, 21 Mar 2011 20:32:58 +0100
2012-10-28 18:05:07 +00:00
Subject: [PATCH] iohandlers: Add enable/disable_write_fd_handler() functions
2012-01-13 19:46:23 +00:00
These will be used to provide a cleaner API for the nonblocking case.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
2012-08-28 15:15:48 +00:00
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2012-01-13 19:46:23 +00:00
---
iohandler.c | 35 +++++++++++++++++++++++++++++++++++
main-loop.h | 3 +++
2 files changed, 38 insertions(+)
2012-01-13 19:46:23 +00:00
diff --git a/iohandler.c b/iohandler.c
2012-10-28 18:05:07 +00:00
index a2d871b..c00fecd 100644
2012-01-13 19:46:23 +00:00
--- a/iohandler.c
+++ b/iohandler.c
@@ -45,6 +45,41 @@ typedef struct IOHandlerRecord {
static QLIST_HEAD(, IOHandlerRecord) io_handlers =
QLIST_HEAD_INITIALIZER(io_handlers);
2012-01-13 19:46:23 +00:00
+static IOHandlerRecord *find_iohandler(int fd)
+{
+ IOHandlerRecord *ioh;
+
+ QLIST_FOREACH(ioh, &io_handlers, next) {
+ if (ioh->fd == fd) {
+ return ioh;
+ }
+ }
+ return NULL;
+}
+
+void enable_write_fd_handler(int fd, IOHandler *fd_write)
+{
+ IOHandlerRecord *ioh;
+
+ ioh = find_iohandler(fd);
+ if (!ioh) {
+ return;
+ }
+
+ ioh->fd_write = fd_write;
+}
+
+void disable_write_fd_handler(int fd)
+{
+ IOHandlerRecord *ioh;
+
+ ioh = find_iohandler(fd);
+ if (!ioh) {
+ return;
+ }
+
+ ioh->fd_write = NULL;
+}
2012-01-13 19:46:23 +00:00
/* XXX: fd_read_poll should be suppressed, but an API change is
necessary in the character devices to suppress fd_can_read(). */
diff --git a/main-loop.h b/main-loop.h
index dce1cd9..eb31273 100644
2012-01-13 19:46:23 +00:00
--- a/main-loop.h
+++ b/main-loop.h
@@ -175,6 +175,9 @@ typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
2012-01-13 19:46:23 +00:00
typedef int IOCanReadHandler(void *opaque);
typedef void IOHandler(void *opaque);
2012-01-13 19:46:23 +00:00
+void enable_write_fd_handler(int fd, IOHandler *fd_write);
+void disable_write_fd_handler(int fd);
+
/**
* qemu_set_fd_handler2: Register a file descriptor with the main loop
*
--
2012-10-28 18:05:07 +00:00
1.7.12.1
2012-01-13 19:46:23 +00:00