Fixed possible crash issue due to lingering leftover callback events from previous multiplayer session.

This commit is contained in:
ANR2ME 2020-09-04 01:48:15 +07:00
parent 7083342046
commit d99f55465e
3 changed files with 12 additions and 4 deletions

View file

@ -468,7 +468,8 @@ void __NetApctlCallbacks()
}
// Must be delayed long enough whenever there is a pending callback.
hleDelayResult(0, "Prevent Apctl thread from blocking", delayus);
sceKernelDelayThread(delayus);
hleSkipDeadbeef();;
}
static inline u32 AllocUser(u32 size, bool fromTop, const char *name) {
@ -758,6 +759,9 @@ static int sceNetApctlInit(int stackSize, int initPriority) {
if (netApctlInited)
return ERROR_NET_APCTL_ALREADY_INITIALIZED;
apctlEvents.clear();
netApctlState = PSP_NET_APCTL_STATE_DISCONNECTED;
// Set default value before connected to an AP
memset(&netApctlInfo, 0, sizeof(netApctlInfo)); // NetApctl_InitInfo();
std::string APname = "Wifi"; // fake AP/hotspot
@ -778,7 +782,6 @@ static int sceNetApctlInit(int stackSize, int initPriority) {
}
netApctlInited = true;
netApctlState = PSP_NET_APCTL_STATE_DISCONNECTED;
return 0;
}

View file

@ -248,6 +248,7 @@ static u32 sceNetAdhocctlInit(int stackSize, int prio, u32 productAddr) {
Memory::ReadStruct(productAddr, &product_code);
}
adhocctlEvents.clear();
netAdhocctlInited = true; //needed for cleanup during AdhocctlTerm even when it failed to connect to Adhoc Server (since it's being faked as success)
// Create fake PSP Thread for callback
@ -3007,6 +3008,7 @@ int sceNetAdhocMatchingInit(u32 memsize) {
fakePoolSize = memsize;
// Initialize Library
matchingEvents.clear();
netAdhocMatchingInited = true;
// Return Success
@ -4077,7 +4079,8 @@ void __NetTriggerCallbacks()
}
// Must be delayed long enough whenever there is a pending callback. Should it be 100-500ms for Adhocctl Events? or Not Less than the delays on sceNetAdhocctl HLE?
hleDelayResult(0, "Prevent Adhocctl thread from blocking", delayus);
sceKernelDelayThread(delayus);
hleSkipDeadbeef();
}
void __NetMatchingCallbacks() //(int matchingId)
@ -4108,7 +4111,8 @@ void __NetMatchingCallbacks() //(int matchingId)
}
// Must be delayed long enough whenever there is a pending callback. Should it be 10-100ms for Matching Events? or Not Less than the delays on sceNetAdhocMatching HLE?
hleDelayResult(0, "Prevent AdhocMatching thread from blocking", delayus);
sceKernelDelayThread(delayus);
hleSkipDeadbeef();
}
const HLEFunction sceNetAdhoc[] = {

View file

@ -162,6 +162,7 @@ static int sceNpAuthInit(u32 poolSize, u32 stackSize, u32 threadPrio)
npAuthMemStat.npMemSize = poolSize;
npAuthMemStat.npMaxMemSize = poolSize / 2; // Dummy
npAuthMemStat.npFreeMemSize = poolSize - 16; // Dummy.
npAuthEvents.clear();
npAuthInited = true;
return 0;