[PATCH] avoid to call red_get_streams_timout twice computing timeout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]