Merge branch 'master' of git+ssh://git.freedesktop.org/git/xcb/libxcb
[free-sw/xcb/libxcb] / src / xcb_in.c
index b252ffc..2997de4 100644 (file)
@@ -108,8 +108,6 @@ static int read_packet(xcb_connection_t *c)
             }
             c->in.request_completed = c->in.request_read - 1;
         }
-        if(genrep.response_type == XCB_ERROR)
-            c->in.request_completed = c->in.request_read;
 
         while(c->in.pending_replies && 
              XCB_SEQUENCE_COMPARE (c->in.pending_replies->request, <=, c->in.request_completed))
@@ -120,6 +118,9 @@ static int read_packet(xcb_connection_t *c)
                 c->in.pending_replies_tail = &c->in.pending_replies;
             free(oldpend);
         }
+
+        if(genrep.response_type == XCB_ERROR)
+            c->in.request_completed = c->in.request_read;
     }
 
     if(genrep.response_type == XCB_ERROR || genrep.response_type == XCB_REPLY)
@@ -402,7 +403,8 @@ xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c)
     {
         _xcb_lock_io(c);
         /* FIXME: follow X meets Z architecture changes. */
-        if(_xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */
+        ret = get_event(c);
+        if(!ret && _xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */
             ret = get_event(c);
         _xcb_unlock_io(c);
     }