Skip to content

Commit cc68692

Browse files
committed
fix: notify client of timeout and cleanup
When transport times out or has a reception failure, it should inform readers that it's message buffer is invalid. Set the status of the codec to the error, so a correct error handler is triggered in the client.
1 parent 9749163 commit cc68692

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

erpc_c/infra/erpc_arbitrated_client_manager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ void ArbitratedClientManager::performClientRequest(RequestContext &request)
8383
if (request.getCodec()->isStatusOk() == true)
8484
{
8585
// Complete the receive through the arbitrator.
86-
err = m_arbitrator->clientReceive(token);
87-
request.getCodec()->updateStatus(err);
86+
m_arbitrator->clientReceive(token);
8887
}
8988

9089
if (token != 0)

erpc_c/infra/erpc_transport_arbitrator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ erpc_status_t TransportArbitrator::receive(MessageBuffer *message)
6363
if (err != kErpcStatus_Success)
6464
{
6565
// if we timeout, we must unblock all pending client(s)
66-
if (err == kErpcStatus_Timeout)
66+
if (err == kErpcStatus_Timeout || err == kErpcStatus_ReceiveFailed)
6767
{
6868
client = m_clientList;
6969
for (; client; client = client->m_next)
7070
{
7171
if (client->m_isValid)
7272
{
73+
client->m_request->getCodec()->updateStatus(err);
7374
client->m_sem.put();
7475
}
7576
}
@@ -107,6 +108,7 @@ erpc_status_t TransportArbitrator::receive(MessageBuffer *message)
107108
{
108109
// Swap the received message buffer with the client's message buffer.
109110
client->m_request->getCodec()->getBufferRef().swap(message);
111+
client->m_request->getCodec()->updateStatus(kErpcStatus_Success);
110112

111113
// Wake up the client receive thread.
112114
client->m_sem.put();
@@ -183,7 +185,7 @@ TransportArbitrator::client_token_t TransportArbitrator::prepareClientReceive(Re
183185
return reinterpret_cast<client_token_t>(info);
184186
}
185187

186-
erpc_status_t TransportArbitrator::clientReceive(client_token_t token)
188+
void TransportArbitrator::clientReceive(client_token_t token)
187189
{
188190
erpc_assert((token != 0) && ("invalid client token" != NULL));
189191

@@ -192,8 +194,6 @@ erpc_status_t TransportArbitrator::clientReceive(client_token_t token)
192194

193195
// Wait on the semaphore until we're signaled.
194196
info->m_sem.get(Semaphore::kWaitForever);
195-
196-
return kErpcStatus_Success;
197197
}
198198

199199
TransportArbitrator::PendingClientInfo *TransportArbitrator::createPendingClient(void){ ERPC_CREATE_NEW_OBJECT(

erpc_c/infra/erpc_transport_arbitrator.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,8 @@ class TransportArbitrator : public Transport
152152
* associated with @a token. The client must have called prepareClientReceive() previously.
153153
*
154154
* @param[in] token The token previously returned by prepareClientReceive().
155-
*
156-
* @return erpc_status_t Return erpc status of client receive function.
157155
*/
158-
erpc_status_t clientReceive(client_token_t token);
156+
void clientReceive(client_token_t token);
159157

160158
/*!
161159
* @brief This function free client token.

0 commit comments

Comments
 (0)