Recurse with may_block = FALSE, so we don't get into the pathology where

Thu Nov  1 21:48:43 2001  Owen Taylor  <otaylor@redhat.com>

        * tests/mainloop-test.c (recurser_idle): Recurse
        with may_block = FALSE, so we don't get into
        the pathology where the recurser_idle recurses
        for 10 iterations, and the only thing that is
        running is the recurser idle, which adds
        another recursion for each of those 10 iterations
        and....

        * tests/mainloop-test.c (create_crawler): Fix race
        condition where a crawler source could be destroyed
        before it was added to the crawler array.

        * test/Makefile.am: Add mainloop-test back.
This commit is contained in:
Owen Taylor 2001-11-02 02:56:08 +00:00 committed by Owen Taylor
parent 018c5f7d6b
commit 3481763c97
10 changed files with 138 additions and 4 deletions

View File

@ -1,3 +1,19 @@
Thu Nov 1 21:48:43 2001 Owen Taylor <otaylor@redhat.com>
* tests/mainloop-test.c (recurser_idle): Recurse
with may_block = FALSE, so we don't get into
the pathology where the recurser_idle recurses
for 10 iterations, and the only thing that is
running is the recurser idle, which adds
another recursion for each of those 10 iterations
and....
* tests/mainloop-test.c (create_crawler): Fix race
condition where a crawler source could be destroyed
before it was added to the crawler array.
* test/Makefile.am: Add mainloop-test back.
2001-11-01 Marius Andreiana <mandreiana@yahoo.com> 2001-11-01 Marius Andreiana <mandreiana@yahoo.com>
* configure.in: Added ro (Romanian) to ALL_LINGUAS * configure.in: Added ro (Romanian) to ALL_LINGUAS

View File

@ -1,3 +1,19 @@
Thu Nov 1 21:48:43 2001 Owen Taylor <otaylor@redhat.com>
* tests/mainloop-test.c (recurser_idle): Recurse
with may_block = FALSE, so we don't get into
the pathology where the recurser_idle recurses
for 10 iterations, and the only thing that is
running is the recurser idle, which adds
another recursion for each of those 10 iterations
and....
* tests/mainloop-test.c (create_crawler): Fix race
condition where a crawler source could be destroyed
before it was added to the crawler array.
* test/Makefile.am: Add mainloop-test back.
2001-11-01 Marius Andreiana <mandreiana@yahoo.com> 2001-11-01 Marius Andreiana <mandreiana@yahoo.com>
* configure.in: Added ro (Romanian) to ALL_LINGUAS * configure.in: Added ro (Romanian) to ALL_LINGUAS

View File

@ -1,3 +1,19 @@
Thu Nov 1 21:48:43 2001 Owen Taylor <otaylor@redhat.com>
* tests/mainloop-test.c (recurser_idle): Recurse
with may_block = FALSE, so we don't get into
the pathology where the recurser_idle recurses
for 10 iterations, and the only thing that is
running is the recurser idle, which adds
another recursion for each of those 10 iterations
and....
* tests/mainloop-test.c (create_crawler): Fix race
condition where a crawler source could be destroyed
before it was added to the crawler array.
* test/Makefile.am: Add mainloop-test back.
2001-11-01 Marius Andreiana <mandreiana@yahoo.com> 2001-11-01 Marius Andreiana <mandreiana@yahoo.com>
* configure.in: Added ro (Romanian) to ALL_LINGUAS * configure.in: Added ro (Romanian) to ALL_LINGUAS

View File

@ -1,3 +1,19 @@
Thu Nov 1 21:48:43 2001 Owen Taylor <otaylor@redhat.com>
* tests/mainloop-test.c (recurser_idle): Recurse
with may_block = FALSE, so we don't get into
the pathology where the recurser_idle recurses
for 10 iterations, and the only thing that is
running is the recurser idle, which adds
another recursion for each of those 10 iterations
and....
* tests/mainloop-test.c (create_crawler): Fix race
condition where a crawler source could be destroyed
before it was added to the crawler array.
* test/Makefile.am: Add mainloop-test back.
2001-11-01 Marius Andreiana <mandreiana@yahoo.com> 2001-11-01 Marius Andreiana <mandreiana@yahoo.com>
* configure.in: Added ro (Romanian) to ALL_LINGUAS * configure.in: Added ro (Romanian) to ALL_LINGUAS

View File

@ -1,3 +1,19 @@
Thu Nov 1 21:48:43 2001 Owen Taylor <otaylor@redhat.com>
* tests/mainloop-test.c (recurser_idle): Recurse
with may_block = FALSE, so we don't get into
the pathology where the recurser_idle recurses
for 10 iterations, and the only thing that is
running is the recurser idle, which adds
another recursion for each of those 10 iterations
and....
* tests/mainloop-test.c (create_crawler): Fix race
condition where a crawler source could be destroyed
before it was added to the crawler array.
* test/Makefile.am: Add mainloop-test back.
2001-11-01 Marius Andreiana <mandreiana@yahoo.com> 2001-11-01 Marius Andreiana <mandreiana@yahoo.com>
* configure.in: Added ro (Romanian) to ALL_LINGUAS * configure.in: Added ro (Romanian) to ALL_LINGUAS

View File

