Fix sequence number generation 34/301434/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 16 Nov 2023 00:49:21 +0000 (09:49 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 16 Nov 2023 00:49:21 +0000 (09:49 +0900)
To avoid generating duplicate numbers, this patch uses UUID.

Change-Id: I3d8051bad7350028e1dc5c8364902f8fb020705d
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/launch_with_result.c

index 5e03462..7454774 100644 (file)
@@ -58,22 +58,15 @@ typedef struct _aul_reply_info_t {
 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)