From cd90eccf4c0edc41a514084f1c505f2b95627785 Mon Sep 17 00:00:00 2001 From: Martin Vajnar Date: Thu, 30 Jul 2015 13:54:58 +0200 Subject: [PATCH] Fix echoserver's foreground mode es_logic() requires pointer to valid thread_context, but the pointer was only assigned properly when running echoserver as a background thread. Now the pointer is assigned in both cases, that is for running in background and foreground. --- rpp-test-sw/commands/cmd_echoserver.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/rpp-test-sw/commands/cmd_echoserver.c b/rpp-test-sw/commands/cmd_echoserver.c index 635249c..054f121 100644 --- a/rpp-test-sw/commands/cmd_echoserver.c +++ b/rpp-test-sw/commands/cmd_echoserver.c @@ -210,7 +210,7 @@ int cmd_do_init_es(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) err_t err = ERR_OK; uint8_t pindex; int thread_nr; - int command = 0; + int command = ES_COMMAND_RUN_FOREGROUND; unsigned int port_no = 0; int i; @@ -222,19 +222,19 @@ int cmd_do_init_es(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) /* Parse the "command line" arguments */ for (pindex = 1; param[pindex] != 0; pindex++) { if (strncmp(param[pindex], "-c", 3) == 0) { - if (command) { + if (command != ES_COMMAND_RUN_FOREGROUND) { rpp_sci_printf("More than single command are used\n"); return FAILURE; } command = ES_COMMAND_KILL_ALL_THREADS; } else if (strncmp(param[pindex], "-l", 3) == 0) { - if (command) { + if (command != ES_COMMAND_RUN_FOREGROUND) { rpp_sci_printf("More than single command are used\n"); return FAILURE; } command = ES_COMMAND_LIST_THREADS; } else if (strncmp(param[pindex], "-t", 3) == 0) { - if (command) { + if (command != ES_COMMAND_RUN_FOREGROUND) { rpp_sci_printf("More than single command are used\n"); return FAILURE; } @@ -249,14 +249,14 @@ int cmd_do_init_es(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) } /* Port number is mandatory for interactive or background-thread mode */ - if ((!command || command == ES_COMMAND_NEW_THREAD) && !port_no) + if (command == ES_COMMAND_RUN_FOREGROUND || command == ES_COMMAND_NEW_THREAD) { - rpp_sci_printf("Port number not set\n"); - return FAILURE; - } + if (!port_no) + { + rpp_sci_printf("Port number not set\n"); + return FAILURE; + } - /* Execute the particular command */ - if (command == ES_COMMAND_NEW_THREAD) { /* Is there any free preallocated thread handle? */ thread_nr = es_thread_handle_find_first_free(); if (thread_nr < 0) { @@ -266,7 +266,10 @@ int cmd_do_init_es(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) } thread_context = &es_threads[thread_nr]; thread_context->port_no = port_no; + } + /* Execute the particular command */ + if (command == ES_COMMAND_NEW_THREAD) { unsigned int thread_nr_tmp; thread_nr_tmp = (thread_nr % 100); thread_name[2] = (thread_nr_tmp/10) + '0'; -- 2.39.2