[Xcb] [PATCH 2/3] Do not block when calling reply() multiple times.

Jamey Sharp jamey at minilop.net
Fri Jan 22 14:47:12 PST 2010


I don't understand what this patch is for and am about to be away from
e-mail for two weeks. Just wanted to note, though, that there are
occasionally X requests where you need to call xcb_wait_for_reply more
than once to completely process them. Specifically, there's
ListFontsWithInfo and something in the RECORD extension.

As long as XCB has seen some later response, xcb_wait_for_reply will
immediately return NULL, and xcb_poll_for_reply will return indicating
that wait_for_reply would not have blocked. Some applications might
choose to issue a GetInputFocus or something and rely on the NULL
return for these requests, though you can tell from the earlier
responses when you've received the last one.

Jamey

On Wed, Jan 20, 2010 at 10:04 AM, Julien Danjou <julien at danjou.info> wrote:
> Signed-off-by: Julien Danjou <julien at danjou.info>
> ---
>  src/cookie.c |   14 +++++++++++---
>  src/cookie.h |    1 +
>  2 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/src/cookie.c b/src/cookie.c
> index db0a20f..08b9a75 100644
> --- a/src/cookie.c
> +++ b/src/cookie.c
> @@ -23,6 +23,7 @@ xpybCookie_new(PyTypeObject *self, PyObject *args, PyObject *kw)
>  static void
>  xpybCookie_dealloc(xpybCookie *self)
>  {
> +    Py_CLEAR(self->reply);
>     Py_CLEAR(self->reply_type);
>     Py_CLEAR(self->request);
>     Py_CLEAR(self->conn);
> @@ -63,7 +64,7 @@ xpybCookie_reply(xpybCookie *self, PyObject *args)
>  {
>     xcb_generic_error_t *error;
>     xcb_generic_reply_t *data;
> -    PyObject *shim, *reply;
> +    PyObject *shim;
>
>     /* Check arguments and connection. */
>     if (self->request->is_void) {
> @@ -73,6 +74,12 @@ xpybCookie_reply(xpybCookie *self, PyObject *args)
>     if (xpybConn_invalid(self->conn))
>        return NULL;
>
> +    if(self->reply)
> +    {
> +        Py_INCREF((PyObject *) self->reply);
> +        return (PyObject *) self->reply;
> +    }
> +
>     /* Make XCB call */
>     data = xcb_wait_for_reply(self->conn->conn, self->cookie.sequence, &error);
>     if (xpybError_set(self->conn, error))
> @@ -88,9 +95,10 @@ xpybCookie_reply(xpybCookie *self, PyObject *args)
>        goto err1;
>
>     /* Call the reply type object to get a new xcb.Reply instance */
> -    reply = PyObject_CallFunctionObjArgs((PyObject *)self->reply_type, shim, NULL);
> +    self->reply = (xpybReply *) PyObject_CallFunctionObjArgs((PyObject *)self->reply_type, shim, NULL);
> +    Py_INCREF((PyObject *) self->reply);
>     Py_DECREF(shim);
> -    return reply;
> +    return (PyObject *) self->reply;
>  err1:
>     free(data);
>     return NULL;
> diff --git a/src/cookie.h b/src/cookie.h
> index b00e999..f0e25c0 100644
> --- a/src/cookie.h
> +++ b/src/cookie.h
> @@ -9,6 +9,7 @@ typedef struct {
>     PyObject_HEAD
>     xpybConn *conn;
>     xpybRequest *request;
> +    xpybReply *reply;
>     PyTypeObject *reply_type;
>     xcb_void_cookie_t cookie;
>  } xpybCookie;
> --
> 1.6.6
>
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
>


More information about the Xcb mailing list