Make rigctld thread safe for vfo_mode and ext_resp and change other globals to thread_local for future reference

pull/123/head
Michael Black 2019-07-31 16:03:46 -05:00
rodzic 6d28b6b1b1
commit 3dce8b01d1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6599353EC683404D
7 zmienionych plików z 31 dodań i 36 usunięć

Wyświetl plik

@ -124,11 +124,11 @@ static const int have_rl = 1;
#endif
int interactive = 1; /* if no cmd on command line, switch to interactive */
int prompt = 1; /* Print prompt in rigctl */
int vfo_mode = 0; /* vfo_mode = 0 means target VFO is 'currVFO' */
thread_local int interactive = 1; /* if no cmd on command line, switch to interactive */
thread_local int prompt = 1; /* Print prompt in rigctl */
thread_local int vfo_mode = 0; /* vfo_mode = 0 means target VFO is 'currVFO' */
char send_cmd_term = '\r'; /* send_cmd termination char */
thread_local char send_cmd_term = '\r'; /* send_cmd termination char */
int main(int argc, char *argv[])
{

Wyświetl plik

@ -587,17 +587,12 @@ static int next_word(char *buffer, int argc, char *argv[], int newline)
})
extern int interactive;
extern int prompt;
extern int vfo_mode;
extern char send_cmd_term;
int ext_resp = 0;
unsigned char resp_sep = '\n'; /* Default response separator */
/* Note that vfo_mode and ext_resp are not thread safe
* So to run either a vfo_mode or ext_resp mode rigctld it needs to be
* on a separate rigctld instance on a different port. One port per vfo_mode/ext_resp combination for a maximum of 4 instances/ports to cover all 4 combos
* Significant rewrite to fix this for 1 instance
*/
extern thread_local int interactive;
extern thread_local int prompt;
extern thread_local int vfo_mode;
extern thread_local char send_cmd_term;
thread_local int ext_resp = 0;
thread_local unsigned char resp_sep = '\n'; /* Default response separator */
int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, sync_cb_t sync_cb)
{

Wyświetl plik

@ -128,11 +128,11 @@ static sig_atomic_t volatile ctrl_c;
static int volatile ctrl_c;
#endif
int interactive = 1; /* no cmd because of daemon */
int prompt = 0; /* Daemon mode for rigparse return string */
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
thread_local int interactive = 1; /* no cmd because of daemon */
thread_local int prompt = 0; /* Daemon mode for rigparse return string */
thread_local int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
char send_cmd_term = '\r'; /* send_cmd termination char */
thread_local char send_cmd_term = '\r'; /* send_cmd termination char */
#define MAXCONFLEN 128

Wyświetl plik

@ -137,11 +137,11 @@ static sig_atomic_t volatile ctrl_c;
static int volatile ctrl_c;
#endif
int interactive = 1; /* no cmd because of daemon */
int prompt = 0; /* Daemon mode for rigparse return string */
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
thread_local int interactive = 1; /* no cmd because of daemon */
thread_local int prompt = 0; /* Daemon mode for rigparse return string */
thread_local int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
char send_cmd_term = '\r'; /* send_cmd termination char */
thread_local char send_cmd_term = '\r'; /* send_cmd termination char */
const char *portno = "4532";
const char *src_addr = NULL; /* INADDR_ANY */

Wyświetl plik

@ -112,10 +112,10 @@ static const int have_rl = 1;
#endif
int interactive = 1; /* if no cmd on command line, switch to interactive */
int prompt = 1; /* Print prompt in rotctl */
thread_local int interactive = 1; /* if no cmd on command line, switch to interactive */
thread_local int prompt = 1; /* Print prompt in rotctl */
char send_cmd_term = '\r'; /* send_cmd termination char */
thread_local char send_cmd_term = '\r'; /* send_cmd termination char */
int main(int argc, char *argv[])

Wyświetl plik

@ -495,11 +495,11 @@ static int next_word(char *buffer, int argc, char *argv[], int newline)
})
extern int interactive;
extern int prompt;
extern char send_cmd_term;
int ext_resp = 0;
unsigned char resp_sep = '\n'; /* Default response separator */
extern thread_local int interactive;
extern thread_local int prompt;
extern thread_local char send_cmd_term;
thread_local int ext_resp = 0;
thread_local unsigned char resp_sep = '\n'; /* Default response separator */
int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc)

Wyświetl plik

@ -103,13 +103,13 @@ static struct option long_options[] =
{0, 0, 0, 0}
};
int interactive = 1; /* no cmd because of daemon */
int prompt = 0 ; /* Daemon mode for rigparse return string */
thread_local int interactive = 1; /* no cmd because of daemon */
thread_local int prompt = 0 ; /* Daemon mode for rigparse return string */
const char *portno = "4533";
const char *src_addr = NULL; /* INADDR_ANY */
thread_local const char *portno = "4533";
thread_local const char *src_addr = NULL; /* INADDR_ANY */
char send_cmd_term = '\r'; /* send_cmd termination char */
thread_local char send_cmd_term = '\r'; /* send_cmd termination char */
#define MAXCONFLEN 128