From 2ae8ea3844a1a606133f5778c51285b4bf88a74c Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Thu, 21 May 2020 22:53:17 +0200 Subject: [PATCH] - MMS client: fixed potential problem in handling of next invoke ID --- src/mms/inc_private/mms_client_internal.h | 4 ++-- src/mms/iso_mms/client/mms_client_connection.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/mms/inc_private/mms_client_internal.h b/src/mms/inc_private/mms_client_internal.h index 337fe833..6bc4455c 100644 --- a/src/mms/inc_private/mms_client_internal.h +++ b/src/mms/inc_private/mms_client_internal.h @@ -90,8 +90,8 @@ struct sMmsOutstandingCall /* private instance variables */ struct sMmsConnection { - Semaphore lastInvokeIdLock; - uint32_t lastInvokeId; + Semaphore nextInvokeIdLock; + uint32_t nextInvokeId; Semaphore outstandingCallsLock; MmsOutstandingCall outstandingCalls; diff --git a/src/mms/iso_mms/client/mms_client_connection.c b/src/mms/iso_mms/client/mms_client_connection.c index 8dff7dfc..63ebfd38 100644 --- a/src/mms/iso_mms/client/mms_client_connection.c +++ b/src/mms/iso_mms/client/mms_client_connection.c @@ -240,10 +240,10 @@ getNextInvokeId(MmsConnection self) { uint32_t nextInvokeId; - Semaphore_wait(self->lastInvokeIdLock); - self->lastInvokeId++; - nextInvokeId = self->lastInvokeId; - Semaphore_post(self->lastInvokeIdLock); + Semaphore_wait(self->nextInvokeIdLock); + self->nextInvokeId++; + nextInvokeId = self->nextInvokeId; + Semaphore_post(self->nextInvokeIdLock); return nextInvokeId; } @@ -1353,8 +1353,6 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload) hasInvokeId = true; - self->lastInvokeId = invokeId; - break; default: @@ -1429,7 +1427,7 @@ MmsConnection_createInternal(TLSConfiguration tlsConfig, bool createThread) self->requestTimeout = CONFIG_MMS_CONNECTION_DEFAULT_TIMEOUT; - self->lastInvokeIdLock = Semaphore_create(1); + self->nextInvokeIdLock = Semaphore_create(1); self->outstandingCallsLock = Semaphore_create(1); self->associationStateLock = Semaphore_create(1); @@ -1512,7 +1510,7 @@ MmsConnection_destroy(MmsConnection self) if (self->isoParameters != NULL) IsoConnectionParameters_destroy(self->isoParameters); - Semaphore_destroy(self->lastInvokeIdLock); + Semaphore_destroy(self->nextInvokeIdLock); Semaphore_destroy(self->outstandingCallsLock);