Properly closing GIOChannels?



Hello all,
I've been fiddling a bit with GIOChannels lately and I've been running
into some rather annoying segfaults, which I believe to stem from me
improperly managing the closing of my GIOChannels. Only problem is, I
can't divine from the docs what the proper way to properly close one
down is. Running the program through gdb and singlestepping a bit
locates the offending segfault to be located within the
g_source_set_callback_indirect() method, which I think is attempting to
dereference a piece of memory that has been freed by my improper closing
of the GIOChannel. Currently I'm doing the following to close things
down:
g_io_channel_shutdown ( io_channel, TRUE, &error );
g_source_remove ( watch_tag_read ); /* tag from earlier call to
g_io_add_watch() */
g_source_remove ( watch_tag_write ); /* tag from earlier call to
g_io_add_watch() */
/* Unref once for each call to g_io_add_watch and one final time to make
the refcount zero so the object is freed */
g_io_channel_unref ( io_channel );
g_io_channel_unref ( io_channel );
g_io_channel_unref ( io_channel );

Thanks in advance,
Arne
:wq





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