diff --git a/src/msg/Accepter.cc b/src/msg/Accepter.cc index ce0b04a05ad..0c9917e0ab5 100644 --- a/src/msg/Accepter.cc +++ b/src/msg/Accepter.cc @@ -118,19 +118,22 @@ int Accepter::bind(entity_addr_t &bind_addr, int avoid_port1, int avoid_port2) // what port did we get? socklen_t llen = sizeof(listen_addr.ss_addr()); - getsockname(listen_sd, (sockaddr*)&listen_addr.ss_addr(), &llen); + rc = getsockname(listen_sd, (sockaddr*)&listen_addr.ss_addr(), &llen); + if (rc < 0) { + rc = -errno; + lderr(msgr->cct) << "accepter.bind failed getsockname: " << cpp_strerror(rc) << dendl; + return rc; + } ldout(msgr->cct,10) << "accepter.bind bound to " << listen_addr << dendl; // listen! rc = ::listen(listen_sd, 128); if (rc < 0) { - char buf[80]; - ldout(msgr->cct,0) << "accepter.bind unable to listen on " << listen_addr - << ": " << strerror_r(errno, buf, sizeof(buf)) << dendl; - cerr << "accepter.bind unable to listen on " << listen_addr - << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl; - return -errno; + rc = -errno; + lderr(msgr->cct) << "accepter.bind unable to listen on " << listen_addr + << ": " << cpp_strerror(rc) << dendl; + return rc; } msgr->set_myaddr(bind_addr);