]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/Messenger: avoid large pass by value
authorSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 14:19:38 +0000 (07:19 -0700)
committerSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 20:18:05 +0000 (13:18 -0700)
CID 717049: Big parameter passed by value (PASS_BY_VALUE)
At (1): Passing parameter bind_addr of type entity_addr_t (size 136 bytes) by value.

Signed-off-by: Sage Weil <sage@inktank.com>
src/msg/Accepter.cc
src/msg/Accepter.h
src/msg/Messenger.h
src/msg/SimpleMessenger.cc
src/msg/SimpleMessenger.h

index 0c9917e0ab5ee6596bbbc9a9db5381f2a3a867e9..f67dbd47a961c747fdab2e62f51a510b5d868701 100644 (file)
@@ -37,7 +37,7 @@
  * Accepter
  */
 
-int Accepter::bind(entity_addr_t &bind_addr, int avoid_port1, int avoid_port2)
+int Accepter::bind(const entity_addr_t &bind_addr, int avoid_port1, int avoid_port2)
 {
   const md_config_t *conf = msgr->cct->_conf;
   // bind to a socket
@@ -87,9 +87,9 @@ int Accepter::bind(entity_addr_t &bind_addr, int avoid_port1, int avoid_port2)
     rc = ::bind(listen_sd, (struct sockaddr *) &listen_addr.ss_addr(), listen_addr.addr_size());
     if (rc < 0) {
       char buf[80];
-      ldout(msgr->cct,0) << "accepter.bind unable to bind to " << bind_addr.ss_addr()
+      ldout(msgr->cct,0) << "accepter.bind unable to bind to " << listen_addr.ss_addr()
              << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl;
-      cerr << "accepter.bind unable to bind to " << bind_addr.ss_addr()
+      cerr << "accepter.bind unable to bind to " << listen_addr.ss_addr()
           << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
       return -errno;
     }
@@ -105,10 +105,10 @@ int Accepter::bind(entity_addr_t &bind_addr, int avoid_port1, int avoid_port2)
     }
     if (rc < 0) {
       char buf[80];
-      ldout(msgr->cct,0) << "accepter.bind unable to bind to " << bind_addr.ss_addr()
+      ldout(msgr->cct,0) << "accepter.bind unable to bind to " << listen_addr.ss_addr()
              << " on any port in range " << CEPH_PORT_START << "-" << CEPH_PORT_LAST
              << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl;
-      cerr << "accepter.bind unable to bind to " << bind_addr.ss_addr()
+      cerr << "accepter.bind unable to bind to " << listen_addr.ss_addr()
           << " on any port in range " << CEPH_PORT_START << "-" << CEPH_PORT_LAST
           << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
       return -errno;
index 07da2b50e7eb77fcb9b9d0833b6f5f83f24ed71a..07d766b32cddf70341ef1b5b50cc5bc76bd28e3f 100644 (file)
@@ -35,7 +35,7 @@ public:
     
   void *entry();
   void stop();
-  int bind(entity_addr_t &bind_addr, int avoid_port1=0, int avoid_port2=0);
+  int bind(const entity_addr_t &bind_addr, int avoid_port1=0, int avoid_port2=0);
   int rebind(int avoid_port);
   int start();
 };
index 9e3420cd8b2fdee418924c8e35a8702ccfcd2ca9..88f8732e00230ddf6afff3f7d55f3062cd3e183f 100644 (file)
@@ -314,7 +314,7 @@ public:
    * @return 0 on success, or -1 on error, or -errno if
    * we can be more specific about the failure.
    */
-  virtual int bind(entity_addr_t bind_addr) = 0;
+  virtual int bind(const entity_addr_t& bind_addr) = 0;
   /**
    * This is an optional function for implementations
    * to override. For those implementations that do
index 9b5ad56314823b7383047396021e532421aefa39..c44d1ca5c7179405830594532c3f2cf6b5aca29b 100644 (file)
@@ -244,7 +244,7 @@ void SimpleMessenger::queue_reap(Pipe *pipe)
 
 
 
-int SimpleMessenger::bind(entity_addr_t bind_addr)
+int SimpleMessenger::bind(const entity_addr_t &bind_addr)
 {
   lock.Lock();
   if (started) {
index f596a9e04c7b61f6eb70fb44b59ee9ebaac55192..cfa0ea9d8d335297970c472af08f097f28db1859 100644 (file)
@@ -179,7 +179,7 @@ public:
    * @return 0 on success, or -1 if the SimpleMessenger is already running, or
    * -errno if an error is returned from a system call.
    */
-  int bind(entity_addr_t bind_addr);
+  int bind(const entity_addr_t& bind_addr);
   /**
    * This function performs a full restart of the SimpleMessenger. It
    * calls mark_down_all() and binds to a new port. (If avoid_port