mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Don't perform the connection test in resolveHostName() for single addresses unless required
This commit is contained in:
parent
6ca0b93809
commit
128c1503f2
@ -102,7 +102,7 @@ unsigned int LiTestClientConnectivity(const char* testServer, unsigned short ref
|
||||
return ML_TEST_RESULT_INCONCLUSIVE;
|
||||
}
|
||||
|
||||
err = resolveHostName(testServer, AF_UNSPEC, referencePort, &address, &address_length);
|
||||
err = resolveHostName(testServer, AF_UNSPEC, TCP_PORT_FLAG_ALWAYS_TEST | referencePort, &address, &address_length);
|
||||
if (err != 0) {
|
||||
return ML_TEST_RESULT_INCONCLUSIVE;
|
||||
}
|
||||
|
@ -446,11 +446,13 @@ int resolveHostName(const char* host, int family, int tcpTestPort, struct sockad
|
||||
}
|
||||
|
||||
for (currentAddr = res; currentAddr != NULL; currentAddr = currentAddr->ai_next) {
|
||||
// Use the test port to ensure this address is working
|
||||
if (tcpTestPort != 0) {
|
||||
// Use the test port to ensure this address is working if:
|
||||
// a) We have multiple addresses
|
||||
// b) The caller asked us to test even with a single address
|
||||
if (tcpTestPort != 0 && (res->ai_next != NULL || (tcpTestPort & TCP_PORT_FLAG_ALWAYS_TEST))) {
|
||||
SOCKET testSocket = connectTcpSocket((struct sockaddr_storage*)currentAddr->ai_addr,
|
||||
currentAddr->ai_addrlen,
|
||||
tcpTestPort,
|
||||
tcpTestPort & TCP_PORT_MASK,
|
||||
TEST_PORT_TIMEOUT_SEC);
|
||||
if (testSocket == INVALID_SOCKET) {
|
||||
// Try the next address
|
||||
|
@ -52,7 +52,6 @@ typedef socklen_t SOCKADDR_LEN;
|
||||
void addrToUrlSafeString(struct sockaddr_storage* addr, char* string);
|
||||
|
||||
SOCKET createSocket(int addressFamily, int socketType, int protocol, int nonBlocking);
|
||||
int resolveHostName(const char* host, int family, int tcpTestPort, struct sockaddr_storage* addr, SOCKADDR_LEN* addrLen);
|
||||
SOCKET connectTcpSocket(struct sockaddr_storage* dstaddr, SOCKADDR_LEN addrlen, unsigned short port, int timeoutSec);
|
||||
int sendMtuSafe(SOCKET s, char* buffer, int size);
|
||||
SOCKET bindUdpSocket(int addrfamily, int bufferSize);
|
||||
@ -66,6 +65,10 @@ void closeSocket(SOCKET s);
|
||||
int isPrivateNetworkAddress(struct sockaddr_storage* address);
|
||||
int pollSockets(struct pollfd* pollFds, int pollFdsCount, int timeoutMs);
|
||||
|
||||
#define TCP_PORT_MASK 0xFFFF
|
||||
#define TCP_PORT_FLAG_ALWAYS_TEST 0x10000
|
||||
int resolveHostName(const char* host, int family, int tcpTestPort, struct sockaddr_storage* addr, SOCKADDR_LEN* addrLen);
|
||||
|
||||
void enterLowLatencyMode(void);
|
||||
void exitLowLatencyMode(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user