mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
fix possible crash
This commit is contained in:
parent
989b93c92a
commit
de4ae9dd92
@ -248,7 +248,9 @@ bool Init()
|
||||
Log(LogLevel::Info, "MP sharedmem doesn't exist. creating\n");
|
||||
if (!MPQueue->create(kQueueSize))
|
||||
{
|
||||
Log(LogLevel::Error, "MP sharedmem create failed :(\n");
|
||||
Log(LogLevel::Error, "MP sharedmem create failed :( (%d)\n", MPQueue->error());
|
||||
delete MPQueue;
|
||||
MPQueue = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -328,6 +330,7 @@ void SetRecvTimeout(int timeout)
|
||||
|
||||
void Begin()
|
||||
{
|
||||
if (!MPQueue) return;
|
||||
MPQueue->lock();
|
||||
MPQueueHeader* header = (MPQueueHeader*)MPQueue->data();
|
||||
PacketReadOffset = header->PacketWriteOffset;
|
||||
@ -340,6 +343,7 @@ void Begin()
|
||||
|
||||
void End()
|
||||
{
|
||||
if (!MPQueue) return;
|
||||
MPQueue->lock();
|
||||
MPQueueHeader* header = (MPQueueHeader*)MPQueue->data();
|
||||
//SemReset(InstanceID);
|
||||
@ -421,6 +425,7 @@ void FIFOWrite(int fifo, void* buf, int len)
|
||||
|
||||
int SendPacketGeneric(u32 type, u8* packet, int len, u64 timestamp)
|
||||
{
|
||||
if (!MPQueue) return 0;
|
||||
MPQueue->lock();
|
||||
u8* data = (u8*)MPQueue->data();
|
||||
MPQueueHeader* header = (MPQueueHeader*)&data[0];
|
||||
@ -476,6 +481,7 @@ int SendPacketGeneric(u32 type, u8* packet, int len, u64 timestamp)
|
||||
|
||||
int RecvPacketGeneric(u8* packet, bool block, u64* timestamp)
|
||||
{
|
||||
if (!MPQueue) return 0;
|
||||
for (;;)
|
||||
{
|
||||
if (!SemWait(InstanceID, block ? RecvTimeout : 0))
|
||||
@ -552,6 +558,8 @@ int SendAck(u8* packet, int len, u64 timestamp)
|
||||
|
||||
int RecvHostPacket(u8* packet, u64* timestamp)
|
||||
{
|
||||
if (!MPQueue) return -1;
|
||||
|
||||
if (LastHostID != -1)
|
||||
{
|
||||
// check if the host is still connected
|
||||
@ -571,6 +579,8 @@ int RecvHostPacket(u8* packet, u64* timestamp)
|
||||
|
||||
u16 RecvReplies(u8* packets, u64 timestamp, u16 aidmask)
|
||||
{
|
||||
if (!MPQueue) return 0;
|
||||
|
||||
u16 ret = 0;
|
||||
u16 myinstmask = (1 << InstanceID);
|
||||
u16 curinstmask;
|
||||
|
Loading…
Reference in New Issue
Block a user