xcb_in: Allow file descriptors to arrive early
The xserver sends file descriptors independently of replies. If the server sends many events to the client, it is possible for the reply to arrive several messages after the file descriptor. The code already supported this but only if the intermediate messages ended in partial packets. With this patch, file descriptors will be buffered indefinitely until they are consumed by a reply. There is still a limit of 16 file descriptors imposed by the XCB_MAX_PASS_FD constant. If this limit is exceeded, we call _xcb_conn_shutdown.
This commit is contained in:
parent
43fbf03e54
commit
2b0c96c5ea
16
src/xcb_in.c
16
src/xcb_in.c
|
@ -913,6 +913,7 @@ int _xcb_in_init(_xcb_in *in)
|
|||
|
||||
void _xcb_in_destroy(_xcb_in *in)
|
||||
{
|
||||
int i;
|
||||
pthread_cond_destroy(&in->event_cond);
|
||||
free_reply_list(in->current_reply);
|
||||
_xcb_map_delete(in->replies, (void (*)(void *)) free_reply_list);
|
||||
|
@ -929,6 +930,9 @@ void _xcb_in_destroy(_xcb_in *in)
|
|||
in->pending_replies = pend->next;
|
||||
free(pend);
|
||||
}
|
||||
for(i = 0; i < in->in_fd.nfd; i++)
|
||||
close(in->in_fd.fd[i]);
|
||||
in->in_fd.nfd = 0;
|
||||
}
|
||||
|
||||
void _xcb_in_wake_up_next_reader(xcb_connection_t *c)
|
||||
|
@ -1048,18 +1052,6 @@ int _xcb_in_read(xcb_connection_t *c)
|
|||
&c->in.in_fd.fd[c->in.in_fd.ifd],
|
||||
c->in.in_fd.nfd * sizeof (int));
|
||||
c->in.in_fd.ifd = 0;
|
||||
|
||||
/* If we have any left-over file descriptors after emptying
|
||||
* the input buffer, then the server sent some that we weren't
|
||||
* expecting. Close them and mark the connection as broken;
|
||||
*/
|
||||
if (c->in.queue_len == 0 && c->in.in_fd.nfd != 0) {
|
||||
int i;
|
||||
for (i = 0; i < c->in.in_fd.nfd; i++)
|
||||
close(c->in.in_fd.fd[i]);
|
||||
_xcb_conn_shutdown(c, XCB_CONN_CLOSED_FDPASSING_FAILED);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
|
|
Loading…
Reference in New Issue