From 9b859c9ac55af6d533cb50149f7a120fc9792304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 25 Nov 2013 02:09:36 +0100 Subject: [PATCH] qubes-rpc: save one syscall on each data block read_all/write_all calls set_* on every call, so this can be noticeable performance improvement. --- qubes-rpc/ioall.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qubes-rpc/ioall.c b/qubes-rpc/ioall.c index 2a81df4..ce61700 100644 --- a/qubes-rpc/ioall.c +++ b/qubes-rpc/ioall.c @@ -35,12 +35,16 @@ void perror_wrapper(char * msg) void set_nonblock(int fd) { int fl = fcntl(fd, F_GETFL, 0); + if (fl & O_NONBLOCK) + return; fcntl(fd, F_SETFL, fl | O_NONBLOCK); } void set_block(int fd) { int fl = fcntl(fd, F_GETFL, 0); + if (!(fl & O_NONBLOCK)) + return; fcntl(fd, F_SETFL, fl & ~O_NONBLOCK); }