g_io_add_watch, how to remove?



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);

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.



/jonas




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