]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
AsyncConnection: Use reference instead of value passing for try_send
authorHaomai Wang <haomaiwang@gmail.com>
Wed, 27 May 2015 09:07:38 +0000 (17:07 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Sat, 30 May 2015 14:29:55 +0000 (22:29 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/msg/async/AsyncConnection.cc
src/msg/async/AsyncConnection.h

index f4745f5a7f09f4c920e56f30c81caade94a6cdcf..8fcf4858ed15e44514081d24b30d17a1014bd4e0 100644 (file)
@@ -269,9 +269,10 @@ int AsyncConnection::do_sendmsg(struct msghdr &msg, int len, bool more)
 
 // return the remaining bytes, it may larger than the length of ptr
 // else return < 0 means error
-int AsyncConnection::_try_send(bufferlist send_bl, bool send)
+int AsyncConnection::_try_send(bufferlist &send_bl, bool send)
 {
   assert(write_lock.is_locked());
+  ldout(async_msgr->cct, 20) << __func__ << " send bl length is " << send_bl.length() << dendl;
   if (send_bl.length()) {
     if (outcoming_bl.length())
       outcoming_bl.claim_append(send_bl);
@@ -1966,10 +1967,8 @@ int AsyncConnection::send_message(Message *m)
     m->put();
   } else {
     out_q[m->get_priority()].push_back(make_pair(bl, m));
-    if (can_write == 0) {
-      ldout(async_msgr->cct, 10) << __func__ << " write is denied, reschedule m=" << m << dendl;
-      center->dispatch_event_external(write_handler);
-    }
+    ldout(async_msgr->cct, 15) << __func__ << " inline write is denied, reschedule m=" << m << dendl;
+    center->dispatch_event_external(write_handler);
   }
   return 0;
 }
index 85a203ba357b27671eca28b3b9b4e741f6c29309..a707135ddccb7bc4c0c0ab629adde9e8df9a1f8c 100644 (file)
@@ -45,13 +45,13 @@ class AsyncConnection : public Connection {
 
   int read_bulk(int fd, char *buf, int len);
   int do_sendmsg(struct msghdr &msg, int len, bool more);
-  int try_send(bufferlist bl, bool send=true) {
+  int try_send(bufferlist &bl, bool send=true) {
     Mutex::Locker l(write_lock);
     return _try_send(bl, send);
   }
   // if "send" is false, it will only append bl to send buffer
   // the main usage is avoid error happen outside messenger threads
-  int _try_send(bufferlist bl, bool send=true);
+  int _try_send(bufferlist &bl, bool send=true);
   int _send(Message *m);
   void prepare_send_message(Message *m, bufferlist &bl);
   int read_until(uint64_t needed, char *p);