Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free the arbitrated client token from client manager #444

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions erpc_c/infra/erpc_arbitrated_client_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ void ArbitratedClientManager::performClientRequest(RequestContext &request)
request.getCodec()->updateStatus(err);
}

if (token != 0)
{
// Also if status bad, need to free the token.
m_arbitrator->removePendingClient(token);
}

#if ERPC_MESSAGE_LOGGING
if (request.getCodec()->isStatusOk() == true)
{
Expand Down
9 changes: 6 additions & 3 deletions erpc_c/infra/erpc_transport_arbitrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ erpc_status_t TransportArbitrator::clientReceive(client_token_t token)
// Wait on the semaphore until we're signaled.
info->m_sem.get(Semaphore::kWaitForever);

removePendingClient(info);

return kErpcStatus_Success;
}

Expand Down Expand Up @@ -227,11 +225,16 @@ TransportArbitrator::PendingClientInfo *TransportArbitrator::addPendingClient(vo
return info;
}

void TransportArbitrator::removePendingClient(PendingClientInfo *info)
void TransportArbitrator::removePendingClient(client_token_t token)
{
// Convert token to pointer to info struct.
PendingClientInfo *info = reinterpret_cast<PendingClientInfo *>(token);
Mutex::Guard lock(m_clientListMutex);
PendingClientInfo *node;

erpc_assert((token != 0) && ("invalid client token" != NULL));
erpc_assert((info->m_sem.getCount() == 0) && ("Semaphore should be clean" != NULL));

// Clear fields.
info->m_request = NULL;
info->m_isValid = false;
Expand Down
14 changes: 7 additions & 7 deletions erpc_c/infra/erpc_transport_arbitrator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ class TransportArbitrator : public Transport
*/
erpc_status_t clientReceive(client_token_t token);

/*!
* @brief This function free client token.
*
* @param[in] token the client token to remove.
*/
void removePendingClient(client_token_t token);

/*!
* @brief Request info for a client trying to receive a response.
*/
Expand Down Expand Up @@ -200,13 +207,6 @@ class TransportArbitrator : public Transport
*/
PendingClientInfo *addPendingClient(void);

/*!
* @brief This function removes pending client.
*
* @param[in] info Pending client info to remove.
*/
void removePendingClient(PendingClientInfo *info);

/*!
* @brief This function removes pending client list.
*
Expand Down