g_queue problem



Hi all!

I've a little problem with g_queue obj:


/* ******  */
pthread_mutex_lock(&ptr_buff->list_mtx);

jb_log((stderr, "TEST [%d]\n", ptr_buff->queue->length));

if ( (g_queue_is_empty(ptr_buff->queue))==TRUE ){
    jb_log((stderr, "YES queue empty\n"));
    
} else {
    //la lista non e' vuota
    jb_log((stderr, "NO: non empty [%d]\n", ptr_buff->queue->length));
    *el = g_queue_pop_tail(ptr_buff->queue);
    jb_log((stderr, "DENTRO SPOP: [%p]\n", *el));

}

pthread_mutex_unlock(&ptr_buff->list_mtx);
/* ******  */

jb_log() is a fprintf wrapper...

and this is the output:

[jb_ptr_buff.c        ][00150][32765]        TEST [0]
[jb_ptr_buff.c        ][00163][32765]        NO: non empty [0]
[jb_ptr_buff.c        ][00168][32765]        DENTRO SPOP: [0x805ca98]

?!?!
i've not yet pushed anything in queue! 

Is a multithread application, and the queue is mutex protected.
I can't use the async_queue. ( and the pointer *el is ok! )
I missing some code? 
or probably is a bad memory write / memory leak of my application?

glib=2.2

Tnx!




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]