util: resource: Assign an unique resource id when a new resouce is created
authorSung-hun Kim <sfoon.kim@samsung.com>
Mon, 25 Jul 2022 05:45:59 +0000 (14:45 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 27 Jul 2022 08:24:26 +0000 (17:24 +0900)
commit07de2009a3690831b7522ca14c74ea3ea2368750
treefa7e8652d8ad0ed0b91fd9458dd8b65392b83333
parent6315dba1500b5c7049c78318314a7df34b70cd17
util: resource: Assign an unique resource id when a new resouce is created

When PASS-daemon restarted unexpectedly, a pass client which is
survived in spite of PASS-daemon's restart can access resources
by using its own resource id (which is valid for previous PASS
daemon).

To prevent this situation, PASS should assign a unique resource
id for each created resource even if PASS daemon is restarted.
To this end, PASS initializes a global resource id (g_resource_id)
by using the value of gettimeofday(). So, each resource will be
assigned time-reflected resource id, and uniqueness is ensured
unless the number of created resources crosses the time consumed
before restarted.

Change-Id: I0e30addf01a0ee21b1f18aca56010d39d2c90c99
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
include/util/resource.h
src/monitor/request-server.c
src/util/resource.c