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.
This commit is contained in:
Marek Marczykowski-Górecki 2013-11-25 02:09:36 +01:00
parent 4010ddaab5
commit 9b859c9ac5

View File

@ -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);
}