]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
added --num-msgs option
authorAndrew Tridgell <tridge@samba.org>
Tue, 20 Feb 2007 03:57:13 +0000 (14:57 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 20 Feb 2007 03:57:13 +0000 (14:57 +1100)
added TCP_NODELAY on tcp sockets

(This used to be ctdb commit fa76cff388237adea98c2be0827c54334080256a)

ctdb/ctdb_bench.c
ctdb/tcp/tcp_connect.c

index e1fcd1916d91e5c1bdf80584a7f2afd8e95208a9..60d8b7990422bc33c6129fe31860b7ed97da3901 100644 (file)
@@ -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;
index 0f7d617084c4c33f5c5f137a01ccff7b5eb3e175..fe0fc210baf22d63303cabcde667c31840615013 100644 (file)
@@ -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);         
        }