|
|
bd56df |
From 1980701650660459d35db0f956f536c8790e2056 Mon Sep 17 00:00:00 2001
|
|
|
bd56df |
Message-Id: <1980701650660459d35db0f956f536c8790e2056.1346162949.git.crobinso@redhat.com>
|
|
|
bd56df |
In-Reply-To: <90a59d545ad6759c105b0bfcfca70f574482584f.1346162949.git.crobinso@redhat.com>
|
|
|
bd56df |
References: <90a59d545ad6759c105b0bfcfca70f574482584f.1346162949.git.crobinso@redhat.com>
|
|
Justin M. Forbes |
d4cdad |
From: Amit Shah <amit.shah@redhat.com>
|
|
Justin M. Forbes |
d4cdad |
Date: Mon, 21 Mar 2011 20:32:58 +0100
|
|
|
bd56df |
Subject: [PATCH 103/114] iohandlers: Add enable/disable_write_fd_handler()
|
|
|
bd56df |
functions
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
These will be used to provide a cleaner API for the nonblocking case.
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
Signed-off-by: Amit Shah <amit.shah@redhat.com>
|
|
|
bd56df |
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
|
Justin M. Forbes |
d4cdad |
---
|
|
|
b6dd5a |
iohandler.c | 35 +++++++++++++++++++++++++++++++++++
|
|
|
b6dd5a |
main-loop.h | 3 +++
|
|
Hans de Goede |
329b58 |
2 files changed, 38 insertions(+)
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
diff --git a/iohandler.c b/iohandler.c
|
|
|
bd56df |
index dea4355..e663f83 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/iohandler.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/iohandler.c
|
|
Justin M. Forbes |
d4cdad |
@@ -45,6 +45,41 @@ typedef struct IOHandlerRecord {
|
|
Justin M. Forbes |
d4cdad |
static QLIST_HEAD(, IOHandlerRecord) io_handlers =
|
|
Justin M. Forbes |
d4cdad |
QLIST_HEAD_INITIALIZER(io_handlers);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static IOHandlerRecord *find_iohandler(int fd)
|
|
Justin M. Forbes |
d4cdad |
+{
|
|
Justin M. Forbes |
d4cdad |
+ IOHandlerRecord *ioh;
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+ QLIST_FOREACH(ioh, &io_handlers, next) {
|
|
Justin M. Forbes |
d4cdad |
+ if (ioh->fd == fd) {
|
|
Justin M. Forbes |
d4cdad |
+ return ioh;
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
+ return NULL;
|
|
Justin M. Forbes |
d4cdad |
+}
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+void enable_write_fd_handler(int fd, IOHandler *fd_write)
|
|
Justin M. Forbes |
d4cdad |
+{
|
|
Justin M. Forbes |
d4cdad |
+ IOHandlerRecord *ioh;
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+ ioh = find_iohandler(fd);
|
|
Justin M. Forbes |
d4cdad |
+ if (!ioh) {
|
|
Justin M. Forbes |
d4cdad |
+ return;
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+ ioh->fd_write = fd_write;
|
|
Justin M. Forbes |
d4cdad |
+}
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+void disable_write_fd_handler(int fd)
|
|
Justin M. Forbes |
d4cdad |
+{
|
|
Justin M. Forbes |
d4cdad |
+ IOHandlerRecord *ioh;
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+ ioh = find_iohandler(fd);
|
|
Justin M. Forbes |
d4cdad |
+ if (!ioh) {
|
|
Justin M. Forbes |
d4cdad |
+ return;
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+ ioh->fd_write = NULL;
|
|
Justin M. Forbes |
d4cdad |
+}
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
/* XXX: fd_read_poll should be suppressed, but an API change is
|
|
Justin M. Forbes |
d4cdad |
necessary in the character devices to suppress fd_can_read(). */
|
|
Justin M. Forbes |
d4cdad |
diff --git a/main-loop.h b/main-loop.h
|
|
Hans de Goede |
329b58 |
index dce1cd9..eb31273 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/main-loop.h
|
|
Justin M. Forbes |
d4cdad |
+++ b/main-loop.h
|
|
Hans de Goede |
329b58 |
@@ -175,6 +175,9 @@ typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
|
|
Justin M. Forbes |
d4cdad |
typedef int IOCanReadHandler(void *opaque);
|
|
Justin M. Forbes |
d4cdad |
typedef void IOHandler(void *opaque);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+void enable_write_fd_handler(int fd, IOHandler *fd_write);
|
|
Justin M. Forbes |
d4cdad |
+void disable_write_fd_handler(int fd);
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
/**
|
|
Justin M. Forbes |
d4cdad |
* qemu_set_fd_handler2: Register a file descriptor with the main loop
|
|
Justin M. Forbes |
d4cdad |
*
|
|
Justin M. Forbes |
d4cdad |
--
|
|
|
b6dd5a |
1.7.11.2
|
|
Justin M. Forbes |
d4cdad |
|