- return ustcomm_send_command(sock, &lum);
-}
-
-/*
- * This thread manage application communication.
- */
-static void *thread_manage_apps(void *data)
-{
- int i, ret, count;
- unsigned int nb_fd = 2;
- int update_poll_flag = 1;
- struct pollfd *pollfd = NULL;
- struct ust_command ust_cmd;
-
- DBG("[thread] Manage application started");
-
- ust_cmd.sock = -1;
-
- while (1) {
- /* See if we have a valid socket to add to pollfd */
- if (ust_cmd.sock != -1) {
- nb_fd++;
- update_poll_flag = 1;
- }
-
- /* The pollfd struct must be updated */
- if (update_poll_flag) {
- ret = update_apps_cmd_pollfd(nb_fd, &pollfd);
- if (ret < 0) {
- /* malloc failed so we quit */
- goto error;
- }
- if (ust_cmd.sock != -1) {
- /* Update pollfd with the new UST socket */
- DBG("Adding sock %d to apps cmd pollfd", ust_cmd.sock);
- pollfd[nb_fd - 1].fd = ust_cmd.sock;
- pollfd[nb_fd - 1].events = POLLHUP | POLLNVAL;
- ust_cmd.sock = -1;
- }
- }
-
- DBG("Apps thread polling on %d fds", nb_fd);
-
- /* Inifinite blocking call, waiting for transmission */
- ret = poll(pollfd, nb_fd, -1);
- if (ret < 0) {
- perror("poll apps thread");
- goto error;
- }
-
- /* Thread quit pipe has been closed. Killing thread. */
- if (pollfd[0].revents == POLLNVAL) {
- goto error;
- } else if (pollfd[1].revents == POLLERR) {
- ERR("Apps command pipe poll error");
- goto error;
- } else if (pollfd[1].revents == POLLIN) {
- /* Empty pipe */
- ret = read(apps_cmd_pipe[0], &ust_cmd, sizeof(ust_cmd));
- if (ret < 0 || ret < sizeof(ust_cmd)) {
- perror("read apps cmd pipe");
- goto error;
- }
-
- /* Register applicaton to the session daemon */
- ret = register_traceable_app(&ust_cmd.reg_msg, ust_cmd.sock);
- if (ret < 0) {
- /* Only critical ENOMEM error can be returned here */
- goto error;
- }