@@ -290,7 +290,7 @@ str* b2b_htable_insert(b2b_table table, b2b_dlg_t* dlg, int hash_index,
290
290
return b2b_key ;
291
291
}
292
292
293
- /* key format : B2B.hash_index.local_index.timestamp *
293
+ /* key format : B2B.hash_index.local_index.timestamp.random *
294
294
*/
295
295
296
296
int b2b_parse_key (str * key , unsigned int * hash_index , unsigned int * local_index ,
@@ -341,8 +341,14 @@ int b2b_parse_key(str* key, unsigned int* hash_index, unsigned int* local_index,
341
341
}
342
342
343
343
if (timestamp ) {
344
- s .s = p + 1 ;
345
- s .len = key -> len - (s .s - key -> s );
344
+ s .s = p + 1 ;
345
+ // There might be a random number after timestamp, we want to ignore it.
346
+ p = strchr (s .s , '.' );
347
+ if (p != NULL ) {
348
+ s .len = p - s .s ;
349
+ } else {
350
+ s .len = key -> len - (s .s - key -> s );
351
+ }
346
352
if (str2int64 (& s , timestamp ) < 0 )
347
353
{
348
354
LM_DBG ("Could not extract timestamp [%.*s] from key [%.*s]\n" , s .len , s .s , key -> len , key -> s );
@@ -366,8 +372,8 @@ str* b2b_generate_key(unsigned int hash_index, unsigned int local_index,
366
372
str * b2b_key ;
367
373
int len ;
368
374
369
- len = sprintf (buf , "%s.%d.%d.%ld" , b2b_key_prefix .s , hash_index , local_index ,
370
- timestamp ? timestamp : startup_time + get_ticks ());
375
+ len = sprintf (buf , "%s.%d.%d.%ld.%d " , b2b_key_prefix .s , hash_index , local_index ,
376
+ timestamp ? timestamp : startup_time + get_ticks (), rand ());
371
377
372
378
b2b_key = (str * )pkg_malloc (sizeof (str )+ len );
373
379
if (b2b_key == NULL )
0 commit comments