[Xcb] [PATCH Xcb] Added more error states and removed global error_connection

Rami Ylimäki rami.ylimaki at vincit.fi
Mon Nov 7 02:29:30 PST 2011


On 11/04/2011 03:36 PM, Arvind Umrao wrote:
> @@ -209,7 +207,10 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
>
>       if(n<= 0)
>       {
> -        _xcb_conn_shutdown(c);
> +        /* if bytes_write == 0 Write failed because of end of file!*/
> +        if(!n)
> +            errno = EPIPE;
> +        _xcb_conn_shutdown(c, XCB_CONN_ERROR);

Are you setting errno so that you can print a correct error message in 
Xlib? Please don't do that, instead set a proper XCB shutdown code and 
use that in Xlib, don't use errno for this.

> @@ -672,7 +672,9 @@ int _xcb_in_read(xcb_connection_t *c)
>       if((n>  0) || (n<  0&&  WSAGetLastError() == WSAEWOULDBLOCK))
>   #endif /* !_WIN32 */
>           return 1;
> -    _xcb_conn_shutdown(c);
> +    /* if bytes_read == 0 Read failed because of end of file!*/
> +    errno = EPIPE;
> +    _xcb_conn_shutdown(c, XCB_CONN_ERROR);
>       return 0;
>   }

Same here, signal the error with a separate XCB shutdown code and not 
with errno. Instead of ECHECK(EPIPE) in Xlib, you could just check the 
code in dpy->xcb->connection->has_error.

-- Rami



More information about the Xcb mailing list