From: Sage Weil Date: Thu, 28 Feb 2013 21:00:19 +0000 (-0800) Subject: msg/Pipe: move setting of socket options into a common method X-Git-Tag: v0.59~66 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e10c1d145307d6b744be973329a7ec8f9ff5b91a;p=ceph.git msg/Pipe: move setting of socket options into a common method Signed-off-by: Sage Weil Reviewed-by: Greg Farnum --- diff --git a/src/msg/Accepter.cc b/src/msg/Accepter.cc index ac180e21441..90c68df6cf3 100644 --- a/src/msg/Accepter.cc +++ b/src/msg/Accepter.cc @@ -183,7 +183,6 @@ int Accepter::start() void *Accepter::entry() { - const md_config_t *conf = msgr->cct->_conf; ldout(msgr->cct,10) << "accepter starting" << dendl; int errors = 0; @@ -214,14 +213,6 @@ void *Accepter::entry() errors = 0; ldout(msgr->cct,10) << "accepted incoming on sd " << sd << dendl; - // disable Nagle algorithm? - if (conf->ms_tcp_nodelay) { - int flag = 1; - int r = ::setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag)); - if (r < 0) - ldout(msgr->cct,0) << "accepter could't set TCP_NODELAY: " << strerror_r(errno, buf, sizeof(buf)) << dendl; - } - msgr->add_accept_pipe(sd); } else { ldout(msgr->cct,0) << "accepter no incoming connection? sd = " << sd diff --git a/src/msg/Pipe.cc b/src/msg/Pipe.cc index 736146d9f4b..b9a9c3e93c9 100644 --- a/src/msg/Pipe.cc +++ b/src/msg/Pipe.cc @@ -212,6 +212,8 @@ int Pipe::accept() { ldout(msgr->cct,10) << "accept" << dendl; + set_socket_options(); + // my creater gave me sd via accept() assert(state == STATE_ACCEPTING); @@ -709,6 +711,19 @@ int Pipe::accept() return -1; } +void Pipe::set_socket_options() +{ + // disable Nagle algorithm? + if (msgr->cct->_conf->ms_tcp_nodelay) { + int flag = 1; + int r = ::setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag)); + if (r < 0) { + r = -errno; + ldout(msgr->cct,0) << "couldn't set TCP_NODELAY: " << cpp_strerror(r) << dendl; + } + } +} + int Pipe::connect() { bool got_bad_auth = false; @@ -758,13 +773,7 @@ int Pipe::connect() goto fail; } - // disable Nagle algorithm? - if (conf->ms_tcp_nodelay) { - int flag = 1; - int r = ::setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof(flag)); - if (r < 0) - ldout(msgr->cct,0) << "connect couldn't set TCP_NODELAY: " << strerror_r(errno, buf, sizeof(buf)) << dendl; - } + set_socket_options(); // verify banner // FIXME: this should be non-blocking, or in some other way verify the banner as we get it. diff --git a/src/msg/Pipe.h b/src/msg/Pipe.h index 3eeae705bd7..ce6298d9681 100644 --- a/src/msg/Pipe.h +++ b/src/msg/Pipe.h @@ -169,6 +169,8 @@ class DispatchQueue; uint64_t out_seq; uint64_t in_seq, in_seq_acked; + void set_socket_options(); + int accept(); // server handshake int connect(); // client handshake void reader();