Kill misbehaving subscribed clients instead of hanging
This change only affects clients that are subscribed to events, which should be the main cause of our problems. In the common case (no buffered data) the behaviour doesn't change at all: the message is sent directly, no ev_io / ev_timeout callback is enabled. Once a write to a client's socket is not completed fully (returns with EAGAIN error), we put the message in the tail of a queue and init an ev_io callback and a corresponding timer. If the timer is triggered first, the socket is closed and the client connection is removed. If the socket becomes writeable before the timeout we either reset the timer if we couldn't push all the buffered data or completely remove it if everything was pushed. We could also replace ipc_send_message() for all client connections in i3, not just those subscribed to events. Furthermore, we could limit the amount of messages stored and increase the timeout (or use multiple timeouts): eg it's ok if a client is not reading for 10 seconds and we are only holding 5KB of messages for them but it is not ok if they are inactive for 5 seconds and we have 30MB of messages held. Closes #2999 Closes #2539
This commit is contained in:
@ -166,6 +166,14 @@ int sasprintf(char **strp, const char *fmt, ...);
|
||||
*/
|
||||
ssize_t writeall(int fd, const void *buf, size_t count);
|
||||
|
||||
/**
|
||||
* Like writeall, but instead of retrying upon EAGAIN (returned when a write
|
||||
* would block), the function stops and returns the total number of bytes
|
||||
* written so far.
|
||||
*
|
||||
*/
|
||||
ssize_t writeall_nonblock(int fd, const void *buf, size_t count);
|
||||
|
||||
/**
|
||||
* Safe-wrapper around writeall which exits if it returns -1 (meaning that
|
||||
* write failed)
|
||||
|
Reference in New Issue
Block a user