mirror of
https://github.com/ceph/ceph
synced 2024-12-30 07:23:11 +00:00
msg: we should set the socket options before connect or listen in order to have it take effect.
Signed-off-by: Ruifeng Yang <149233652@qq.com>
This commit is contained in:
parent
788c5584a0
commit
438b4e43cb
@ -975,7 +975,6 @@ int AsyncConnection::_process_connection()
|
|||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
net.set_socket_options(sd);
|
|
||||||
|
|
||||||
center->create_file_event(sd, EVENT_READABLE, read_handler);
|
center->create_file_event(sd, EVENT_READABLE, read_handler);
|
||||||
state = STATE_CONNECTING_WAIT_BANNER;
|
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;
|
listen_sd = -1;
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
net.set_socket_options(listen_sd);
|
||||||
|
|
||||||
// use whatever user specified (if anything)
|
// use whatever user specified (if anything)
|
||||||
entity_addr_t listen_addr = bind_addr;
|
entity_addr_t listen_addr = bind_addr;
|
||||||
listen_addr.set_family(family);
|
listen_addr.set_family(family);
|
||||||
|
@ -116,6 +116,9 @@ int NetHandler::generic_connect(const entity_addr_t& addr, bool nonblock)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_socket_options(s);
|
||||||
|
|
||||||
ret = ::connect(s, (sockaddr*)&addr.addr, addr.addr_size());
|
ret = ::connect(s, (sockaddr*)&addr.addr, addr.addr_size());
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (errno == EINPROGRESS && nonblock)
|
if (errno == EINPROGRESS && nonblock)
|
||||||
@ -126,8 +129,6 @@ int NetHandler::generic_connect(const entity_addr_t& addr, bool nonblock)
|
|||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_socket_options(s);
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +140,16 @@ int Accepter::bind(const entity_addr_t &bind_addr, const set<int>& avoid_ports)
|
|||||||
return rc;
|
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;
|
ldout(msgr->cct,10) << "accepter.bind bound to " << listen_addr << dendl;
|
||||||
|
|
||||||
// listen!
|
// listen!
|
||||||
|
@ -913,6 +913,9 @@ int Pipe::connect()
|
|||||||
}
|
}
|
||||||
|
|
||||||
recv_reset();
|
recv_reset();
|
||||||
|
|
||||||
|
set_socket_options();
|
||||||
|
|
||||||
// connect!
|
// connect!
|
||||||
ldout(msgr->cct,10) << "connecting to " << peer_addr << dendl;
|
ldout(msgr->cct,10) << "connecting to " << peer_addr << dendl;
|
||||||
rc = ::connect(sd, (sockaddr*)&peer_addr.addr, peer_addr.addr_size());
|
rc = ::connect(sd, (sockaddr*)&peer_addr.addr, peer_addr.addr_size());
|
||||||
@ -922,8 +925,6 @@ int Pipe::connect()
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_socket_options();
|
|
||||||
|
|
||||||
// verify banner
|
// verify banner
|
||||||
// FIXME: this should be non-blocking, or in some other way verify the banner as we get it.
|
// 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) {
|
if (tcp_read((char*)&banner, strlen(CEPH_BANNER)) < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user