[Xcb] [PATCH xcb/libxcb] Fatal error message when we close libX11 window application

Arvind Umrao arvind.umrao at oracle.com
Thu Oct 20 01:48:00 PDT 2011


On 10/20/11 12:10 PM, Rami Ylimäki wrote:
>> +        _xcb_conn_shutdown(c, errno);
>> +            _xcb_conn_shutdown(c, errno);
>> +        _xcb_conn_shutdown(c, errno);
>> +        _xcb_conn_shutdown(c, errno);
>> +        _xcb_conn_shutdown(c, errno);
>> +    _xcb_conn_shutdown(c, EPIPE);
>> +            _xcb_conn_shutdown(c, errno);
>> +                _xcb_conn_shutdown(c, ENOTSUP);
>> +            _xcb_conn_shutdown(c, ECOMM);
> +        _xcb_conn_shutdown(c, errno);
>
> Looks like this approach would work well in practice. However, I don't 
> see anything wrong in using XCB specific error codes instead of the 
> generic errno codes. In the end I don't care which approach is taken, 
> but it might be more clear to just use two values (e.g. 
> CONNECTION_ERROR and CONNECTION_CLOSED) since nobody is using the 
> other error codes for anything.
>
> -- Rami
>

Thanks for the review. Your suggestions are good, specially for windows 
environment I do not need to worry about errno.

So my code changes will look like something

void _xcb_conn_shutdown(xcb_connection_t *c, xcb_connection_error_type err)
{
     c->has_error = err;
}

_xcb_conn_shutdown(c, CONNECTION_ERROR) or _xcb_conn_shutdown(c, 
CONNECTION_CLOSED)

Junta any objection if we do not give specific errno.  Sometime people 
do want to know errno. Also our legacy  libX11 default IO hander depends 
on errno.  But it is not big deal, I can change libX11 IO handler and 
make it fit for xcb connection error.  In case if we do want to keep the 
errno,  we can add one more variable for connection error type as 
suggested by Rami, sometime back.

xcbinit.h
enum xcb_connection_error_type
{
     CONNECTION_ERROR = 1 ,
     CONNECTION_CLOSED =2
};


struct xcb_connection_t {
     int has_error; /* It will store errno */

     xcb_connection_error_type err_type;  /*  I can add one more 
variable for error type,  as Rami suggested sometime back */

     /* constant data */
     xcb_setup_t *setup;
     int fd;

     /* I/O data */
     pthread_mutex_t iolock;
     _xcb_in in;
     _xcb_out out;

     /* misc data */
     _xcb_ext ext;
     _xcb_xid xid;
};


Thanks and Regards
-Arvind



More information about the Xcb mailing list