FEXServerClient: Disable confusing connection log

On first FEXInterpreter execution, it is expected that `ConnectToServer`
will fail with `ECONNREFUSED` because FEXServer won't be running.

Skip printing this first messaage to stderr if configured.
If it is some other error message then ensure it is still printed.
This commit is contained in:
Ryan Houdek committed 2022-12-05 05:18:41 -08:00
1 parent 66e0d46d89
commit f0caa81253
2 files changed
+11 -5

No files matched your search

+6 -4
View File
@@ -147,7 +147,7 @@ namespace FEXServerClient {
return ServerFD;
}
int ConnectToServer() {
int ConnectToServer(ConnectionOption ConnectionOption) {
auto ServerSocketName = GetServerSocketName();
// Create the initial unix socket
@@ -169,7 +169,9 @@ namespace FEXServerClient {
size_t SizeOfAddr = sizeof(addr.sun_family) + SizeOfSocketString;
if (connect(SocketFD, reinterpret_cast<struct sockaddr*>(&addr), SizeOfAddr) == -1) {
LogMan::Msg::EFmt("Couldn't connect to FEXServer socket {} {} {}", ServerSocketName, errno, strerror(errno));
if (ConnectionOption == ConnectionOption::Default || errno != ECONNREFUSED) {
LogMan::Msg::EFmt("Couldn't connect to FEXServer socket {} {} {}", ServerSocketName, errno, strerror(errno));
}
close(SocketFD);
return -1;
}
@@ -196,7 +198,7 @@ namespace FEXServerClient {
}
int ConnectToAndStartServer(char *InterpreterPath) {
int ServerFD = ConnectToServer();
int ServerFD = ConnectToServer(ConnectionOption::NoPrintConnectionError);
if (ServerFD == -1) {
// Couldn't connect to the server. Start one
@@ -253,7 +255,7 @@ namespace FEXServerClient {
while (poll(&PollFD, 1, -1) == -1 && errno == EINTR);
for (size_t i = 0; i < 5; ++i) {
ServerFD = ConnectToServer();
ServerFD = ConnectToServer(ConnectionOption::Default);
if (ServerFD != -1) {
break;
+5 -1
View File
@@ -63,12 +63,16 @@ namespace FEXServerClient {
*/
int ConnectToAndStartServer(char *InterpreterPath);
enum class ConnectionOption {
Default,
NoPrintConnectionError,
};
/**
* @brief Connect to a FEXServer instance if it exists
*
* @return socket FD for communicating with server
*/
int ConnectToServer();
int ConnectToServer(ConnectionOption ConnectionOption = ConnectionOption::Default);
/**
* @name Packet request functions