[multicat-devel] [Git][videolan/multicat][master] 2 commits: Fix multilive poll timeout

Christophe Massiot gitlab at videolan.org
Fri Jun 12 00:42:35 CEST 2020



Christophe Massiot pushed to branch master at VideoLAN / multicat


Commits:
06e18a17 by Arnaud de Turckheim at 2020-06-11T18:50:06+02:00
Fix multilive poll timeout

The poll timeout wasn't updated when triggered too soon, it's fixed.
And 1ms is added to the timeout to compensate precision loss.

- - - - -
0877620f by Christophe Massiot at 2020-06-12T00:40:48+02:00
Merge branch 'quarium-multilive'

- - - - -


1 changed file:

- multilive.c


Changes:

=====================================
multilive.c
=====================================
@@ -242,7 +242,7 @@ int main( int i_argc, char **pp_argv )
     for ( ; ; )
     {
         uint64_t i_current_date = wall_Date();
-        int i_timeout;
+
         if ( i_next_announce == UINT64_MAX )
         {
             if ( i_master_expiration <= i_current_date )
@@ -250,9 +250,6 @@ int main( int i_argc, char **pp_argv )
                 Up();
                 i_next_announce = i_current_date;
             }
-            else
-                i_timeout = (i_master_expiration - i_current_date) * 1000 /
-                            CLOCK_FREQ;
         }
 
         if ( i_next_announce <= i_current_date )
@@ -275,12 +272,17 @@ int main( int i_argc, char **pp_argv )
 
             i_current_date = wall_Date();
             i_next_announce += i_period;
-            i_timeout = (i_next_announce - i_current_date) * 1000 /
-                        CLOCK_FREQ;
-            if ( i_timeout < 0 )
-                i_timeout = 0;
         }
 
+        /* next action date */
+        uint64_t i_next_run = i_next_announce != UINT64_MAX ?
+            i_next_announce : i_master_expiration;
+
+        /* add 1 ms for rounding */
+        int i_timeout = ((i_next_run - i_current_date) * 1000 / CLOCK_FREQ) + 1;
+        if ( i_timeout < 0 )
+            i_timeout = 0;
+
         if ( poll( pfd, 1, i_timeout ) < 0 )
         {
             int saved_errno = errno;



View it on GitLab: https://code.videolan.org/videolan/multicat/-/compare/d03d536e6b6180b0a53a9631af750fc8b4707f3e...0877620f607d30111c5104ae213feecf887e2caf

-- 
View it on GitLab: https://code.videolan.org/videolan/multicat/-/compare/d03d536e6b6180b0a53a9631af750fc8b4707f3e...0877620f607d30111c5104ae213feecf887e2caf
You're receiving this email because of your account on code.videolan.org.




More information about the multicat-devel mailing list