Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ void set_tcp_tx_delay(int fd, int delay, struct callbacks *cb)
PLOG_ERROR(cb, "setsockopt(TCP_TX_DELAY)");
}

void set_tcp_no_delay(int fd, struct callbacks *cb)
{
int value = true;
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &value, sizeof(value)))
PLOG_ERROR(cb, "setsockopt(TCP_NODELAY)");
}

void fill_random(char *buf, int size)
{
int fd, chunk, done = 0;
Expand Down
1 change: 1 addition & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ void set_freebind(int fd, struct callbacks *cb);
void set_debug(int fd, int onoff, struct callbacks *cb);
void set_mark(int fd, int mark, struct callbacks *cb);
void set_tcp_tx_delay(int fd, int delay, struct callbacks *cb);
void set_tcp_no_delay(int fd, struct callbacks *cb);
void fill_random(char *buf, int size);
int do_close(int fd);
struct addrinfo *copy_addrinfo(const struct addrinfo *);
Expand Down
2 changes: 2 additions & 0 deletions define_all_flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct flags_parser *add_flags_tcp(struct flags_parser *fp)
DEFINE_FLAG(fp, bool, pin_numa, false, 'N', "Pin threads to CPU cores");
#endif
DEFINE_FLAG(fp, int, tcp_tx_delay, 0, 't', "Force usec delay in TCP flows");
DEFINE_FLAG(fp, bool, no_delay, false, 0, "Set TCP_NODELAY sockopt on data sockets to disable Nagle's algorithm");

/* Return the updated fp */
return (fp);
Expand Down Expand Up @@ -149,6 +150,7 @@ struct flags_parser *add_flags_tcp_stream(struct flags_parser *fp)
DEFINE_FLAG(fp, bool, split_bidir , false, 0, "Bidirectional using separate tx/rx sockets");
DEFINE_FLAG(fp, bool, enable_tcp_maerts, false, 'M', "Enables TCP_MAERTS test (server writes and client reads). It overrides enable_read, and enable_write");
DEFINE_FLAG(fp, bool, async_connect, false, 0, "use non blocking connect");
DEFINE_FLAG(fp, bool, no_cork, false, 0, "Do not set MSG_MORE when sending over data sockets.");

/* Return the updated fp */
return (fp);
Expand Down
2 changes: 2 additions & 0 deletions lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ struct options {
bool skip_rx_copy;
bool tx_zerocopy;
bool rx_zerocopy;
bool no_delay;
bool no_cork;
bool time_wait;
double interval;
long long max_pacing_rate;
Expand Down
2 changes: 2 additions & 0 deletions socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ static void socket_init_not_established(struct thread *t, int s)
if (err)
PLOG_ERROR(t->cb, "setsockopt(SO_LINGER)");
}
if (opts->no_delay)
set_tcp_no_delay(s, cb);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions tcp_stream_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ int main(int argc, char **argv)
opts.recv_flags = MSG_TRUNC;
if (opts.tx_zerocopy)
opts.send_flags = MSG_ZEROCOPY;
if (!opts.no_cork)
opts.send_flags |= MSG_MORE;

flags_parser_dump(fp);
flags_parser_destroy(fp);
Expand Down