From cc8c79eb0f095ba2a476cf033ec209ed6237f1b5 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Thu, 2 May 2013 07:46:07 -0700 Subject: [PATCH] Added a more unique naming paradigm for remote console temporary log files to avoid potential collisions when multiple simulators may be running concurrently --- scp.c | 2 ++ sim_console.c | 7 ++++--- sim_defs.h | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/scp.c b/scp.c index b7cac770..f76cbe04 100644 --- a/scp.c +++ b/scp.c @@ -3146,6 +3146,8 @@ return SCPE_OK; t_stat set_default_cmd (int32 flg, char *cptr) { +if (sim_is_running) + return SCPE_INVREM; if ((!cptr) || (*cptr == 0)) return SCPE_2FARG; sim_trim_endspc(cptr); diff --git a/sim_console.c b/sim_console.c index 407f531b..d5ceb23e 100644 --- a/sim_console.c +++ b/sim_console.c @@ -350,7 +350,7 @@ static TMXR sim_rem_con_tmxr = { 0, 0, 0, NULL, NULL, &sim_remote_console };/* r static uint32 sim_rem_read_timeout = 30; /* seconds before automatic continue */ static int32 sim_rem_step_line = -1; /* step in progress on line # */ static t_bool sim_log_temp = FALSE; /* temporary log file active */ -#define SIM_REMOTE_TEMP_LOG "sim_remote_console.log" +static char sim_rem_con_temp_name[PATH_MAX+1]; /* SET REMOTE CONSOLE command */ @@ -650,7 +650,8 @@ for (i=(was_stepping ? sim_rem_step_line : 0); int32 save_quiet = sim_quiet; sim_quiet = 0; - sim_set_logon (0, SIM_REMOTE_TEMP_LOG); + sprintf (sim_rem_con_temp_name, "sim_remote_console_%d.temporary_log", (int)getpid()); + sim_set_logon (0, sim_rem_con_temp_name); sim_quiet = save_quiet; sim_log_temp = TRUE; } @@ -714,7 +715,7 @@ for (i=(was_stepping ? sim_rem_step_line : 0); sim_quiet = 0; sim_set_logoff (0, NULL); sim_quiet = save_quiet; - remove (SIM_REMOTE_TEMP_LOG); + remove (sim_rem_con_temp_name); sim_log_temp = FALSE; } tmxr_linemsg (lp, "Simulator Running..."); diff --git a/sim_defs.h b/sim_defs.h index 2ee9229a..38539103 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -118,6 +118,7 @@ #undef PACKED /* avoid macro name collision */ #undef ERROR /* avoid macro name collision */ #undef MEM_MAPPED /* avoid macro name collision */ +#include #endif /* avoid macro names collisions */