mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
async: first synchronous write may succeed partially
When trying to write (to e.g. the slave, or to a clipboard receiver), we first try to send the data synchronously, and only if that fails do we switch to asynchronous mode. However, the first synchronous may (in fact, is likely to) succeed partially.
This commit is contained in:
parent
c5602fde96
commit
903581b7eb
2 changed files with 9 additions and 6 deletions
10
selection.c
10
selection.c
|
|
@ -384,13 +384,14 @@ send(void *data, struct wl_data_source *wl_data_source, const char *mime_type,
|
|||
return;
|
||||
}
|
||||
|
||||
switch (async_write(fd, selection, len, &(size_t){0})) {
|
||||
size_t async_idx = 0;
|
||||
switch (async_write(fd, selection, len, &async_idx)) {
|
||||
case ASYNC_WRITE_REMAIN: {
|
||||
struct clipboard_send *ctx = malloc(sizeof(*ctx));
|
||||
*ctx = (struct clipboard_send) {
|
||||
.data = strdup(selection),
|
||||
.len = len,
|
||||
.idx = 0,
|
||||
.idx = async_idx,
|
||||
};
|
||||
|
||||
if (fdm_add(wayl->fdm, fd, EPOLLOUT, &fdm_send, ctx))
|
||||
|
|
@ -475,13 +476,14 @@ primary_send(void *data,
|
|||
return;
|
||||
}
|
||||
|
||||
switch (async_write(fd, selection, len, &(size_t){0})) {
|
||||
size_t async_idx = 0;
|
||||
switch (async_write(fd, selection, len, &async_idx)) {
|
||||
case ASYNC_WRITE_REMAIN: {
|
||||
struct clipboard_send *ctx = malloc(sizeof(*ctx));
|
||||
*ctx = (struct clipboard_send) {
|
||||
.data = strdup(selection),
|
||||
.len = len,
|
||||
.idx = 0,
|
||||
.idx = async_idx,
|
||||
};
|
||||
|
||||
if (fdm_add(wayl->fdm, fd, EPOLLOUT, &fdm_send, ctx))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue