mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 17:05:50 +00:00
Avoid unlock and immediate relock of mutex
This commit is contained in:
parent
1376c62e5f
commit
d9ea208dea
@ -520,7 +520,7 @@ static bool sendMessageEnet(short ptype, short paylen, const void* payload) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PltUnlockMutex(&enetMutex);
|
||||
// enetMutex still locked here
|
||||
}
|
||||
else {
|
||||
PNVCTL_ENET_PACKET_HEADER_V1 packet;
|
||||
@ -532,12 +532,18 @@ static bool sendMessageEnet(short ptype, short paylen, const void* payload) {
|
||||
packet = (PNVCTL_ENET_PACKET_HEADER_V1)enetPacket->data;
|
||||
packet->type = LE16(ptype);
|
||||
memcpy(&packet[1], payload, paylen);
|
||||
|
||||
PltLockMutex(&enetMutex);
|
||||
}
|
||||
|
||||
PltLockMutex(&enetMutex);
|
||||
// Queue the packet to be sent
|
||||
err = enet_peer_send(peer, 0, enetPacket);
|
||||
|
||||
// Actually send it
|
||||
enet_host_service(client, NULL, 0);
|
||||
|
||||
PltUnlockMutex(&enetMutex);
|
||||
|
||||
if (err < 0) {
|
||||
Limelog("Failed to send ENet control packet\n");
|
||||
enet_packet_destroy(enetPacket);
|
||||
|
Loading…
x
Reference in New Issue
Block a user