enum kconsumerd_fd_state state)
{
struct kconsumerd_fd *iter;
+
+ pthread_mutex_lock(&kconsumerd_lock_fds);
cds_list_for_each_entry(iter, &kconsumerd_fd_list.head, list) {
if (iter->sessiond_fd == sessiond_fd) {
iter->state = state;
break;
}
}
+ pthread_mutex_unlock(&kconsumerd_lock_fds);
}
/*
int i = 0;
DBG("Updating poll fd array");
- pthread_mutex_lock(&kconsumerd_lock_fds);
cds_list_for_each_entry(iter, &kconsumerd_fd_list.head, list) {
DBG("Inside for each");
(*pollfd)[i].events = POLLIN;
kconsumerd_update_fd_array = 0;
- pthread_mutex_unlock(&kconsumerd_lock_fds);
return i;
}
free(local_kconsumerd_fd);
local_kconsumerd_fd = NULL;
}
+
+ /* Lock mutex for fds count */
+ pthread_mutex_lock(&kconsumerd_lock_fds);
/* allocate for all fds + 1 for the kconsumerd_poll_pipe */
pollfd = malloc((kconsumerd_fds_count + 1) * sizeof(struct pollfd));
if (pollfd == NULL) {
perror("pollfd malloc");
goto end;
}
+
/* allocate for all fds + 1 for the kconsumerd_poll_pipe */
local_kconsumerd_fd = malloc((kconsumerd_fds_count + 1) *
sizeof(struct kconsumerd_fd));
kconsumerd_send_error(KCONSUMERD_POLL_ERROR);
goto end;
}
+ /* Unlock mutex for fds count */
+ pthread_mutex_unlock(&kconsumerd_lock_fds);
+
nb_fd = ret;
}
}
}
end:
+ pthread_mutex_unlock(&kconsumerd_lock_fds);
DBG("polling thread exiting");
if (pollfd != NULL) {
free(pollfd);