Commit 581c5fd5 authored by Kai Vehmanen's avatar Kai Vehmanen

Fixed the following issue: su_source_step should not alter the iteration...

Fixed the following issue: su_source_step should not alter the iteration sequence depending on e.g. the result of g_main_context_prepare(); it produces warnings in some real life mainloop contexts (such as the one found in telepathy-sofiasip) and is potentially dangerous. Patch by Mikhail Zabaluev.

darcs-hash:20061221164120-7659e-ef15061e9b90dbeee98bb0ebd9401b044c46c201.gz
parent 845d1787
......@@ -55,6 +55,7 @@ Contributors to this release
- **template**: First Surname (patch to nua/soa/msg)
- Petteri Puolakka (patch to stun)
- Mikhail Zabluev (patch to su-glib mainloop integration)
See the AUTHORS file in the distribution package.
......@@ -94,3 +95,8 @@ Bugs fixed in this release
Roman Filonenko.
- Bug in zero-padding STUN messages with a message integrity
attribute. Patch by Petteri Puolakka.
- Fixed a severe problem with timer accuracy, when sofia-sip timers
where used under glib's mainloop.
- Improved glib mainloop integration to avoid warnings about already
active mainloop context, and potentially other issue. Patch by
Mikhail Zabaluev. Closes sf.net item #1606786.
......@@ -319,34 +319,28 @@ gboolean su_source_prepare(GSource *gs, gint *return_tout)
enter;
if (self->sup_head)
if (self->sup_head) {
*return_tout = 0;
return TRUE;
*return_tout = -1;
}
if (self->sup_timers) {
su_time_t now;
GTimeVal gtimeval;
su_duration_t tout;
tout = SU_DURATION_MAX;
g_source_get_current_time(gs, &gtimeval);
now.tv_sec = gtimeval.tv_sec + 2208988800UL;
now.tv_usec = gtimeval.tv_usec;
tout = su_timer_next_expires(self->sup_timers, now);
if (tout == 0)
return TRUE;
if ((gint)tout < 0 || tout > (su_duration_t)G_MAXINT)
tout = -1;
*return_tout = (tout < 0 || tout > (su_duration_t)G_MAXINT)?
-1 : (gint)tout;
*return_tout = (gint)tout;
return (tout == 0);
}
return FALSE;
}
......@@ -995,30 +989,29 @@ su_duration_t su_source_step(su_port_t *self, su_duration_t tout)
gmc = g_source_get_context(self->sup_source);
if (gmc && g_main_context_acquire(gmc)) {
gint n = 0;
GPollFD *fds = NULL;
gint priority = G_MAXINT;
if (g_main_context_prepare(gmc, &priority)) {
g_main_context_dispatch(gmc);
} else {
gint timeout = tout > G_MAXINT ? G_MAXINT : tout;
gint i, n = 0;
GPollFD *fds = NULL;
priority = G_MAXINT;
if (g_main_context_prepare(gmc, &priority)) {
gint src_tout = -1;
n = g_main_context_query(gmc, priority, &timeout, fds, n);
n = g_main_context_query(gmc, priority, &src_tout, NULL, 0);
if (n > 0) {
fds = g_alloca(n * (sizeof *fds));
n = g_main_context_query(gmc, priority, &timeout, fds, n);
fds = g_alloca(n * (sizeof *fds));
n = g_main_context_query(gmc, priority, &src_tout, fds, n);
}
if (tout < timeout)
timeout = tout;
if (src_tout >= 0 && tout > (su_duration_t)src_tout)
tout = src_tout;
i = su_wait((su_wait_t *)fds, n, timeout);
if (g_main_context_check(gmc, priority, fds, n))
g_main_context_dispatch(gmc);
su_wait((su_wait_t *)fds, n, tout);
}
g_main_context_check(gmc, priority, fds, n);
g_main_context_dispatch(gmc);
g_main_context_release(gmc);
}
......
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