mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-02-17 11:20:36 +01:00
client: handle the case of zero data bytes
When terminating the connection, we might get a read of zero Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
fb115a1f43
commit
23c34fc77d
2 changed files with 9 additions and 5 deletions
|
|
@ -401,10 +401,14 @@ client_dispatch(struct source *source, void *data)
|
|||
|
||||
_cleanup_iobuf_ struct iobuf *buf = iobuf_new(64);
|
||||
int rc = iobuf_append_from_fd(buf, source_get_fd(source));
|
||||
if (rc == -EAGAIN)
|
||||
if (rc == -EAGAIN) {
|
||||
return;
|
||||
else if (rc < 0)
|
||||
} else if (rc == 0) {
|
||||
rc = -ECANCELED;
|
||||
goto error;
|
||||
} else if (rc < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
msg = client_parse_message(iobuf_data(buf), iobuf_len(buf));
|
||||
if (!msg) {
|
||||
|
|
|
|||
|
|
@ -127,9 +127,9 @@ iobuf_append_from_fd(struct iobuf *buf, int fd)
|
|||
ssize_t rc;
|
||||
do {
|
||||
rc = xread(fd, data, sizeof(data));
|
||||
if (rc <= 0) {
|
||||
if (rc == -EAGAIN)
|
||||
return nread;
|
||||
if (rc == 0 || rc == -EAGAIN) {
|
||||
break;
|
||||
} else if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue