Ver código fonte

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.
Marek Marczykowski-Górecki 10 anos atrás
pai
commit
9b859c9ac5
1 arquivos alterados com 4 adições e 0 exclusões
  1. 4 0
      qubes-rpc/ioall.c

+ 4 - 0
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);
 }