avoid to call red_get_streams_timout twice computing timeout

Due to how the MIN macro is defined the function was called twice
unless the compiler could demonstrate that was returning the same
value (which actually is impossible as function as clock_gettime
are not deterministic).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Frediano Ziglio 2015-08-21 11:15:55 +01:00
parent 83f507db4b
commit 39be1c448c

View File

@ -12189,11 +12189,12 @@ SPICE_GNUC_NORETURN void *red_worker_main(void *arg)
for (;;) {
int i, num_events;
unsigned int timers_queue_timeout;
unsigned int timeout;
timers_queue_timeout = spice_timer_queue_get_timeout_ms();
worker->event_timeout = MIN(red_get_streams_timout(worker), worker->event_timeout);
worker->event_timeout = MIN(timers_queue_timeout, worker->event_timeout);
timeout = spice_timer_queue_get_timeout_ms();
worker->event_timeout = MIN(timeout, worker->event_timeout);
timeout = red_get_streams_timout(worker);
worker->event_timeout = MIN(timeout, worker->event_timeout);
num_events = poll(worker->poll_fds, MAX_EVENT_SOURCES, worker->event_timeout);
red_handle_streams_timout(worker);
spice_timer_queue_cb();