Don't block when flushing a full protocol buffer

In case the client isn't responding, this will block the compositor.
Instead we flush with MSG_DONTWAIT, which lets us fill up the kernel buffer
as much as we can (after not returning EPOLLOUT anymore it still can take
80k more), and then disconnect the client if we get EAGAIN.
This commit is contained in:
Kristian Høgsberg 2012-02-29 11:07:48 -05:00
parent bf53f2033d
commit b26774da5b
4 changed files with 39 additions and 15 deletions

View file

@ -88,6 +88,14 @@ struct wl_global {
static int wl_debug = 0;
static void
destroy_client(void *data)
{
struct wl_client *client = data;
wl_client_destroy(client);
}
WL_EXPORT void
wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...)
{
@ -104,7 +112,9 @@ wl_resource_post_event(struct wl_resource *resource, uint32_t opcode, ...)
if (closure == NULL)
return;
wl_closure_send(closure, resource->client->connection);
if (wl_closure_send(closure, resource->client->connection))
wl_event_loop_add_idle(resource->client->display->loop,
destroy_client, resource->client);
if (wl_debug)
wl_closure_print(closure, object, true);
@ -129,7 +139,9 @@ wl_resource_queue_event(struct wl_resource *resource, uint32_t opcode, ...)
if (closure == NULL)
return;
wl_closure_queue(closure, resource->client->connection);
if (wl_closure_queue(closure, resource->client->connection))
wl_event_loop_add_idle(resource->client->display->loop,
destroy_client, resource->client);
if (wl_debug)
wl_closure_print(closure, object, true);