aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-28 18:20:25 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-28 18:20:25 +0000
commit903581b7eb05a566373eb784eeb958b9cd792493 (patch)
tree5bc6f512230313bb7bd0715346054ab44a5d38d2
parentfont: set pixman filter when re-scaling glyph (diff)
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.
-rw-r--r--selection.c10
-rw-r--r--terminal.c5
2 files changed, 9 insertions, 6 deletions
diff --git a/selection.c b/selection.c
index 8ed0b6da..2839636a 100644
--- a/selection.c
+++ b/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))
diff --git a/terminal.c b/terminal.c
index 887e90c1..0cfbdb2e 100644
--- a/terminal.c
+++ b/terminal.c
@@ -32,6 +32,7 @@
bool
term_to_slave(struct terminal *term, const void *_data, size_t len)
{
+ size_t async_idx = 0;
if (tll_length(term->ptmx_buffer) > 0) {
/* With a non-empty queue, EPOLLOUT has already been enabled */
goto enqueue_data;
@@ -42,7 +43,7 @@ term_to_slave(struct terminal *term, const void *_data, size_t len)
* switch to asynchronous.
*/
- switch (async_write(term->ptmx, _data, len, &(size_t){0})) {
+ switch (async_write(term->ptmx, _data, len, &async_idx)) {
case ASYNC_WRITE_REMAIN:
/* Switch to asynchronous mode; let FDM write the remaining data */
if (!fdm_event_add(term->fdm, term->ptmx, EPOLLOUT))
@@ -73,7 +74,7 @@ enqueue_data:
struct ptmx_buffer queued = {
.data = copy,
.len = len,
- .idx = 0,
+ .idx = async_idx,
};
tll_push_back(term->ptmx_buffer, queued);
}