On Fri, 2004-07-23 at 14:27 +0200, Philip Van Hoof wrote: > Queue * new_Queue (gpointer host) > { > Queue *queue = (Queue*)g_malloc(sizeof (Queue)); > > queue->app = host; > queue->add_item = add_item; > queue->cleanup = cleanup; > queue->items = NULL; > pthread_mutex_init (&queue->items_mutex, NULL); > return queue; > } > Why aren't you using a GAsyncQueue? > > static void * thread_main_func (void * data) > { > Queue *queue = (Queue*)data; > > while (queue->items) This is unsafe. Use: while ((item = g_async_queue_try_pop(queue))) > if (g_list_length (queue->items) == 1) > { > pthread_create (&queue->thread, NULL, thread_main_func, queue); > } This seems like a race condition that will create multiple consumer threads in some cases (not to mention it being unsafe to call g_list_length on a list being modified by another thread). In that case, you will certainly have a bigger problem as multiple consumer threads try to process an item (item access isn't locked). > While most of the times this works perfectly, I am getting > > Xlib: unexpected async reply (sequence 0x46c)! > > When I click the GtkDrawingArea to fast. The thread which is created to > process queued items will get killed by a segmentation error. Use a GAsyncQueue, and only create the thread once, and have it simply block on item retrieval.
Attachment:
signature.asc
Description: This is a digitally signed message part