To avoid generating duplicate numbers, this patch uses UUID.
Change-Id: I3d8051bad7350028e1dc5c8364902f8fb020705d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
static pthread_mutex_t __aul_mutex = PTHREAD_MUTEX_INITIALIZER;
static GList *__reply_info_list;
-static int __rand(int n)
-{
- unsigned int seed = time(NULL) + n;
-
- return rand_r(&seed);
-}
-
static char *__gen_seq_num(void)
{
- static int num;
- char buf[MAX_LOCAL_BUFSZ];
+ char uuid[37];
+ uuid_t u;
- g_atomic_int_inc(&num);
- snprintf(buf, sizeof(buf), "%d@%d", __rand(num), num);
+ uuid_generate(u);
+ uuid_unparse(u, uuid);
- return strdup(buf);
+ return strdup(uuid);
}
static void __destroy_aul_error_info(aul_error_info_t *info)