mirror of
https://github.com/wiiu-env/wiiload_plugin.git
synced 2024-11-22 10:39:16 +01:00
Optimize error handling
This commit is contained in:
parent
31dedcfd89
commit
1984203bed
@ -77,9 +77,11 @@ void TcpReceiver::executeThread() {
|
|||||||
socklen_t len;
|
socklen_t len;
|
||||||
while (!exitRequested) {
|
while (!exitRequested) {
|
||||||
if (serverSocket < 0) {
|
if (serverSocket < 0) {
|
||||||
if (!createSocket()) {
|
if (!createSocket() && !exitRequested) {
|
||||||
DEBUG_FUNCTION_LINE_WARN("Starting the wiiload server failed. Check the network connection.");
|
if (errno != EBUSY) {
|
||||||
OSSleepTicks(OSSecondsToTicks(5));
|
DEBUG_FUNCTION_LINE_WARN("Create socket failed %d", errno);
|
||||||
|
}
|
||||||
|
OSSleepTicks(OSMillisecondsToTicks(10));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -87,23 +89,23 @@ void TcpReceiver::executeThread() {
|
|||||||
memset(&clientAddr, 0, sizeof(clientAddr));
|
memset(&clientAddr, 0, sizeof(clientAddr));
|
||||||
|
|
||||||
len = 16;
|
len = 16;
|
||||||
DEBUG_FUNCTION_LINE("Waiting for wiiload connection");
|
|
||||||
int32_t clientSocket = accept(serverSocket, (struct sockaddr *) &clientAddr, &len);
|
int32_t clientSocket = accept(serverSocket, (struct sockaddr *) &clientAddr, &len);
|
||||||
if (clientSocket >= 0) {
|
if (clientSocket >= 0) {
|
||||||
uint32_t ipAddress = clientAddr.sin_addr.s_addr;
|
uint32_t ipAddress = clientAddr.sin_addr.s_addr;
|
||||||
|
DEBUG_FUNCTION_LINE("Waiting for wiiload connection");
|
||||||
int32_t result = loadToMemory(clientSocket, ipAddress);
|
int32_t result = loadToMemory(clientSocket, ipAddress);
|
||||||
close(clientSocket);
|
close(clientSocket);
|
||||||
|
|
||||||
if (result >= 0) {
|
if (result >= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!exitRequested) {
|
||||||
if (!exitRequested) {
|
if (errno != EBUSY) {
|
||||||
DEBUG_FUNCTION_LINE_WARN("Error accepting the socket");
|
DEBUG_FUNCTION_LINE_WARN("Accept failed %d", errno);
|
||||||
cleanupSocket();
|
|
||||||
OSSleepTicks(OSSecondsToTicks(1));
|
|
||||||
}
|
}
|
||||||
|
OSSleepTicks(OSMillisecondsToTicks(10));
|
||||||
}
|
}
|
||||||
|
OSSleepTicks(OSMillisecondsToTicks(1));
|
||||||
}
|
}
|
||||||
cleanupSocket();
|
cleanupSocket();
|
||||||
DEBUG_FUNCTION_LINE("Stopping wiiload server.");
|
DEBUG_FUNCTION_LINE("Stopping wiiload server.");
|
||||||
|
Loading…
Reference in New Issue
Block a user