[Spice-devel] [PATCH] avoid to call red_get_streams_timout twice computing timeout
Frediano Ziglio
fziglio at redhat.com
Fri Aug 21 03:16:23 PDT 2015
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 at redhat.com>
---
server/red_worker.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index ccba8a3..7460614 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -12188,11 +12188,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();
--
2.4.3
More information about the Spice-devel
mailing list