From: Haomai Wang Date: Thu, 31 Dec 2015 15:46:17 +0000 (+0800) Subject: net_handler: adjust set_socket_options to avoid read from conf X-Git-Tag: ses5-milestone5~429^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2d1f7aaf404e2ef6feb0c46aa007f5a8b0999764;p=ceph.git net_handler: adjust set_socket_options to avoid read from conf 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 --- diff --git a/src/msg/async/net_handler.cc b/src/msg/async/net_handler.cc index dae74e4f5eb9..9a420d975770 100644 --- a/src/msg/async/net_handler.cc +++ b/src/msg/async/net_handler.cc @@ -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; diff --git a/src/msg/async/net_handler.h b/src/msg/async/net_handler.h index 02f2e96c5fb6..eb43f54f7bb4 100644 --- a/src/msg/async/net_handler.h +++ b/src/msg/async/net_handler.h @@ -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); /**