]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Event: Avoid potential wakeup leak between set and read
authorHaomai Wang <haomaiwang@gmail.com>
Wed, 27 May 2015 02:48:47 +0000 (10:48 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Sat, 30 May 2015 14:29:54 +0000 (22:29 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/msg/async/Event.cc

index 4b63209078f00c51effb4145aefef1a88269ff50..131d86924ed249efd2f224444825e06b62397f64 100644 (file)
@@ -46,9 +46,10 @@ class C_handle_notify : public EventCallback {
   C_handle_notify(EventCenter *c): center(c) {}
   void do_request(int fd_or_id) {
     char c[256];
-    center->already_wakeup.set(0);
-    int r = read(fd_or_id, c, sizeof(c));
-    assert(r > 0);
+    do {
+      center->already_wakeup.set(0);
+      read(fd_or_id, c, sizeof(c));
+    } while (center->already_wakeup.read());
   }
 };