Re: GIOChannel error handling



Johannes Stezenbach <js convergence de> writes:

> The GIOError type is IMHO unsufficient for proper error
> handling, in some cases one needs access to the real errno.
> 
> (E.g. reading from a device driver which can report buffer
> under/overruns.)
> 
> In my code I currently just check errno directly when I get
> G_IO_ERROR_UNKNOWN, which works with the current GIOChannel
> implementation. However, the Glib API does not guarantee that
> this is valid, and IMHO it also is somewhat unclean.
> 
> 
> I therefore propose to add
> 
>   gint g_io_channel_unix_get_errno (GIOChannel *channel);
> 
> implemented by adding an "errno" member to struct _GIOUnixChannel
> and setting it directly after every system call done in giounix.c.
> 
> 
> I don't know if the concept of errno is really OS indenpendent,
> so I propose it for UNIX only. It would make sense to provide
> something similar for other OSs, too, though. Maybe it should
> even be
> 
>   gint g_io_channel_get_errno (GIOChannel *channel);
> 
> 
> Opinons?

Conceptually, this is the same bug that GTK+ 1.2 suffered from regarding
"EINTR". This was fixed in GLIB HEAD by adding G_IO_ERROR_AGAIN. We will
use this in GIMP 1.4 instead of the ugly direct access to "errno".

Given the fact that device drivers or strange OSs may set errno to
whatever they consider appropriate, we should IMHO follow Johannes'
proposal and make the original errno available through an API.

I'm however biassed whether this should be g_io_channel_unix_get_errno()
or g_io_channel_get_errno(). Tim??

ciao,
--Mitch




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