Skip to content

Commit

Permalink
Merge pull request #2194 from Sonicadvance1/fix_confusing_error
Browse files Browse the repository at this point in the history
FEXServerClient: Disable confusing connection log
  • Loading branch information
lioncash committed Dec 5, 2022
2 parents 66e0d46 + f0caa81 commit cc6306a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Source/Common/FEXServerClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace FEXServerClient {
return ServerFD;
}

int ConnectToServer() {
int ConnectToServer(ConnectionOption ConnectionOption) {
auto ServerSocketName = GetServerSocketName();

// Create the initial unix socket
Expand All @@ -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;
}
Expand All @@ -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

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion Source/Common/FEXServerClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc6306a

Please sign in to comment.