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

Rami Ylimäki rami.ylimaki at vincit.fi
Wed Oct 19 23:40:11 PDT 2011


On 10/18/2011 03:51 PM, Arvind Umrao wrote:
> @@ -209,7 +209,7 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
>
>       if(n<= 0)
>       {
> -        _xcb_conn_shutdown(c);
> +        _xcb_conn_shutdown(c, errno);
>           return 0;
>       }

I think you might me passing an obsolete error number here (when n 
equals 0).

>
> @@ -317,9 +317,15 @@ void xcb_disconnect(xcb_connection_t *c)
>
>   /* Private interface */
>
> -void _xcb_conn_shutdown(xcb_connection_t *c)
> +void _xcb_conn_shutdown(xcb_connection_t *c, int err)
>   {
> -    c->has_error = 1;
> +#ifndef _WIN32
> +    /* Only error number greater than zero possible*/
> +    if(err>  0)
> +        c->has_error = err;
> +    else
> +#endif /* !_WIN32*/
> +        c->has_error = 1;
>   }

The callers of this function should know which error code to set so that 
there should be no need to adjust it. In other words, callers shouldn't 
pass zero.

> +        _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, errno);
> +    _xcb_conn_shutdown(c, EPIPE);
> +            _xcb_conn_shutdown(c, errno);
> +                _xcb_conn_shutdown(c, ENOTSUP);
> +            _xcb_conn_shutdown(c, ECOMM);

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



More information about the Xcb mailing list