session: basic fifo-tuning-logic
[vpp.git] / src / vpp / app / vppctl.c
index f81a0ce..31c9e43 100644 (file)
@@ -147,6 +147,7 @@ main (int argc, char *argv[])
   u8 *cmd = 0;
   int do_quit = 0;
   int is_interactive = 0;
+  int acked = 1;               /* counts messages from VPP; starts at 1 */
   int sent_ttype = 0;
 
 
@@ -156,7 +157,7 @@ main (int argc, char *argv[])
   argc--;
   argv++;
 
-  if (argc > 1 && strcmp (argv[0], "-s") == 0)
+  if (argc > 1 && strncmp (argv[0], "-s", 2) == 0)
     {
       s->config = argv[1];
       argc -= 2;
@@ -179,7 +180,7 @@ main (int argc, char *argv[])
   if (is_interactive)
     {
       /* Capture terminal resize events */
-      memset (&sa, 0, sizeof (struct sigaction));
+      clib_memset (&sa, 0, sizeof (struct sigaction));
       sa.sa_handler = signal_handler_winch;
       if (sigaction (SIGWINCH, &sa, 0) < 0)
        {
@@ -314,7 +315,10 @@ main (int argc, char *argv[])
                    }
 
                  while (q < (p + len) && !*q)
-                   q++;
+                   {
+                     q++;
+                     acked++;  /* every NUL is an acknowledgement */
+                   }
                  len -= q - p;
                  p = q;
                }
@@ -322,7 +326,7 @@ main (int argc, char *argv[])
              vec_reset_length (str);
            }
 
-         if (do_quit)
+         if (do_quit && do_quit < acked)
            {
              /* Ask the other end to close the connection */
              clib_socket_tx_add_formatted (s, "quit\n");
@@ -339,7 +343,7 @@ main (int argc, char *argv[])
              clib_socket_tx_add_formatted (s, "%s\n", cmd);
              clib_socket_tx (s);
              vec_free (cmd);
-             do_quit = 1;
+             do_quit = acked;  /* quit after the next response */
            }
        }
       else