From 2fc02029b96876a8a28ae1061e0dcc427c7e9b26 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 12 Jan 2016 15:25:15 +0100 Subject: [PATCH] sse-multiplex: don't block on client sockets Rather kill a client connection when the write buffer is full than blocking in sse-multiplexd. --- net/sse-multiplex/src/sse-multiplexd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sse-multiplex/src/sse-multiplexd.c b/net/sse-multiplex/src/sse-multiplexd.c index a9dc129..131943b 100644 --- a/net/sse-multiplex/src/sse-multiplexd.c +++ b/net/sse-multiplex/src/sse-multiplexd.c @@ -236,7 +236,7 @@ static void remove_provider(provider_t *p) { } static void add_client(provider_t *p, FILE *file) { - if (fputs(p->header, file) == EOF || fflush(file) == EOF) { + if (fputs(p->header, file) == EOF || fflush(file) == EOF || ferror(file)) { fclose(file); return; } @@ -415,6 +415,8 @@ static void handle_accept(uint32_t events) { return; } + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); + provider_t *p = get_provider(command); if (!p) { fclose(file);