PROX: print panic message on screen 35/69535/2
authorXavier Simonart <xavier.simonart@intel.com>
Sun, 12 Jan 2020 15:52:10 +0000 (16:52 +0100)
committerXavier Simonart <xavier.simonart@intel.com>
Wed, 29 Jan 2020 11:39:41 +0000 (12:39 +0100)
When PROX detects an error condition at startup, it calls PROX_PANIC
which prints an message before calling rte_panic to end the application.
If ncurses was already started, this results in the message being printed
in ncurses (and prox.log) then leaving ncurses; hence the message is usually
not visible to the user (until it open prox.log), giving the impression of an
unexpected crash.

With this fix, the error message is repeated after closing ncurses, hence the message
will be printed on stdout.
Note that it might also be printed twice on stdout if ncurses was not already started.

As part of this fix, prox.log is now properly closed.

Change-Id: If41875843f1a39bc715f4264b3992c3fa018394e
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
VNFs/DPPD-PROX/display.c
VNFs/DPPD-PROX/log.c
VNFs/DPPD-PROX/log.h
VNFs/DPPD-PROX/quit.h

index e1b8d8d..d81a40e 100644 (file)
@@ -669,6 +669,7 @@ void display_end(void)
        if (scr != NULL) {
                endwin();
        }
+       scr = NULL;
 }
 
 static void pps_print(WINDOW *dst_scr, int y, int x, uint64_t val, int is_blue)
index b07076d..2094c18 100644 (file)
@@ -81,6 +81,13 @@ void plog_init(const char *log_name, int log_name_pid)
        tsc_off = rte_rdtsc() + 2500000000;
 }
 
+void plog_end(void)
+{
+       if (fp)
+               fclose(fp);
+       fp = NULL;
+}
+
 int plog_set_lvl(int lvl)
 {
        if (lvl <= PROX_MAX_LOG_LVL) {
index a5dcf47..0d2fba1 100644 (file)
@@ -81,6 +81,7 @@ __attribute__((format(printf, 2, 3))) static inline int plogdx_dbg(__attribute__
 #endif
 
 void plog_init(const char *log_name, int log_name_pid);
+void plog_end(void);
 void file_print(const char *str);
 
 int plog_set_lvl(int lvl);
index d0bf8b9..c3cd056 100644 (file)
@@ -34,6 +34,8 @@
                if (cond) {                                             \
                        plog_info(__VA_ARGS__);                         \
                        display_end();                                  \
+                       plog_end();                                     \
+                       plog_info(__VA_ARGS__);                         \
                        if (prox_cfg.flags & DSF_DAEMON) {              \
                                pid_t ppid = getppid();                 \
                                plog_info("sending SIGUSR2 to %d\n", ppid);\