Skip to content

Commit ca649ef

Browse files
Yogesh Pandeadbridge
authored andcommitted
Delaying message id random initialization to later stage.
Random initialization sequence is causing start up issues in multiple platform when done at construction phase. The right thing is to delay the random initialization to later stage when the message id is actually required. This provides system to do all necessary allocation upfront without causing any random race condition at startup phase.
1 parent f60e9a8 commit ca649ef

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

features/frameworks/mbed-coap/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## [v5.1.1](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.1)
4+
5+
- Delay the random initialization of message id to a later phase and not during init() so there is enough time
6+
for system to complete the rest of the initialization.
7+
8+
-[Full Changelog](https://github.com/ARMmbed/mbed-coap/compare/v5.1.0...v5.1.1)
9+
10+
311
## [v5.1.0](https://github.com/ARMmbed/mbed-coap/releases/tag/v5.1.0)
412

513
- Introduce SN_COAP_REDUCE_BLOCKWISE_HEAP_FOOTPRINT configuration flag.

features/frameworks/mbed-coap/source/sn_coap_protocol.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,7 @@ struct coap_s *sn_coap_protocol_init(void *(*used_malloc_func_ptr)(uint16_t), vo
179179

180180
#endif /* ENABLE_RESENDINGS */
181181

182-
/* Randomize global message ID */
183-
randLIB_seed_random();
184-
message_id = randLIB_get_16bit();
185-
if (message_id == 0) {
186-
message_id = 1;
187-
}
188-
182+
message_id = 0;
189183
return handle;
190184
}
191185

@@ -2523,6 +2517,11 @@ static bool compare_address_and_port(const sn_nsdl_addr_s* left, const sn_nsdl_a
25232517

25242518
static uint16_t get_new_message_id(void)
25252519
{
2520+
if (message_id == 0) {
2521+
/* Randomize global message ID */
2522+
randLIB_seed_random();
2523+
message_id = randLIB_get_16bit();
2524+
}
25262525
message_id++;
25272526
if (message_id == 0) {
25282527
message_id = 1;

0 commit comments

Comments
 (0)