Release the main_loop lock around calls to prepare() and check() so that

Mon Feb  1 19:04:28 1999  Owen Taylor  <otaylor@redhat.com>

	* gmain.c (g_main_iterate): Release the main_loop
	 lock around calls to prepare() and check() so
	 that we are not holding the main loop lock
	 over user code.
This commit is contained in:
Owen Taylor 1999-02-02 01:04:41 +00:00 committed by Owen Taylor
parent 87d3468f20
commit f26256fe18
10 changed files with 134 additions and 42 deletions

View File

@ -1,6 +1,13 @@
Mon Feb 1 19:04:28 1999 Owen Taylor <otaylor@redhat.com>
* gmain.c (g_main_iterate): Release the main_loop
lock around calls to prepare() and check() so
that we are not holding the main loop lock
over user code.
1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Moved the check for MT save function variants * configure.in: Moved the check for MT safe function variants
after the determination of the MT cflags and use them there. after the determination of the MT cflags and use them there.
1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>

View File

@ -1,6 +1,13 @@
Mon Feb 1 19:04:28 1999 Owen Taylor <otaylor@redhat.com>
* gmain.c (g_main_iterate): Release the main_loop
lock around calls to prepare() and check() so
that we are not holding the main loop lock
over user code.
1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Moved the check for MT save function variants * configure.in: Moved the check for MT safe function variants
after the determination of the MT cflags and use them there. after the determination of the MT cflags and use them there.
1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>

View File

@ -1,6 +1,13 @@
Mon Feb 1 19:04:28 1999 Owen Taylor <otaylor@redhat.com>
* gmain.c (g_main_iterate): Release the main_loop
lock around calls to prepare() and check() so
that we are not holding the main loop lock
over user code.
1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Moved the check for MT save function variants * configure.in: Moved the check for MT safe function variants
after the determination of the MT cflags and use them there. after the determination of the MT cflags and use them there.
1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>

View File

@ -1,6 +1,13 @@
Mon Feb 1 19:04:28 1999 Owen Taylor <otaylor@redhat.com>
* gmain.c (g_main_iterate): Release the main_loop
lock around calls to prepare() and check() so
that we are not holding the main loop lock
over user code.
1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Moved the check for MT save function variants * configure.in: Moved the check for MT safe function variants
after the determination of the MT cflags and use them there. after the determination of the MT cflags and use them there.
1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>

View File

@ -1,6 +1,13 @@
Mon Feb 1 19:04:28 1999 Owen Taylor <otaylor@redhat.com>
* gmain.c (g_main_iterate): Release the main_loop
lock around calls to prepare() and check() so
that we are not holding the main loop lock
over user code.
1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Moved the check for MT save function variants * configure.in: Moved the check for MT safe function variants
after the determination of the MT cflags and use them there. after the determination of the MT cflags and use them there.
1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>

View File

@ -1,6 +1,13 @@
Mon Feb 1 19:04:28 1999 Owen Taylor <otaylor@redhat.com>
* gmain.c (g_main_iterate): Release the main_loop
lock around calls to prepare() and check() so
that we are not holding the main loop lock
over user code.
1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Moved the check for MT save function variants * configure.in: Moved the check for MT safe function variants
after the determination of the MT cflags and use them there. after the determination of the MT cflags and use them there.
1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>

View File

@ -1,6 +1,13 @@
Mon Feb 1 19:04:28 1999 Owen Taylor <otaylor@redhat.com>
* gmain.c (g_main_iterate): Release the main_loop
lock around calls to prepare() and check() so
that we are not holding the main loop lock
over user code.
1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Moved the check for MT save function variants * configure.in: Moved the check for MT safe function variants
after the determination of the MT cflags and use them there. after the determination of the MT cflags and use them there.
1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>

View File

@ -1,6 +1,13 @@
Mon Feb 1 19:04:28 1999 Owen Taylor <otaylor@redhat.com>
* gmain.c (g_main_iterate): Release the main_loop
lock around calls to prepare() and check() so
that we are not holding the main loop lock
over user code.
1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Moved the check for MT save function variants * configure.in: Moved the check for MT safe function variants
after the determination of the MT cflags and use them there. after the determination of the MT cflags and use them there.
1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de> 1999-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>

View File

