-static void msg_move_exec(struct uevent_msg *msg)
-{
- list_move_tail(&msg->node, &exec_list);
- run_exec_q = 1;
- expected_seqnum = msg->seqnum+1;
- dbg("moved seq %llu to exec, next expected is %llu",
- msg->seqnum, expected_seqnum);
-}
-
-/* msg queue management routine handles the timeouts and dispatches the events */
-static void msg_queue_manager(void)
-{
- struct uevent_msg *loop_msg;
- struct uevent_msg *tmp_msg;
- struct sysinfo info;
- long msg_age = 0;
- int timeout = event_timeout;
-
- dbg("msg queue manager, next expected is %llu", expected_seqnum);
-recheck:
- sysinfo(&info);
- list_for_each_entry_safe(loop_msg, tmp_msg, &msg_list, node) {
- /* move event with expected sequence to the exec list */
- if (loop_msg->seqnum == expected_seqnum) {
- msg_move_exec(loop_msg);
- continue;
- }
-
- /* limit timeout during initialization phase */
- if (init_phase) {
- if (timeout > UDEVD_INIT_EVENT_TIMEOUT)
- timeout = UDEVD_INIT_EVENT_TIMEOUT;
- dbg("initialization phase, timeout %i seconds", timeout);
- }
-
- /* move event with expired timeout to the exec list */
- msg_age = info.uptime - loop_msg->queue_time;
- dbg("seq %llu is %li seconds old", loop_msg->seqnum, msg_age);
- if (msg_age >= timeout) {
- msg_move_exec(loop_msg);
- goto recheck;
- } else
- break;
- }
-
- msg_dump_queue();
-
- /* set timeout for remaining queued events */
- if (!list_empty(&msg_list)) {
- struct itimerval itv = {{0, 0}, {timeout - msg_age, 0}};
- info("next event expires in %li seconds", timeout - msg_age);
- setitimer(ITIMER_REAL, &itv, NULL);
- }
-}
-