summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2024-02-28 17:19:08 +0100
committersfan5 <sfan5@live.de>2024-02-29 17:24:05 +0100
commit78cedac844c8b3accef9bc6bd5a24474e7f9d19a (patch)
tree3fe1e2d86eff18ca7dd50082fec2c3c37160b96d
parentdec29e82ace45eddc910305d8e26de6b0022945b (diff)
downloadmpv-78cedac844c8b3accef9bc6bd5a24474e7f9d19a.tar.bz2
mpv-78cedac844c8b3accef9bc6bd5a24474e7f9d19a.tar.xz
wayland_common: fix DND read error handling
-rw-r--r--video/out/wayland_common.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 582dc81f9e..3c07ee79ee 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1568,25 +1568,35 @@ static void check_dnd_fd(struct vo_wayland_state *wl)
return;
if (fdp.revents & POLLIN) {
- size_t data_read = 0;
+ ssize_t data_read = 0;
const size_t chunk_size = 256;
bstr file_list = {
.start = talloc_zero_size(NULL, chunk_size),
};
- while ((data_read = read(wl->dnd_fd, file_list.start + file_list.len, chunk_size)) > 0) {
+ while (1) {
+ data_read = read(wl->dnd_fd, file_list.start + file_list.len, chunk_size);
+ if (data_read == -1 && errno == EINTR)
+ continue;
+ else if (data_read <= 0)
+ break;
file_list.len += data_read;
file_list.start = talloc_realloc_size(NULL, file_list.start, file_list.len + chunk_size);
memset(file_list.start + file_list.len, 0, chunk_size);
}
- MP_VERBOSE(wl, "Read %zu bytes from the DND fd\n", file_list.len);
+ if (data_read == -1) {
+ MP_VERBOSE(wl, "DND aborted (read error)\n");
+ } else {
+ MP_VERBOSE(wl, "Read %zu bytes from the DND fd\n", file_list.len);
- if (wl->dnd_offer)
- wl_data_offer_finish(wl->dnd_offer);
+ if (wl->dnd_offer)
+ wl_data_offer_finish(wl->dnd_offer);
- mp_event_drop_mime_data(wl->vo->input_ctx, wl->dnd_mime_type,
- file_list, wl->dnd_action);
+ assert(wl->dnd_action >= 0);
+ mp_event_drop_mime_data(wl->vo->input_ctx, wl->dnd_mime_type,
+ file_list, wl->dnd_action);
+ }
talloc_free(file_list.start);
free_dnd_data(wl);