Skip to content

Commit 34b37d1

Browse files
committed
In case of cbor_encoder_close_container failure, reduce the number of properties to be appended by one and retry send
1 parent 102ce67 commit 34b37d1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/cbor/CBOREncoder.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@ CborError CBOREncoder::encode(PropertyContainer & property_container, uint8_t *
8080
return error;
8181
}
8282

83+
error = cbor_encoder_close_container(&encoder, &arrayEncoder);
84+
if (CborNoError != error)
85+
{
86+
/* Trim the number of properties to be included in the next message to avoid error closing container */
87+
encoded_properties_message_limit = num_encoded_properties - 1;
88+
return error;
89+
}
90+
8391
/* Restore property message limit to NO_LIMIT */
8492
encoded_properties_message_limit = -1;
8593

86-
CHECK_CBOR(cbor_encoder_close_container(&encoder, &arrayEncoder));
87-
8894
/* The append process has been successful, so we don't need to terty to send this properties set. Cleanup _has_been_appended_but_not_sended flag */
8995
iter = property_container.begin();
9096
std::advance(iter, current_property_index);

0 commit comments

Comments
 (0)