@ -1,3 +1,19 @@
Thu Nov 1 21:48:43 2001 Owen Taylor <otaylor@redhat.com>
* tests/mainloop-test.c (recurser_idle): Recurse
with may_block = FALSE, so we don't get into
the pathology where the recurser_idle recurses
for 10 iterations, and the only thing that is
running is the recurser idle, which adds
another recursion for each of those 10 iterations
and....
* tests/mainloop-test.c (create_crawler): Fix race
condition where a crawler source could be destroyed
before it was added to the crawler array.
* test/Makefile.am: Add mainloop-test back.
2001-11-01 Marius Andreiana <mandreiana@yahoo.com> 2001-11-01 Marius Andreiana <mandreiana@yahoo.com>
* configure.in: Added ro (Romanian) to ALL_LINGUAS * configure.in: Added ro (Romanian) to ALL_LINGUAS

View File

@ -1,3 +1,19 @@
Thu Nov 1 21:48:43 2001 Owen Taylor <otaylor@redhat.com>
* tests/mainloop-test.c (recurser_idle): Recurse
with may_block = FALSE, so we don't get into
the pathology where the recurser_idle recurses
for 10 iterations, and the only thing that is
running is the recurser idle, which adds
another recursion for each of those 10 iterations
and....
* tests/mainloop-test.c (create_crawler): Fix race
condition where a crawler source could be destroyed
before it was added to the crawler array.
* test/Makefile.am: Add mainloop-test back.
2001-11-01 Marius Andreiana <mandreiana@yahoo.com> 2001-11-01 Marius Andreiana <mandreiana@yahoo.com>
* configure.in: Added ro (Romanian) to ALL_LINGUAS * configure.in: Added ro (Romanian) to ALL_LINGUAS

View File

@ -1,3 +1,19 @@
Thu Nov 1 21:48:43 2001 Owen Taylor <otaylor@redhat.com>
* tests/mainloop-test.c (recurser_idle): Recurse
with may_block = FALSE, so we don't get into
the pathology where the recurser_idle recurses
for 10 iterations, and the only thing that is
running is the recurser idle, which adds
another recursion for each of those 10 iterations
and....
* tests/mainloop-test.c (create_crawler): Fix race
condition where a crawler source could be destroyed
before it was added to the crawler array.
* test/Makefile.am: Add mainloop-test back.
2001-11-01 Marius Andreiana <mandreiana@yahoo.com> 2001-11-01 Marius Andreiana <mandreiana@yahoo.com>
* configure.in: Added ro (Romanian) to ALL_LINGUAS * configure.in: Added ro (Romanian) to ALL_LINGUAS

View File

@ -62,6 +62,7 @@ test_programs = \
hash-test \ hash-test \
iochannel-test \ iochannel-test \
list-test \ list-test \
mainloop-test \
module-test \ module-test \
node-test \ node-test \
queue-test \ queue-test \
@ -102,7 +103,7 @@ gio_test_LDADD = $(progs_LDADD)
hash_test_LDADD = $(progs_LDADD) hash_test_LDADD = $(progs_LDADD)
iochannel_test_LDADD = $(progs_LDADD) iochannel_test_LDADD = $(progs_LDADD)
list_test_LDADD = $(progs_LDADD) list_test_LDADD = $(progs_LDADD)
#mainloop_test_LDADD = $(thread_LDADD) mainloop_test_LDADD = $(thread_LDADD)
markup_test_LDADD = $(progs_LDADD) markup_test_LDADD = $(progs_LDADD)
module_test_LDADD = $(module_LDADD) module_test_LDADD = $(module_LDADD)
module_test_LDFLAGS = @G_MODULE_LDFLAGS@ module_test_LDFLAGS = @G_MODULE_LDFLAGS@

View File

@ -18,6 +18,10 @@
#define CRAWLER_TIMEOUT_RANGE 40 #define CRAWLER_TIMEOUT_RANGE 40
#define RECURSER_TIMEOUT 50 #define RECURSER_TIMEOUT 50
/* The partial ordering between the context array mutex and
* crawler array mutex is that the crawler array mutex cannot
* be locked while the context array mutex is locked
*/
GPtrArray *context_array; GPtrArray *context_array;
GMutex *context_array_mutex; GMutex *context_array_mutex;
GCond *context_array_cond; GCond *context_array_cond;
@ -327,13 +331,14 @@ create_crawler (void)
GSource *source = g_timeout_source_new (g_random_int_range (0, CRAWLER_TIMEOUT_RANGE)); GSource *source = g_timeout_source_new (g_random_int_range (0, CRAWLER_TIMEOUT_RANGE));
g_source_set_callback (source, (GSourceFunc)crawler_callback, source, NULL); g_source_set_callback (source, (GSourceFunc)crawler_callback, source, NULL);
G_LOCK (crawler_array_lock);
g_ptr_array_add (crawler_array, source);
g_mutex_lock (context_array_mutex); g_mutex_lock (context_array_mutex);
g_source_attach (source, context_array->pdata[g_random_int_range (0, context_array->len)]); g_source_attach (source, context_array->pdata[g_random_int_range (0, context_array->len)]);
g_source_unref (source); g_source_unref (source);
g_mutex_unlock (context_array_mutex); g_mutex_unlock (context_array_mutex);
G_LOCK (crawler_array_lock);
g_ptr_array_add (crawler_array, source);
G_UNLOCK (crawler_array_lock); G_UNLOCK (crawler_array_lock);
} }
@ -361,7 +366,7 @@ recurser_idle (gpointer data)
gint i; gint i;
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
g_main_context_iteration (context, TRUE); g_main_context_iteration (context, FALSE);
return FALSE; return FALSE;
} }