mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
dnd.c: use non-blocking I/O in drop_send_file_chunks()
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/472b29a5-22c7-4f25-9541-9c9fafa78518 Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
5cb0df0305
commit
e948f64dbf
@@ -217,6 +217,8 @@ Detailed list of changes
|
||||
|
||||
- Password input in kittens: hide the cursor and display 🔒 (U+1F512) at the end of typed characters to make it visually clear the user is entering a password
|
||||
|
||||
- DnD: Use non-blocking I/O when reading file chunks in ``drop_send_file_chunks()`` to avoid blocking the main event loop
|
||||
|
||||
0.46.2 [2026-03-21]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -552,6 +552,11 @@ drop_send_file_chunks(Window *w) {
|
||||
ssize_t n;
|
||||
do { n = read(w->drop.file_fd_plus_one - 1, buf, sizeof(buf)); } while (n < 0 && errno == EINTR);
|
||||
if (n < 0) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
/* No data available right now; retry via timer */
|
||||
w->drop.file_send_timer = add_main_loop_timer(ms_to_monotonic_t(20), false, file_send_timer_callback, (void*)(uintptr_t)w->id, NULL);
|
||||
return;
|
||||
}
|
||||
drop_close_file_fd(w);
|
||||
drop_send_error(w, EIO);
|
||||
return;
|
||||
@@ -583,7 +588,7 @@ drop_send_file_chunks(Window *w) {
|
||||
static void
|
||||
drop_send_file_data(Window *w, const char *path) {
|
||||
drop_close_file_fd(w);
|
||||
int fd = safe_open(path, O_RDONLY | O_CLOEXEC, 0);
|
||||
int fd = safe_open(path, O_RDONLY | O_CLOEXEC | O_NONBLOCK, 0);
|
||||
if (fd < 0) {
|
||||
switch (errno) {
|
||||
case ENOENT: case ENOTDIR: drop_send_error(w, ENOENT); break;
|
||||
|
||||
Reference in New Issue
Block a user