Check return value of eventfd_write and remove eventfd_read function. This is
because if eventfd_write is not correctly working (return value is -1),
then monitor pthread will not be exited. In addition, eventfd_read is used to
read dummy value, so psi monitor will be exited correctly regardless of eventfd_read.
It solves problems reported by Coverity with cid = 1704480 and cid = 1704688.
Change-Id: Ife5e17998a0edd46e3d7e6ad028d7a0a7285f19a
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
static void *psi_monitor_thread_destroy_handler(int *efd)
{
- eventfd_t dummy = 0;
- eventfd_read(*efd, &dummy);
-
pthread_exit(NULL);
}
static void destroy_psi_monitor_thread(void)
{
- eventfd_write(g_psi_monitor_thread_destroy_event_fd, 1);
+ int ret;
+
+ if (g_psi_monitor_thread_destroy_event_fd < 0)
+ return;
+
+ ret = eventfd_write(g_psi_monitor_thread_destroy_event_fd, 1);
+ if (ret < 0) {
+ _E("Failed to destroy PSI monitor thread");
+ return;
+ }
+
pthread_join(g_psi_monitor_thread, NULL);
epoll_ctl(g_psi_monitor_epoll_fd, EPOLL_CTL_DEL,