vlib: align stack on OS page size
[vpp.git] / src / vlib / unix / main.c
index 45b12cd..ed909b6 100755 (executable)
@@ -61,7 +61,6 @@ char *vlib_default_runtime_dir = "vlib";
 
 unix_main_t unix_main;
 clib_file_main_t file_main;
-vlib_physmem_main_t physmem_main;
 
 static clib_error_t *
 unix_main_init (vlib_main_t * vm)
@@ -89,12 +88,18 @@ unsetup_signal_handlers (int sig)
     dangerous to vec_resize it when crashing, mheap itself might have been
     corruptted already */
 static u8 *syslog_msg = 0;
+static int last_signum = 0;
+static uword last_faulting_address = 0;
 
 static void
 unix_signal_handler (int signum, siginfo_t * si, ucontext_t * uc)
 {
   uword fatal = 0;
 
+  /* These come in handy when looking at core files from optimized images */
+  last_signum = signum;
+  last_faulting_address = (uword) si->si_addr;
+
   syslog_msg = format (syslog_msg, "received signal %U, PC %U",
                       format_signal, signum, format_ucontext_pc, uc);
 
@@ -105,11 +110,16 @@ unix_signal_handler (int signum, siginfo_t * si, ucontext_t * uc)
     {
       /* these (caught) signals cause the application to exit */
     case SIGTERM:
-      if (unix_main.vlib_main->main_loop_exit_set)
+      /*
+       * Ignore SIGTERM if it's sent before we're ready.
+       */
+      if (unix_main.vlib_main && unix_main.vlib_main->main_loop_exit_set)
        {
          syslog (LOG_ERR | LOG_DAEMON, "received SIGTERM, exiting...");
          unix_main.vlib_main->main_loop_exit_now = 1;
        }
+      else
+       syslog (LOG_ERR | LOG_DAEMON, "IGNORE early SIGTERM...");
       break;
       /* fall through */
     case SIGQUIT:
@@ -554,10 +564,11 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
  *
  * @cfgcmd{runtime-dir}
  * Define directory where VPP is going to store all runtime files.
- * Default is /run/vpp.
+ * Default is /run/vpp when running as root, /run/user/<UID>/vpp if running as
+ * an unprivileged user.
  *
  * @cfgcmd{cli-listen, &lt;address:port&gt;}
- * Bind the CLI to listen at the address and port given. @clocalhost
+ * Bind the CLI to listen at the address and port given. @c localhost
  * on TCP port @c 5002, given as <tt>cli-listen localhost:5002</tt>,
  * is typical.
  *
@@ -569,7 +580,7 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
  * Configure the CLI prompt to be @c string.
  *
  * @cfgcmd{cli-history-limit, &lt;nn&gt;}
- * Limit commmand history to @c nn  lines. A value of @c 0
+ * Limit command history to @c nn  lines. A value of @c 0
  * disables command history. Default value: @c 50
  *
  * @cfgcmd{cli-no-banner}
@@ -581,6 +592,12 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
  * @cfgcmd{cli-pager-buffer-limit, &lt;nn&gt;}
  * Limit pager buffer to @c nn lines of output.
  * A value of @c 0 disables the pager. Default value: @c 100000
+ *
+ * @cfgcmd{gid, &lt;nn&gt;}
+ * Set the effective gid under which the vpp process is to run.
+ *
+ * @cfgcmd{poll-sleep-usec, &lt;nn&gt;}
+ * Set a fixed poll sleep interval between main loop polls.
 ?*/
 VLIB_EARLY_CONFIG_FUNCTION (unix_config, "unix");
 
@@ -615,7 +632,7 @@ vlib_thread_stack_init (uword thread_index)
 {
   vec_validate (vlib_thread_stacks, thread_index);
   vlib_thread_stacks[thread_index] = clib_mem_alloc_aligned
-    (VLIB_THREAD_STACK_SIZE, VLIB_THREAD_STACK_SIZE);
+    (VLIB_THREAD_STACK_SIZE, clib_mem_get_page_size ());
 
   /*
    * Disallow writes to the bottom page of the stack, to