Skip to content

Commit

Permalink
msg/simple: cleanups
Browse files Browse the repository at this point in the history
should save the `errno` which may be changed by `ldout` and/or `<<` operator

Signed-off-by: Yan Jun <yan.jun8@zte.com.cn>
(cherry picked from commit 91a29bc)
Signed-off-by: Robin H. Johnson <robin.johnson@dreamhost.com>
  • Loading branch information
Yan-waller authored and Robin H. Johnson committed Feb 22, 2017
1 parent 9f1e1ce commit d22beca
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/msg/simple/Pipe.cc
Expand Up @@ -827,15 +827,17 @@ void Pipe::set_socket_options()
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;
ldout(msgr->cct,0) << "couldn't set TCP_NODELAY: "
<< cpp_strerror(r) << dendl;
}
}
if (msgr->cct->_conf->ms_tcp_rcvbuf) {
int size = msgr->cct->_conf->ms_tcp_rcvbuf;
int r = ::setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (void*)&size, sizeof(size));
if (r < 0) {
r = -errno;
ldout(msgr->cct,0) << "couldn't set SO_RCVBUF to " << size << ": " << cpp_strerror(r) << dendl;
ldout(msgr->cct,0) << "couldn't set SO_RCVBUF to " << size
<< ": " << cpp_strerror(r) << dendl;
}
}

Expand All @@ -845,7 +847,8 @@ void Pipe::set_socket_options()
int r = ::setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, (void*)&val, sizeof(val));
if (r) {
r = -errno;
ldout(msgr->cct,0) << "couldn't set SO_NOSIGPIPE: " << cpp_strerror(r) << dendl;
ldout(msgr->cct,0) << "couldn't set SO_NOSIGPIPE: "
<< cpp_strerror(r) << dendl;
}
#endif

Expand All @@ -856,8 +859,9 @@ void Pipe::set_socket_options()
int iptos = IPTOS_CLASS_CS6;
r = ::setsockopt(sd, IPPROTO_IP, IP_TOS, &iptos, sizeof(iptos));
if (r < 0) {
r = -errno;
ldout(msgr->cct,0) << "couldn't set IP_TOS to " << iptos
<< ": " << cpp_strerror(errno) << dendl;
<< ": " << cpp_strerror(r) << dendl;
}
#endif
#if defined(SO_PRIORITY)
Expand All @@ -868,8 +872,9 @@ void Pipe::set_socket_options()
r = ::setsockopt(sd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio));
#endif
if (r < 0) {
r = -errno;
ldout(msgr->cct,0) << "couldn't set SO_PRIORITY to " << prio
<< ": " << cpp_strerror(errno) << dendl;
<< ": " << cpp_strerror(r) << dendl;
}
#endif
}
Expand Down

0 comments on commit d22beca

Please sign in to comment.