Patchwork [3/8] remove event_notifier_test

login
register
mail settings
Submitter Paolo Bonzini
Date May 26, 2010, 2:09 p.m.
Message ID <1274882978-9875-4-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/53628/
State New
Headers show

Comments

Paolo Bonzini - May 26, 2010, 2:09 p.m.
This is broken; since the eventfd is used in nonblocking mode there
is a race between reading and writing.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 event_notifier.c |   15 ---------------
 event_notifier.h |    1 -
 2 files changed, 0 insertions(+), 16 deletions(-)

Patch

diff --git a/event_notifier.c b/event_notifier.c
index 3f50568..0f7b8da 100644
--- a/event_notifier.c
+++ b/event_notifier.c
@@ -51,18 +51,3 @@  int event_notifier_test_and_clear(EventNotifier *e)
     int r = read(e->fd, &value, sizeof(value));
     return r == sizeof(value);
 }
-
-int event_notifier_test(EventNotifier *e)
-{
-    uint64_t value;
-    int r = read(e->fd, &value, sizeof(value));
-    if (r == sizeof(value)) {
-        /* restore previous value. */
-        int s = write(e->fd, &value, sizeof(value));
-        /* never blocks because we use EFD_SEMAPHORE.
-         * If we didn't we'd get EAGAIN on overflow
-         * and we'd have to write code to ignore it. */
-        assert(s == sizeof(value));
-    }
-    return r == sizeof(value);
-}
diff --git a/event_notifier.h b/event_notifier.h
index 8d5735f..714d690 100644
--- a/event_notifier.h
+++ b/event_notifier.h
@@ -12,6 +12,5 @@  void event_notifier_cleanup(EventNotifier *);
 int event_notifier_get_fd(EventNotifier *);
 int event_notifier_set(EventNotifier *);
 int event_notifier_test_and_clear(EventNotifier *);
-int event_notifier_test(EventNotifier *);
 
 #endif