]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/AsyncConnection: simplify shutdown socket flow
authorHaomai Wang <haomai@xsky.com>
Fri, 1 Jul 2016 15:44:46 +0000 (23:44 +0800)
committerHaomai Wang <haomai@xsky.com>
Tue, 12 Jul 2016 15:50:47 +0000 (23:50 +0800)
Let cleanup resources things all in shutdown_socket

Signed-off-by: Haomai Wang <haomai@xsky.com>
src/msg/async/AsyncConnection.cc
src/msg/async/AsyncConnection.h

index 18d480da43df470bb59ec64df0e6a45dda9589a1..f2eb152e988eb47e15c6f638eaf0c6be2a1f52d9 100644 (file)
@@ -2180,12 +2180,7 @@ void AsyncConnection::fault()
   }
 
   write_lock.Lock();
-  if (sd >= 0) {
-    shutdown_socket();
-    center->delete_file_event(sd, EVENT_READABLE|EVENT_WRITABLE);
-    ::close(sd);
-    sd = -1;
-  }
+  shutdown_socket();
   can_write = WriteStatus::NOWRITE;
   open_write = false;
 
index 4b9205926f8a3681ea57edab61ac0c2cd828d6bd..de81e6c5fcb9dd39d1ac58a44063708ac576f1b0 100644 (file)
@@ -104,8 +104,16 @@ class AsyncConnection : public Connection {
     return !out_q.empty() || outcoming_bl.length();
   }
   void shutdown_socket() {
-    if (sd >= 0)
+    for (auto &&t : register_time_events)
+      center->delete_time_event(t);
+    register_time_events.clear();
+    center->delete_time_event(last_tick_id);
+    if (sd >= 0) {
+      center->delete_file_event(sd, EVENT_READABLE|EVENT_WRITABLE);
       ::shutdown(sd, SHUT_RDWR);
+      ::close(sd);
+      sd = -1;
+    }
   }
   Message *_get_next_outgoing(bufferlist *bl) {
     assert(write_lock.is_locked());