static int same_file;
static int splice_size = SPLICE_SIZE;
static char *filename = "splice-file";
-static int max_client_run = 15;
+static unsigned int max_client_run = 15;
static int run_rw = 1;
static int run_splice = 1;
static int run_mmap = 1;
struct sockaddr_in saddr_in;
struct sockaddr addr;
unsigned int len;
- int sk;
+ int sk, opt;
bind_to_cpu(offset);
- nice(-20);
+ if (nice(-20) < 0)
+ perror("nice");
sk = socket(PF_INET, SOCK_STREAM, 0);
if (sk < 0)
return error("socket");
+ opt = 1;
+ if (setsockopt(sk, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0)
+ return error("setsockopt");
+
saddr_in.sin_addr.s_addr = htonl(INADDR_ANY);
saddr_in.sin_port = htons(net_port + offset);
- if (bind(sk, (struct sockaddr*)&saddr_in, sizeof(saddr_in)) < 0)
+ if (bind(sk, (struct sockaddr *) &saddr_in, sizeof(saddr_in)) < 0)
return error("bind");
if (listen(sk, 1) < 0)
off = 0;
do {
- int ret = splice(fd, &off, pfd[1], NULL, min(size, (unsigned long long) splice_size), 0);
+ int ret = ssplice(fd, &off, pfd[1], NULL, min(size, (unsigned long long) splice_size), 0);
if (ret <= 0)
return error("splice-in");
size -= ret;
while (ret > 0) {
int flags = size ? SPLICE_F_MORE : 0;
- int written = splice(pfd[0], NULL, out_fd, NULL, ret, flags);
+ int written = ssplice(pfd[0], NULL, out_fd, NULL, ret, flags);
if (written <= 0)
return error("splice-out");
char fname[64];
bind_to_cpu(offset);
- nice(-20);
+ if (nice(-20) < 0)
+ perror("nice");
if (!write_to_null)
out_fd = client_open_net(offset);