From 77b2758c93fedc0238d0529caa4d8e31076c4074 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Sat, 25 Aug 2012 01:11:22 +0200 Subject: [PATCH] vm/qubes-rpc: move set_(non)?block to ioall.c as can be used not only in qrexec --- qrexec/write_stdin.c | 12 ------------ qubes_rpc/ioall.c | 11 +++++++++++ qubes_rpc/ioall.h | 2 ++ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/qrexec/write_stdin.c b/qrexec/write_stdin.c index 7ace53b6..939b72ea 100644 --- a/qrexec/write_stdin.c +++ b/qrexec/write_stdin.c @@ -109,18 +109,6 @@ int write_stdin(int fd, int client_id, char *data, int len, } -void set_nonblock(int fd) -{ - int fl = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, fl | O_NONBLOCK); -} - -void set_block(int fd) -{ - int fl = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, fl & ~O_NONBLOCK); -} - /* Data feed process has exited, so we need to clear all control structures for the client. However, if we have buffered data for the client (which is rare btw), diff --git a/qubes_rpc/ioall.c b/qubes_rpc/ioall.c index fff063cc..355b88fa 100644 --- a/qubes_rpc/ioall.c +++ b/qubes_rpc/ioall.c @@ -32,6 +32,17 @@ void perror_wrapper(char * msg) errno=prev; } +void set_nonblock(int fd) +{ + int fl = fcntl(fd, F_GETFL, 0); + fcntl(fd, F_SETFL, fl | O_NONBLOCK); +} + +void set_block(int fd) +{ + int fl = fcntl(fd, F_GETFL, 0); + fcntl(fd, F_SETFL, fl & ~O_NONBLOCK); +} int write_all(int fd, void *buf, int size) { diff --git a/qubes_rpc/ioall.h b/qubes_rpc/ioall.h index 1a700c6c..c9913e8f 100644 --- a/qubes_rpc/ioall.h +++ b/qubes_rpc/ioall.h @@ -1,3 +1,5 @@ int write_all(int fd, void *buf, int size); int read_all(int fd, void *buf, int size); int copy_fd_all(int fdout, int fdin); +void set_nonblock(int fd); +void set_block(int fd);