Re: g_io_add_watch, how to remove?
- From: Owen Taylor <otaylor redhat com>
- To: jonas <jonas bulow servicefactory se>
- Cc: gtk-devel-list gnome org
- Subject: Re: g_io_add_watch, how to remove?
- Date: 01 Aug 2001 10:21:20 -0400
[ Not really a suitable question for gtk-devel-list ]
jonas <jonas bulow servicefactory se> writes:
> Hi!
>
> I use g_io_add_watch to watch for activities on a unix file descriptor:
>
> g_io_add_watch(cioc,
> G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
> client_handler,
> NULL);
>
> How do I remove this watch when the channel is no longer available, i.e
> closed?
>
> client_handler above does the following when the tearing down the socket
> connection (cioc):
>
> g_io_channel_close(cioc);
> g_free(cioc);
^^^^^^^^^^^^^^
Aagh! Never, never, never free, any complex data structure that
GLib, etc, allocates. g_io_channel_unref().
> The problem I experience is that the main loop (g_main) dispatches
> activites on this closed channel/file descriptor and I realize that I
> have forgotten to remove the watch on this channel from the main loop.
> So, if anyone could enlightenme how to do that I would be glad. I have
> looked in the glib manual and in the source without getting any insights
> of how to do this.
g_source_remove()
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]