]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
net_handler: adjust set_socket_options to avoid read from conf
authorHaomai Wang <haomai@xsky.com>
Thu, 31 Dec 2015 15:46:17 +0000 (23:46 +0800)
committerHaomai Wang <haomai@xsky.com>
Mon, 11 Jul 2016 14:41:50 +0000 (22:41 +0800)
We don't want net_handler rely on config value, caller may expect to pass
different value to set_socket_options according to different socket type
like heartbeat, client socket or server socket.

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

index dae74e4f5eb9f747e60c91fdc5a62818ac90d1f8..9a420d975770928df07bfb2f9d4a98fb00a1752f 100644 (file)
@@ -89,10 +89,10 @@ void NetHandler::set_close_on_exec(int sd)
   }
 }
 
-void NetHandler::set_socket_options(int sd)
+void NetHandler::set_socket_options(int sd, bool nodelay, int size)
 {
   // disable Nagle algorithm?
-  if (cct->_conf->ms_tcp_nodelay) {
+  if (nodelay) {
     int flag = 1;
     int r = ::setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag));
     if (r < 0) {
@@ -100,8 +100,7 @@ void NetHandler::set_socket_options(int sd)
       ldout(cct, 0) << "couldn't set TCP_NODELAY: " << cpp_strerror(r) << dendl;
     }
   }
-  if (cct->_conf->ms_tcp_rcvbuf) {
-    int size = cct->_conf->ms_tcp_rcvbuf;
+  if (size) {
     int r = ::setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (void*)&size, sizeof(size));
     if (r < 0)  {
       r = -errno;
index 02f2e96c5fb6c9e5bb1e8f083ffe92fab5854e28..eb43f54f7bb4fb84f227badb9a2eb0fcec7e2b0a 100644 (file)
@@ -29,7 +29,7 @@ namespace ceph {
     explicit NetHandler(CephContext *c): cct(c) {}
     int set_nonblock(int sd);
     void set_close_on_exec(int sd);
-    void set_socket_options(int sd);
+    void set_socket_options(int sd, bool nodelay, int size);
     int connect(const entity_addr_t &addr);
     
     /**