Fix use of enetMutex during connection failure
This commit is contained in:
parent
109472e4ab
commit
b3b5ee1c2c
1 changed files with 5 additions and 4 deletions
|
|
@ -150,6 +150,7 @@ int initializeControlStream(void) {
|
||||||
stopping = 0;
|
stopping = 0;
|
||||||
PltCreateEvent(&invalidateRefFramesEvent);
|
PltCreateEvent(&invalidateRefFramesEvent);
|
||||||
LbqInitializeLinkedBlockingQueue(&invalidReferenceFrameTuples, 20);
|
LbqInitializeLinkedBlockingQueue(&invalidReferenceFrameTuples, 20);
|
||||||
|
PltCreateMutex(&enetMutex);
|
||||||
|
|
||||||
if (AppVersionQuad[0] == 3) {
|
if (AppVersionQuad[0] == 3) {
|
||||||
packetTypes = (short*)packetTypesGen3;
|
packetTypes = (short*)packetTypesGen3;
|
||||||
|
|
@ -195,6 +196,7 @@ void destroyControlStream(void) {
|
||||||
LC_ASSERT(stopping);
|
LC_ASSERT(stopping);
|
||||||
PltCloseEvent(&invalidateRefFramesEvent);
|
PltCloseEvent(&invalidateRefFramesEvent);
|
||||||
freeFrameInvalidationList(LbqDestroyLinkedBlockingQueue(&invalidReferenceFrameTuples));
|
freeFrameInvalidationList(LbqDestroyLinkedBlockingQueue(&invalidReferenceFrameTuples));
|
||||||
|
PltDeleteMutex(&enetMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getNextFrameInvalidationTuple(PQUEUED_FRAME_INVALIDATION_TUPLE* qfit) {
|
int getNextFrameInvalidationTuple(PQUEUED_FRAME_INVALIDATION_TUPLE* qfit) {
|
||||||
|
|
@ -599,8 +601,6 @@ int stopControlStream(void) {
|
||||||
ctlSock = INVALID_SOCKET;
|
ctlSock = INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
PltDeleteMutex(&enetMutex);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -620,8 +620,6 @@ int sendInputPacketOnControlStream(unsigned char* data, int length) {
|
||||||
int startControlStream(void) {
|
int startControlStream(void) {
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
PltCreateMutex(&enetMutex);
|
|
||||||
|
|
||||||
if (AppVersionQuad[0] >= 5) {
|
if (AppVersionQuad[0] >= 5) {
|
||||||
ENetAddress address;
|
ENetAddress address;
|
||||||
ENetEvent event;
|
ENetEvent event;
|
||||||
|
|
@ -735,8 +733,11 @@ int startControlStream(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer != NULL) {
|
if (peer != NULL) {
|
||||||
|
// We must use the mutex here because we have a live thread now.
|
||||||
|
PltLockMutex(&enetMutex);
|
||||||
enet_peer_disconnect_now(peer, 0);
|
enet_peer_disconnect_now(peer, 0);
|
||||||
peer = NULL;
|
peer = NULL;
|
||||||
|
PltUnlockMutex(&enetMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
PltInterruptThread(&lossStatsThread);
|
PltInterruptThread(&lossStatsThread);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue