Make atomic variable to avoid race condition 96/285196/2
authorSuyeon Hwang <stom.hwang@samsung.com>
Wed, 7 Dec 2022 08:25:38 +0000 (17:25 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Thu, 8 Dec 2022 04:53:38 +0000 (13:53 +0900)
commitf37ca19b667df32e156a3a12c6a3509ec9dc775c
tree8a4169631d7ae6ed8014c5ef012dc029336cc813
parent493ec7a4362b29681344c69c156680e95802ab2b
Make atomic variable to avoid race condition

- Issue:
Sometimes, the engine library can access invalid memory location when
the engine app tries to access callback.

- Solution:
Some engine API can access callback function in sttd_engine_agent.
However, these callbacks are not protected by multi threading. Thus,
thee engine app can access invalid pointer if engine library terminates
the engine internally and the app tries too access callback in sub
thread.
Therefore, this patch changes the global variable to atomic variable for
protecting those callback pointers and flags. And also this patch adds
null check for those pointers. Through this patch, engine library can
access those global variables in a safe way even if it is on multi thread
environment.

Change-Id: Ie501985b0ad5b1fdaf0937649cbacc37ab1e4b42
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
server/sttd_engine_agent.c
server/sttd_server.c