mirror of
https://github.com/wiiu-env/wiiload_plugin.git
synced 2024-11-22 02:29:15 +01:00
Fix joining the thread
This commit is contained in:
parent
ca47e10a0c
commit
a8a3287ebf
16
src/main.cpp
16
src/main.cpp
@ -28,23 +28,19 @@ INITIALIZE_PLUGIN() {
|
|||||||
/* Entry point */
|
/* Entry point */
|
||||||
ON_APPLICATION_START() {
|
ON_APPLICATION_START() {
|
||||||
initLogging();
|
initLogging();
|
||||||
|
|
||||||
if (thread != nullptr) {
|
|
||||||
DEBUG_FUNCTION_LINE_WARN("The wiiload thread is still allocated but not running.");
|
|
||||||
thread->skipJoin = true;
|
|
||||||
delete thread;
|
|
||||||
thread = nullptr;
|
|
||||||
}
|
|
||||||
DEBUG_FUNCTION_LINE("Start wiiload thread");
|
DEBUG_FUNCTION_LINE("Start wiiload thread");
|
||||||
thread = new TcpReceiver(4299);
|
thread = new (std::nothrow) TcpReceiver(4299);
|
||||||
|
if (thread == nullptr) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to create wiiload thread");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ON_APPLICATION_ENDS() {
|
ON_APPLICATION_ENDS() {
|
||||||
DEBUG_FUNCTION_LINE("Stop wiiload thread");
|
DEBUG_FUNCTION_LINE("Stop wiiload thread!");
|
||||||
if (thread != nullptr) {
|
if (thread != nullptr) {
|
||||||
delete thread;
|
delete thread;
|
||||||
thread = nullptr;
|
thread = nullptr;
|
||||||
}
|
}
|
||||||
|
DEBUG_FUNCTION_LINE_VERBOSE("Done!");
|
||||||
deinitLogging();
|
deinitLogging();
|
||||||
}
|
}
|
@ -100,20 +100,12 @@ public:
|
|||||||
|
|
||||||
//! Shutdown thread
|
//! Shutdown thread
|
||||||
void shutdownThread() {
|
void shutdownThread() {
|
||||||
if (skipJoin) {
|
//! wait for thread to finish
|
||||||
DEBUG_FUNCTION_LINE_WARN("Skip joining the thread \"%s\", it's not running.", pThreadName.c_str());
|
if (pThread && !(iAttributes & eAttributeDetach)) {
|
||||||
} else {
|
if (isThreadSuspended()) {
|
||||||
//! wait for thread to finish
|
resumeThread();
|
||||||
if (!skipJoin && pThread && !(iAttributes & eAttributeDetach)) {
|
|
||||||
if (!OSIsThreadTerminated(pThread)) {
|
|
||||||
if (isThreadSuspended()) {
|
|
||||||
resumeThread();
|
|
||||||
}
|
|
||||||
OSJoinThread(pThread, nullptr);
|
|
||||||
} else {
|
|
||||||
DEBUG_FUNCTION_LINE_WARN("Thread \"%s\" has already been terminated!!!", pThreadName.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
OSJoinThread(pThread, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! free the thread stack buffer
|
//! free the thread stack buffer
|
||||||
@ -137,7 +129,6 @@ public:
|
|||||||
eAttributeDetach = 0x08,
|
eAttributeDetach = 0x08,
|
||||||
eAttributePinnedAff = 0x10
|
eAttributePinnedAff = 0x10
|
||||||
};
|
};
|
||||||
bool skipJoin = false;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int threadCallback(int argc, const char **argv) {
|
static int threadCallback(int argc, const char **argv) {
|
||||||
|
Loading…
Reference in New Issue
Block a user