@ -732,16 +732,27 @@ g_main_iterate (gboolean block,
continue; continue;
} }
in_check_or_prepare++; if (!(hook->flags & G_SOURCE_READY))
if (hook->flags & G_SOURCE_READY ||
((GSourceFuncs *) hook->func)->prepare (source->source_data,
&current_time,
&source_timeout))
{ {
gboolean (*prepare) (gpointer source_data,
GTimeVal *current_time,
gint *timeout);
prepare = ((GSourceFuncs *) hook->func)->prepare;
in_check_or_prepare++;
G_UNLOCK (main_loop);
if ((*prepare) (source->source_data, &current_time, &source_timeout))
hook->flags |= G_SOURCE_READY;
G_LOCK (main_loop);
in_check_or_prepare--; in_check_or_prepare--;
}
if (hook->flags & G_SOURCE_READY)
{
if (!dispatch) if (!dispatch)
{ {
hook->flags |= G_SOURCE_READY;
g_hook_unref (&source_list, hook); g_hook_unref (&source_list, hook);
G_UNLOCK (main_loop); G_UNLOCK (main_loop);
@ -749,14 +760,11 @@ g_main_iterate (gboolean block,
} }
else else
{ {
hook->flags |= G_SOURCE_READY;
n_ready++; n_ready++;
current_priority = source->priority; current_priority = source->priority;
timeout = 0; timeout = 0;
} }
} }
else
in_check_or_prepare--;
if (source_timeout >= 0) if (source_timeout >= 0)
{ {
@ -793,12 +801,24 @@ g_main_iterate (gboolean block,
continue; continue;
} }
in_check_or_prepare++; if (!(hook->flags & G_SOURCE_READY))
if (hook->flags & G_SOURCE_READY ||
((GSourceFuncs *) hook->func)->check (source->source_data,
&current_time))
{ {
gboolean (*check) (gpointer source_data,
GTimeVal *current_time);
check = ((GSourceFuncs *) hook->func)->check;
in_check_or_prepare++;
G_UNLOCK (main_loop);
if ((*check) (source->source_data, &current_time))
hook->flags |= G_SOURCE_READY;
G_LOCK (main_loop);
in_check_or_prepare--; in_check_or_prepare--;
}
if (hook->flags & G_SOURCE_READY)
{
if (dispatch) if (dispatch)
{ {
hook->flags &= ~G_SOURCE_READY; hook->flags &= ~G_SOURCE_READY;
@ -815,8 +835,6 @@ g_main_iterate (gboolean block,
return TRUE; return TRUE;
} }
} }
else
in_check_or_prepare--;
hook = g_hook_next_valid (&source_list, hook, TRUE); hook = g_hook_next_valid (&source_list, hook, TRUE);
} }
@ -852,7 +870,7 @@ g_main_iteration (gboolean block)
if (in_check_or_prepare) if (in_check_or_prepare)
{ {
g_warning ("g_main_iteration(): called recursively from within a source's check() or " g_warning ("g_main_iteration(): called recursively from within a source's check() or "
"prepare() member, iteration not possible"); "prepare() member or from a second thread, iteration not possible");
return FALSE; return FALSE;
} }
else else
@ -878,7 +896,7 @@ g_main_run (GMainLoop *loop)
if (in_check_or_prepare) if (in_check_or_prepare)
{ {
g_warning ("g_main_run(): called recursively from within a source's check() or " g_warning ("g_main_run(): called recursively from within a source's check() or "
"prepare() member, iteration not possible"); "prepare() member or from a second thread, iteration not possible");
return; return;
} }

52
gmain.c
View File

@ -732,16 +732,27 @@ g_main_iterate (gboolean block,
continue; continue;
} }
in_check_or_prepare++; if (!(hook->flags & G_SOURCE_READY))
if (hook->flags & G_SOURCE_READY ||
((GSourceFuncs *) hook->func)->prepare (source->source_data,
&current_time,
&source_timeout))
{ {
gboolean (*prepare) (gpointer source_data,
GTimeVal *current_time,
gint *timeout);
prepare = ((GSourceFuncs *) hook->func)->prepare;
in_check_or_prepare++;
G_UNLOCK (main_loop);
if ((*prepare) (source->source_data, &current_time, &source_timeout))
hook->flags |= G_SOURCE_READY;
G_LOCK (main_loop);
in_check_or_prepare--; in_check_or_prepare--;
}
if (hook->flags & G_SOURCE_READY)
{
if (!dispatch) if (!dispatch)
{ {
hook->flags |= G_SOURCE_READY;
g_hook_unref (&source_list, hook); g_hook_unref (&source_list, hook);
G_UNLOCK (main_loop); G_UNLOCK (main_loop);
@ -749,14 +760,11 @@ g_main_iterate (gboolean block,
} }
else else
{ {
hook->flags |= G_SOURCE_READY;
n_ready++; n_ready++;
current_priority = source->priority; current_priority = source->priority;
timeout = 0; timeout = 0;
} }
} }
else
in_check_or_prepare--;
if (source_timeout >= 0) if (source_timeout >= 0)
{ {
@ -793,12 +801,24 @@ g_main_iterate (gboolean block,
continue; continue;
} }
in_check_or_prepare++; if (!(hook->flags & G_SOURCE_READY))
if (hook->flags & G_SOURCE_READY ||
((GSourceFuncs *) hook->func)->check (source->source_data,
&current_time))
{ {
gboolean (*check) (gpointer source_data,
GTimeVal *current_time);
check = ((GSourceFuncs *) hook->func)->check;
in_check_or_prepare++;
G_UNLOCK (main_loop);
if ((*check) (source->source_data, &current_time))
hook->flags |= G_SOURCE_READY;
G_LOCK (main_loop);
in_check_or_prepare--; in_check_or_prepare--;
}
if (hook->flags & G_SOURCE_READY)
{
if (dispatch) if (dispatch)
{ {
hook->flags &= ~G_SOURCE_READY; hook->flags &= ~G_SOURCE_READY;
@ -815,8 +835,6 @@ g_main_iterate (gboolean block,
return TRUE; return TRUE;
} }
} }
else
in_check_or_prepare--;
hook = g_hook_next_valid (&source_list, hook, TRUE); hook = g_hook_next_valid (&source_list, hook, TRUE);
} }
@ -852,7 +870,7 @@ g_main_iteration (gboolean block)
if (in_check_or_prepare) if (in_check_or_prepare)
{ {
g_warning ("g_main_iteration(): called recursively from within a source's check() or " g_warning ("g_main_iteration(): called recursively from within a source's check() or "
"prepare() member, iteration not possible"); "prepare() member or from a second thread, iteration not possible");
return FALSE; return FALSE;
} }
else else
@ -878,7 +896,7 @@ g_main_run (GMainLoop *loop)
if (in_check_or_prepare) if (in_check_or_prepare)
{ {
g_warning ("g_main_run(): called recursively from within a source's check() or " g_warning ("g_main_run(): called recursively from within a source's check() or "
"prepare() member, iteration not possible"); "prepare() member or from a second thread, iteration not possible");
return; return;
} }