Skip to content

Commit

Permalink
page-xfer: Pull tcp_cork,nodelay().
Browse files Browse the repository at this point in the history
Move tcp_cork() and tcp_nodelay() to the only user: page-xfer.c. While
at it, fix error messages (as they do not refer to restoring the sockopt
values) and demote them as they are not fatal to the page transfer.

Signed-off-by: Michał Mirosław <[email protected]>
  • Loading branch information
osctobe authored and avagin committed Aug 4, 2023
1 parent 9118601 commit 1db922f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
2 changes: 0 additions & 2 deletions criu/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ static inline int sk_wait_data(int sk)
}

void fd_set_nonblocking(int fd, bool on);
void tcp_nodelay(int sk, bool on);
void tcp_cork(int sk, bool on);

const char *ns_to_string(unsigned int ns);

Expand Down
15 changes: 15 additions & 0 deletions criu/page-xfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <linux/falloc.h>
#include <netinet/tcp.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -157,6 +158,20 @@ static inline int send_psi(int sk, struct page_server_iov *pi)
return send_psi_flags(sk, pi, 0);
}

static void tcp_cork(int sk, bool on)
{
int val = on ? 1 : 0;
if (setsockopt(sk, SOL_TCP, TCP_CORK, &val, sizeof(val)))
pr_pwarn("Unable to set TCP_CORK=%d", val);
}

static void tcp_nodelay(int sk, bool on)
{
int val = on ? 1 : 0;
if (setsockopt(sk, SOL_TCP, TCP_NODELAY, &val, sizeof(val)))
pr_pwarn("Unable to set TCP_NODELAY=%d", val);
}

/* page-server xfer */
static int write_pages_to_server(struct page_xfer *xfer, int p, unsigned long len)
{
Expand Down
15 changes: 0 additions & 15 deletions criu/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <sys/resource.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sched.h>
#include <ftw.h>
#include <time.h>
Expand Down Expand Up @@ -1155,20 +1154,6 @@ const char *ns_to_string(unsigned int ns)
}
}

void tcp_cork(int sk, bool on)
{
int val = on ? 1 : 0;
if (setsockopt(sk, SOL_TCP, TCP_CORK, &val, sizeof(val)))
pr_pwarn("Unable to restore TCP_CORK (%d)", val);
}

void tcp_nodelay(int sk, bool on)
{
int val = on ? 1 : 0;
if (setsockopt(sk, SOL_TCP, TCP_NODELAY, &val, sizeof(val)))
pr_pwarn("Unable to restore TCP_NODELAY (%d)", val);
}

static int get_sockaddr_in(struct sockaddr_storage *addr, char *host, unsigned short port)
{
memset(addr, 0, sizeof(*addr));
Expand Down

0 comments on commit 1db922f

Please sign in to comment.