mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 14:48:02 +02:00
ei: if sending a message fails, don't send any more
Any error will cause ei_disconnect() which in turn unwinds our context. Each object removed will cause an ei_send_message() to notify the server but that will only cause error messages - our socket is already gone. Fix this by removing the source and checking if the fd is still valid before we write to it. Fixes #47
This commit is contained in:
parent
3f768ecbfc
commit
38244b8c66
1 changed files with 12 additions and 9 deletions
21
src/libei.c
21
src/libei.c
|
|
@ -836,15 +836,18 @@ ei_send_message(struct ei *ei, const struct brei_object *object,
|
|||
_cleanup_iobuf_ struct iobuf *buf = brei_result_get_data(result);
|
||||
assert(buf);
|
||||
int fd = source_get_fd(ei->source);
|
||||
|
||||
int rc = ei_unsent_flush(ei);
|
||||
if (rc >= 0)
|
||||
rc = iobuf_send(buf, fd);
|
||||
if (rc == -EAGAIN) {
|
||||
ei_queue_unsent(ei, ei->source, steal(&buf));
|
||||
rc = 0;
|
||||
} else if (rc < 0){
|
||||
log_warn(ei, "failed to send message: %s", strerror(-rc));
|
||||
int rc = -EPIPE;
|
||||
if (fd != -1) {
|
||||
rc = ei_unsent_flush(ei);
|
||||
if (rc >= 0)
|
||||
rc = iobuf_send(buf, fd);
|
||||
if (rc == -EAGAIN) {
|
||||
ei_queue_unsent(ei, ei->source, steal(&buf));
|
||||
rc = 0;
|
||||
} else if (rc < 0){
|
||||
log_warn(ei, "failed to send message: %s", strerror(-rc));
|
||||
source_remove(ei->source);
|
||||
}
|
||||
}
|
||||
return rc < 0 ? rc : 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue