server: warn when falling back to random TCP port

This commit is contained in:
Michael Davidsaver
2021-04-18 13:46:26 -07:00
parent 78940d5530
commit 4a6c468f9f
+5
View File
@@ -343,6 +343,7 @@ ServIface::ServIface(const std::string& addr, unsigned short port, server::Serve
,sock(AF_INET, SOCK_STREAM, 0)
{
server->acceptor_loop.assertInLoop();
auto orig_port = bind_addr.port();
// try to bind to requested port, then fallback to a random port
while(true) {
@@ -360,6 +361,10 @@ ServIface::ServIface(const std::string& addr, unsigned short port, server::Serve
name = bind_addr.tostring();
if(bind_addr.port() != orig_port) {
log_warn_printf(connsetup, "Server unable to bind port %u, falling back to %s\n", orig_port, name.c_str());
}
// added in libevent 2.1.1
#ifndef LEV_OPT_DISABLED
# define LEV_OPT_DISABLED 0