Commit 7f477905 authored by Radostin Stoyanov's avatar Radostin Stoyanov Committed by Andrei Vagin

util: Introduce fd_set_nonblocking()

Combine the functionality of socket_set_non_blocking() and
socket_set_blocking() into a new function, and move it in
criu/util.c to enable reusability throughout the code base.
Signed-off-by: 's avatarRadostin Stoyanov <rstoyanov1@gmail.com>
parent 116e3cb6
......@@ -274,6 +274,7 @@ static inline int sk_wait_data(int sk)
return poll(&pfd, 1, -1);
}
void fd_set_nonblocking(int fd, bool on);
void tcp_nodelay(int sk, bool on);
void tcp_cork(int sk, bool on);
......
......@@ -1116,6 +1116,24 @@ int fd_has_data(int lfd)
return ret;
}
void fd_set_nonblocking(int fd, bool on)
{
int flags = fcntl(fd, F_GETFL, NULL);
if (flags < 0) {
pr_perror("Failed to obtain flags from fd %d", fd);
return;
}
if (on)
flags |= O_NONBLOCK;
else
flags &= (~O_NONBLOCK);
if (fcntl(fd, F_SETFL, flags) < 0)
pr_perror("Failed to set flags for fd %d", fd);
}
int make_yard(char *path)
{
if (mount("none", path, "tmpfs", 0, NULL)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment