Workaround for restarting the current application after loading a new plugin

This commit is contained in:
Maschell 2020-08-09 18:14:30 +02:00
parent b20b41901b
commit 6e44a24e1e
2 changed files with 19 additions and 5 deletions

View File

@ -1,6 +1,8 @@
#include <wups.h> #include <wups.h>
#include "utils/TcpReceiver.h" #include "utils/TcpReceiver.h"
#include <whb/log_udp.h> #include <whb/log_udp.h>
#include <coreinit/cache.h>
#include <sysapp/launch.h>
WUPS_PLUGIN_NAME("Wiiload"); WUPS_PLUGIN_NAME("Wiiload");
WUPS_PLUGIN_DESCRIPTION("Wiiload Server"); WUPS_PLUGIN_DESCRIPTION("Wiiload Server");
@ -26,9 +28,18 @@ void stopThread() {
} }
} }
ON_APPLICATION_END() { ON_APPLICATION_END() {
DEBUG_FUNCTION_LINE("Kill thread"); DEBUG_FUNCTION_LINE("Kill thread");
stopThread(); stopThread();
} }
bool gDoRelaunch __attribute__((section(".data"))) = 0;
ON_VYSNC() {
// On each frame check if we want to exit.
if(gDoRelaunch){
SYSRelaunchTitle(0, NULL);
gDoRelaunch = 0;
DCFlushRange(&gDoRelaunch, sizeof(gDoRelaunch));
}
}

View File

@ -14,6 +14,7 @@
#include "utils/utils.h" #include "utils/utils.h"
#include <wups_backend/PluginUtils.h> #include <wups_backend/PluginUtils.h>
#include <coreinit/debug.h> #include <coreinit/debug.h>
#include <coreinit/cache.h>
#define RPX_TEMP_PATH "fs:/vol/external01/wiiu/apps/" #define RPX_TEMP_PATH "fs:/vol/external01/wiiu/apps/"
#define RPX_TEMP_FILE "fs:/vol/external01/wiiu/apps/temp.rpx" #define RPX_TEMP_FILE "fs:/vol/external01/wiiu/apps/temp.rpx"
@ -25,7 +26,7 @@ void _SYSLaunchTitleWithStdArgsInNoSplash(uint64_t, uint32_t);
} }
TcpReceiver::TcpReceiver(int32_t port) TcpReceiver::TcpReceiver(int32_t port)
: CThread(CThread::eAttributeAffCore0), exitRequested(false), serverPort(port), serverSocket(-1) { : CThread(CThread::eAttributeAffCore1, 16,0x20000), exitRequested(false), serverPort(port), serverSocket(-1) {
resumeThread(); resumeThread();
} }
@ -62,8 +63,6 @@ void TcpReceiver::executeThread() {
return; return;
} }
DEBUG_FUNCTION_LINE("");
if ((ret = listen(serverSocket, 1)) < 0) { if ((ret = listen(serverSocket, 1)) < 0) {
socketclose(serverSocket); socketclose(serverSocket);
return; return;
@ -84,7 +83,9 @@ void TcpReceiver::executeThread() {
socketclose(clientSocket); socketclose(clientSocket);
if (result > 0) if (result > 0)
if (result >= 0){
break; break;
}
} else { } else {
DEBUG_FUNCTION_LINE("Server socket accept failed %i %d", clientSocket, wiiu_geterrno()); DEBUG_FUNCTION_LINE("Server socket accept failed %i %d", clientSocket, wiiu_geterrno());
OSSleepTicks(OSMicrosecondsToTicks(100000)); OSSleepTicks(OSMicrosecondsToTicks(100000));
@ -102,6 +103,7 @@ typedef struct __attribute((packed)) {
char path[256]; char path[256];
} LOAD_REQUEST; } LOAD_REQUEST;
extern bool gDoRelaunch;
int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) { int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
DEBUG_FUNCTION_LINE("Loading file from ip %08X", ipAddress); DEBUG_FUNCTION_LINE("Loading file from ip %08X", ipAddress);
@ -260,7 +262,8 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
PluginUtils::destroyPluginContainer(finalList); PluginUtils::destroyPluginContainer(finalList);
} else { } else {
PluginUtils::destroyPluginContainer(finalList); PluginUtils::destroyPluginContainer(finalList);
SYSRelaunchTitle(NULL, NULL); gDoRelaunch = 1;
DCFlushRange(&gDoRelaunch, sizeof(gDoRelaunch));
} }
free(loadAddress); free(loadAddress);