mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
added --num-msgs option
added TCP_NODELAY on tcp sockets (This used to be ctdb commit fa76cff388237adea98c2be0827c54334080256a)
This commit is contained in:
parent
cc2696cc50
commit
f49c93f96b
@ -43,6 +43,7 @@ static double end_timer(void)
|
||||
|
||||
static int timelimit = 10;
|
||||
static int num_records = 10;
|
||||
static int num_msgs = 1;
|
||||
static int num_repeats = 100;
|
||||
|
||||
enum my_functions {FUNC_INCR=1, FUNC_FETCH=2};
|
||||
@ -152,6 +153,7 @@ static void bench_ring(struct ctdb_context *ctdb, struct event_context *ev)
|
||||
int vnn=ctdb_get_vnn(ctdb);
|
||||
|
||||
if (vnn == 0) {
|
||||
int i;
|
||||
/* two messages are injected into the ring, moving
|
||||
in opposite directions */
|
||||
int dest, incr;
|
||||
@ -160,18 +162,21 @@ static void bench_ring(struct ctdb_context *ctdb, struct event_context *ev)
|
||||
data.dptr = (uint8_t *)&incr;
|
||||
data.dsize = sizeof(incr);
|
||||
|
||||
incr = 1;
|
||||
dest = (ctdb_get_vnn(ctdb) + incr) % ctdb_get_num_nodes(ctdb);
|
||||
ctdb_send_message(ctdb, dest, 0, data);
|
||||
incr = -1;
|
||||
dest = (ctdb_get_vnn(ctdb) + incr) % ctdb_get_num_nodes(ctdb);
|
||||
ctdb_send_message(ctdb, dest, 0, data);
|
||||
for (i=0;i<num_msgs;i++) {
|
||||
incr = 1;
|
||||
dest = (ctdb_get_vnn(ctdb) + incr) % ctdb_get_num_nodes(ctdb);
|
||||
ctdb_send_message(ctdb, dest, 0, data);
|
||||
|
||||
incr = -1;
|
||||
dest = (ctdb_get_vnn(ctdb) + incr) % ctdb_get_num_nodes(ctdb);
|
||||
ctdb_send_message(ctdb, dest, 0, data);
|
||||
}
|
||||
}
|
||||
|
||||
start_timer();
|
||||
|
||||
while (end_timer() < timelimit) {
|
||||
if (vnn == 0 && msg_count % 1000 == 0) {
|
||||
if (vnn == 0 && msg_count % 10000 == 0) {
|
||||
printf("Ring: %.2f msgs/sec (+ve=%d -ve=%d)\r",
|
||||
msg_count/end_timer(), msg_plus, msg_minus);
|
||||
fflush(stdout);
|
||||
@ -203,6 +208,7 @@ int main(int argc, const char *argv[])
|
||||
{ "self-connect", 0, POPT_ARG_NONE, &self_connect, 0, "enable self connect", "boolean" },
|
||||
{ "timelimit", 't', POPT_ARG_INT, &timelimit, 0, "timelimit", "integer" },
|
||||
{ "num-records", 'r', POPT_ARG_INT, &num_records, 0, "num_records", "integer" },
|
||||
{ "num-msgs", 'n', POPT_ARG_INT, &num_msgs, 0, "num_msgs", "integer" },
|
||||
POPT_TABLEEND
|
||||
};
|
||||
int opt;
|
||||
|
@ -46,6 +46,7 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f
|
||||
struct ctdb_context *ctdb = node->ctdb;
|
||||
int error = 0;
|
||||
socklen_t len = sizeof(error);
|
||||
int one = 1;
|
||||
|
||||
if (getsockopt(tnode->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0 ||
|
||||
error != 0) {
|
||||
@ -64,6 +65,8 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f
|
||||
/* tell the ctdb layer we are connected */
|
||||
node->ctdb->upcalls->node_connected(node);
|
||||
|
||||
setsockopt(tnode->fd,IPPROTO_TCP,TCP_NODELAY,(char *)&one,sizeof(one));
|
||||
|
||||
if (tnode->queue) {
|
||||
EVENT_FD_WRITEABLE(tnode->fde);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user