Skip to content

Commit 672aa84

Browse files
amgrossMichalPrincNXP
authored andcommitted
Free the arbitrated client token from client manager
1 parent f84916c commit 672aa84

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

erpc_c/infra/erpc_arbitrated_client_manager.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ void ArbitratedClientManager::performClientRequest(RequestContext &request)
8787
request.getCodec()->updateStatus(err);
8888
}
8989

90+
if (token != 0)
91+
{
92+
// Also if status bad, need to free the token.
93+
m_arbitrator->removePendingClient(token);
94+
}
95+
9096
#if ERPC_MESSAGE_LOGGING
9197
if (request.getCodec()->isStatusOk() == true)
9298
{

erpc_c/infra/erpc_transport_arbitrator.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ erpc_status_t TransportArbitrator::clientReceive(client_token_t token)
193193
// Wait on the semaphore until we're signaled.
194194
info->m_sem.get(Semaphore::kWaitForever);
195195

196-
removePendingClient(info);
197-
198196
return kErpcStatus_Success;
199197
}
200198

@@ -227,11 +225,16 @@ TransportArbitrator::PendingClientInfo *TransportArbitrator::addPendingClient(vo
227225
return info;
228226
}
229227

230-
void TransportArbitrator::removePendingClient(PendingClientInfo *info)
228+
void TransportArbitrator::removePendingClient(client_token_t token)
231229
{
230+
// Convert token to pointer to info struct.
231+
PendingClientInfo *info = reinterpret_cast<PendingClientInfo *>(token);
232232
Mutex::Guard lock(m_clientListMutex);
233233
PendingClientInfo *node;
234234

235+
erpc_assert((token != 0) && ("invalid client token" != NULL));
236+
erpc_assert((info->m_sem.getCount() == 0) && ("Semaphore should be clean" != NULL));
237+
235238
// Clear fields.
236239
info->m_request = NULL;
237240
info->m_isValid = false;

erpc_c/infra/erpc_transport_arbitrator.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ class TransportArbitrator : public Transport
157157
*/
158158
erpc_status_t clientReceive(client_token_t token);
159159

160+
/*!
161+
* @brief This function free client token.
162+
*
163+
* @param[in] token the client token to remove.
164+
*/
165+
void removePendingClient(client_token_t token);
166+
160167
/*!
161168
* @brief Request info for a client trying to receive a response.
162169
*/
@@ -200,13 +207,6 @@ class TransportArbitrator : public Transport
200207
*/
201208
PendingClientInfo *addPendingClient(void);
202209

203-
/*!
204-
* @brief This function removes pending client.
205-
*
206-
* @param[in] info Pending client info to remove.
207-
*/
208-
void removePendingClient(PendingClientInfo *info);
209-
210210
/*!
211211
* @brief This function removes pending client list.
212212
*

0 commit comments

Comments
 (0)