aboutsummaryrefslogtreecommitdiffstats
path: root/libaxl_flush.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-04-20 18:58:00 +0200
committerMattias Andrée <maandree@kth.se>2020-04-20 18:58:00 +0200
commitda8b1c1d1baafb9cf4a0cc9a88362f161f8d1319 (patch)
tree0fb0676b127996064ccb75b695e9aaf9657ce9f1 /libaxl_flush.c
downloadlibaxl-da8b1c1d1baafb9cf4a0cc9a88362f161f8d1319.tar.gz
libaxl-da8b1c1d1baafb9cf4a0cc9a88362f161f8d1319.tar.bz2
libaxl-da8b1c1d1baafb9cf4a0cc9a88362f161f8d1319.tar.xz
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libaxl_flush.c')
-rw-r--r--libaxl_flush.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libaxl_flush.c b/libaxl_flush.c
new file mode 100644
index 0000000..848dbe5
--- /dev/null
+++ b/libaxl_flush.c
@@ -0,0 +1,30 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+int
+libaxl_flush(LIBAXL_CONNECTION *restrict conn, int flags)
+{
+ LIBAXL_CONTEXT *ctx;
+ ssize_t r;
+
+ WLOCK_CONNECTION_SEND(conn);
+
+ while ((ctx = conn->pending_out)) {
+ while (ctx->out_progress < ctx->out_length) {
+ r = liberror_send(conn->fd, &ctx->out_buf[ctx->out_progress],
+ ctx->out_length - ctx->out_progress, flags, "<display server>");
+ if (r < 0) {
+ WUNLOCK_CONNECTION_SEND(conn);
+ return LIBAXL_ERROR_SYSTEM;
+ }
+ ctx->out_progress += (size_t)r;
+ }
+
+ conn->pending_out = ctx->next_pending_out;
+ libaxl_context_free(ctx);
+ }
+
+ WUNLOCK_CONNECTION_SEND(conn);
+
+ return 0;
+}