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

fix: errors in transaction handling #631

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions coap/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ static int prv_checkFinished(lwm2m_transaction_t * transacP,
uint8_t* token;
coap_packet_t * transactionMessage = (coap_packet_t *) transacP->message;

if (transactionMessage->mid != receivedMessage->mid) {
return false;
}

if (COAP_DELETE < transactionMessage->code)
{
// response
Expand Down
14 changes: 9 additions & 5 deletions core/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,17 @@ static lwm2m_transaction_t * prv_get_transaction(lwm2m_context_t * contextP, voi
lwm2m_transaction_t * transaction;

transaction = contextP->transactionList;
while (transaction != NULL
&& lwm2m_session_is_equal(sessionH, transaction->peerH, contextP->userData) == false
&& transaction->mID != mid)
{
while (transaction != NULL && (lwm2m_session_is_equal(sessionH, transaction->peerH, contextP->userData) == false ||
transaction->mID != mid)) {
transaction = transaction->next;
}
return transaction;

if (transaction != NULL &&
(lwm2m_session_is_equal(sessionH, transaction->peerH, contextP->userData) == true && transaction->mID == mid)) {
return transaction;
}

return NULL;
}

// limited clone of transaction to be used by block transfers
Expand Down