add longlived option to test client 92/2892/1
authorAndy Green <andy.green@linaro.org>
Sun, 13 Jan 2013 03:58:18 +0000 (11:58 +0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:24 +0000 (13:01 -0800)
Needed to confirm pending timeouts won't kill the connection, by default
it spams the server with connections that live less than 5s

Signed-off-by: Andy Green <andy.green@linaro.org>
test-server/test-client.c

index 9f65269..afad928 100644 (file)
@@ -194,6 +194,7 @@ static struct option options[] = {
        { "version",    required_argument,      NULL, 'v' },
        { "undeflated", no_argument,            NULL, 'u' },
        { "nomux",      no_argument,            NULL, 'n' },
+       { "longlived",  no_argument,            NULL, 'l' },
        { NULL, 0, 0, 0 }
 };
 
@@ -208,6 +209,7 @@ int main(int argc, char **argv)
        struct libwebsocket *wsi_dumb;
        int ietf_version = -1; /* latest */
        int mirror_lifetime = 0;
+       int longlived = 0;
 
        fprintf(stderr, "libwebsockets test client\n"
                        "(C) Copyright 2010-2013 Andy Green <andy@warmcat.com> "
@@ -217,7 +219,7 @@ int main(int argc, char **argv)
                goto usage;
 
        while (n >= 0) {
-               n = getopt_long(argc, argv, "nuv:khsp:d:", options, NULL);
+               n = getopt_long(argc, argv, "nuv:khsp:d:l", options, NULL);
                if (n < 0)
                        continue;
                switch (n) {
@@ -230,6 +232,9 @@ int main(int argc, char **argv)
                case 'p':
                        port = atoi(optarg);
                        break;
+               case 'l':
+                       longlived = 1;
+                       break;
                case 'k':
                        opts = LWS_WRITE_CLIENT_IGNORE_XOR_MASK;
                        break;
@@ -310,6 +315,9 @@ int main(int argc, char **argv)
                        }
 
                        mirror_lifetime = 10 + (random() & 1023);
+                       /* useful to test single connection stability */
+                       if (longlived)
+                               mirror_lifetime += 50000;
 
                        fprintf(stderr, "opened mirror connection with "
                                             "%d lifetime\n", mirror_lifetime);
@@ -340,6 +348,6 @@ usage:
        fprintf(stderr, "Usage: libwebsockets-test-client "
                                "<server address> [--port=<p>] "
                                "[--ssl] [-k] [-v <ver>] "
-                               "[-d <log bitfield>]\n");
+                               "[-d <log bitfield>] [-l]\n");
        return 1;
 }