]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Event: Use atomic cas to avoid missing wakeup
authorHaomai Wang <haomaiwang@gmail.com>
Thu, 30 Apr 2015 14:22:53 +0000 (22:22 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Thu, 30 Apr 2015 14:22:53 +0000 (22:22 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/msg/async/Event.cc

index 4bf2d3151a76020080e7e873325fbf47d2179ac3..daa5fb1b191261fe60fc1f12aed935a2968c27cf 100644 (file)
@@ -246,7 +246,7 @@ void EventCenter::delete_time_event(uint64_t id)
 
 void EventCenter::wakeup()
 {
-  if (!already_wakeup.read()) {
+  if (already_wakeup.cas(0, 1)) {
     ldout(cct, 1) << __func__ << dendl;
     char buf[1];
     buf[0] = 'c';
@@ -254,7 +254,6 @@ void EventCenter::wakeup()
     int n = write(notify_send_fd, buf, 1);
     // FIXME ?
     assert(n == 1);
-    already_wakeup.set(1);
   }
 }