summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/ServerHandleImpl.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2023-05-11 22:05:17 +0200
committerMattes D <github@xoft.cz>2023-05-16 23:50:37 +0200
commitc9522fb740200ccef6230cec452c48efb31e5394 (patch)
tree7e74d70699e13dd0a92444a1a0add7a3059ac7ca /src/OSSupport/ServerHandleImpl.cpp
parentTry a timeout for jobs. (diff)
downloadcuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.gz
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.bz2
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.lz
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.xz
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.zst
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.zip
Diffstat (limited to 'src/OSSupport/ServerHandleImpl.cpp')
-rw-r--r--src/OSSupport/ServerHandleImpl.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/OSSupport/ServerHandleImpl.cpp b/src/OSSupport/ServerHandleImpl.cpp
index 1550e38f6..e68f82757 100644
--- a/src/OSSupport/ServerHandleImpl.cpp
+++ b/src/OSSupport/ServerHandleImpl.cpp
@@ -141,7 +141,9 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
if (!ServerHandleImplHelper::IsValidSocket(MainSock))
{
m_ErrorCode = EVUTIL_SOCKET_ERROR();
- Printf(m_ErrorMsg, "Cannot create socket for port %d: %s", a_Port, evutil_socket_error_to_string(m_ErrorCode));
+ m_ErrorMsg = fmt::format(FMT_STRING("Cannot create a server socket for port {}: {} ({})"),
+ a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode)
+ );
return false;
}
@@ -149,10 +151,10 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
if (evutil_make_listen_socket_reuseable(MainSock) != 0)
{
m_ErrorCode = EVUTIL_SOCKET_ERROR();
- Printf(m_ErrorMsg, "Port %d cannot be made reusable: %d (%s). Restarting the server might not work.",
+ m_ErrorMsg = fmt::format(FMT_STRING("Port {} cannot be made reusable: {} ({}). Restarting the server might not work."),
a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode)
);
- LOG("%s", m_ErrorMsg.c_str());
+ LOG("%s", m_ErrorMsg);
}
// Bind to all interfaces:
@@ -163,7 +165,9 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
if (bind(MainSock, reinterpret_cast<const sockaddr *>(&name), sizeof(name)) != 0)
{
m_ErrorCode = EVUTIL_SOCKET_ERROR();
- Printf(m_ErrorMsg, "Cannot bind IPv4 socket to port %d: %s", a_Port, evutil_socket_error_to_string(m_ErrorCode));
+ m_ErrorMsg = fmt::format(FMT_STRING("Cannot bind IPv4 socket to port {}: {} ({})"),
+ a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode)
+ );
evutil_closesocket(MainSock);
return false;
}
@@ -185,10 +189,10 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
if (evutil_make_listen_socket_reuseable(MainSock) != 0)
{
m_ErrorCode = EVUTIL_SOCKET_ERROR();
- Printf(m_ErrorMsg, "Port %d cannot be made reusable: %d (%s). Restarting the server might not work.",
+ m_ErrorMsg = fmt::format(FMT_STRING("Port {} cannot be made reusable: {} ({}). Restarting the server might not work."),
a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode)
);
- LOG("%s", m_ErrorMsg.c_str());
+ LOG("%s", m_ErrorMsg);
}
// Bind to all interfaces:
@@ -199,7 +203,7 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
if (bind(MainSock, reinterpret_cast<const sockaddr *>(&name), sizeof(name)) != 0)
{
m_ErrorCode = EVUTIL_SOCKET_ERROR();
- Printf(m_ErrorMsg, "Cannot bind IPv6 socket to port %d: %d (%s)", a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode));
+ m_ErrorMsg = fmt::format(FMT_STRING("Cannot bind IPv6 socket to port {}: {} ({})"), a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode));
evutil_closesocket(MainSock);
return false;
}
@@ -207,14 +211,14 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
if (evutil_make_socket_nonblocking(MainSock) != 0)
{
m_ErrorCode = EVUTIL_SOCKET_ERROR();
- Printf(m_ErrorMsg, "Cannot make socket on port %d non-blocking: %d (%s)", a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode));
+ m_ErrorMsg = fmt::format(FMT_STRING("Cannot make socket on port {} non-blocking: {} ({})"), a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode));
evutil_closesocket(MainSock);
return false;
}
if (listen(MainSock, SOMAXCONN) != 0)
{
m_ErrorCode = EVUTIL_SOCKET_ERROR();
- Printf(m_ErrorMsg, "Cannot listen on port %d: %d (%s)", a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode));
+ m_ErrorMsg = fmt::format(FMT_STRING("Cannot listen on port {}: {} ({})"), a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode));
evutil_closesocket(MainSock);
return false;
}
@@ -241,10 +245,10 @@ bool cServerHandleImpl::Listen(UInt16 a_Port)
if (evutil_make_listen_socket_reuseable(SecondSock) != 0)
{
m_ErrorCode = EVUTIL_SOCKET_ERROR();
- Printf(m_ErrorMsg, "Port %d cannot be made reusable (second socket): %d (%s). Restarting the server might not work.",
+ m_ErrorMsg = fmt::format(FMT_STRING("Port {} cannot be made reusable (second socket): {} ({}). Restarting the server might not work."),
a_Port, m_ErrorCode, evutil_socket_error_to_string(m_ErrorCode)
);
- LOG("%s", m_ErrorMsg.c_str());
+ LOG("%s", m_ErrorMsg);
}
// Make the secondary socket nonblocking: