Commit ba4ca9ad authored by Youness Alaoui's avatar Youness Alaoui

Cast the current time for pseudotcp timeout calculation into guint32

The pseudo_tcp_socket_get_next_clock returns the next clock in terms
of g_get_monotonic_clock / 1000, however, it gets cropped to guint32.
When we try to find the interval, by substracting the current time as
a guint64, it will return a negative value, which prevents an integer
overflow by setting the timeout to 0. This causes the notify_clock
timeout to be called all the time by the mainloop, taking 100% of CPU.
parent 73081e56
......@@ -1719,11 +1719,11 @@ adjust_tcp_clock (NiceAgent *agent, Stream *stream, Component *component)
#endif
}
if (!component->tcp_clock) {
long interval = timeout - (g_get_monotonic_time () / 1000);
long interval = timeout - (guint32) (g_get_monotonic_time () / 1000);
/* Prevent integer overflows */
if (interval < 0 || interval > G_MAXINT)
interval = 0;
interval = G_MAXINT;
component->tcp_clock = agent_timeout_add_with_context (agent, interval,
notify_pseudo_tcp_socket_clock, component);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment