mirror of
https://github.com/ceph/ceph
synced 2025-01-18 17:12:29 +00:00
Merge pull request #5723 from H3C/wip-msg-bugfix1
msg: we should set the socket options before connect or listen in order to have it take effect. Reviewed-by: Haomai Wang <haomaiwang@gmail.com> Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
commit
61c7ac1c2b
@ -979,7 +979,6 @@ int AsyncConnection::_process_connection()
|
||||
if (r < 0) {
|
||||
goto fail;
|
||||
}
|
||||
net.set_socket_options(sd);
|
||||
|
||||
center->create_file_event(sd, EVENT_READABLE, read_handler);
|
||||
state = STATE_CONNECTING_WAIT_BANNER;
|
||||
|
@ -97,6 +97,9 @@ int Processor::bind(const entity_addr_t &bind_addr, const set<int>& avoid_ports)
|
||||
listen_sd = -1;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
net.set_socket_options(listen_sd);
|
||||
|
||||
// use whatever user specified (if anything)
|
||||
entity_addr_t listen_addr = bind_addr;
|
||||
listen_addr.set_family(family);
|
||||
|
@ -116,6 +116,9 @@ int NetHandler::generic_connect(const entity_addr_t& addr, bool nonblock)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
set_socket_options(s);
|
||||
|
||||
ret = ::connect(s, (sockaddr*)&addr.addr, addr.addr_size());
|
||||
if (ret < 0) {
|
||||
if (errno == EINPROGRESS && nonblock)
|
||||
@ -126,8 +129,6 @@ int NetHandler::generic_connect(const entity_addr_t& addr, bool nonblock)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
set_socket_options(s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,16 @@ int Accepter::bind(const entity_addr_t &bind_addr, const set<int>& avoid_ports)
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (msgr->cct->_conf->ms_tcp_rcvbuf) {
|
||||
int size = msgr->cct->_conf->ms_tcp_rcvbuf;
|
||||
rc = ::setsockopt(listen_sd, SOL_SOCKET, SO_RCVBUF, (void*)&size, sizeof(size));
|
||||
if (rc < 0) {
|
||||
rc = -errno;
|
||||
lderr(msgr->cct) << "accepter.bind failed to set SO_RCVBUF to " << size << ": " << cpp_strerror(r) << dendl;
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
ldout(msgr->cct,10) << "accepter.bind bound to " << listen_addr << dendl;
|
||||
|
||||
// listen!
|
||||
|
@ -897,6 +897,9 @@ int Pipe::connect()
|
||||
}
|
||||
|
||||
recv_reset();
|
||||
|
||||
set_socket_options();
|
||||
|
||||
// connect!
|
||||
ldout(msgr->cct,10) << "connecting to " << peer_addr << dendl;
|
||||
rc = ::connect(sd, (sockaddr*)&peer_addr.addr, peer_addr.addr_size());
|
||||
@ -906,8 +909,6 @@ int Pipe::connect()
|
||||
goto fail;
|
||||
}
|
||||
|
||||
set_socket_options();
|
||||
|
||||
// verify banner
|
||||
// FIXME: this should be non-blocking, or in some other way verify the banner as we get it.
|
||||
if (tcp_read((char*)&banner, strlen(CEPH_BANNER)) < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user