]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blobdiff - rpp-test-sw/commands/cmd_echoserver.c
Add the possibility to break echoserver running in foreground
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / cmd_echoserver.c
index 054f12130695cb3ff31e1e0ed9657376a8ee7e76..eadbc39d951a45cbc931a0d3729d75efd59283c0 100644 (file)
@@ -117,7 +117,7 @@ static void es_thread_terminate(struct es_thread_context *thread_context)
 }
 
 
-static void es_logic(void *data)
+static void es_logic(cmd_io_t *cmd_io, void *data)
 {
        struct es_thread_context *thread_context = (struct es_thread_context*)data;
        err_t err = ERR_OK;
@@ -140,7 +140,7 @@ static void es_logic(void *data)
                goto leave_clean;
        }
 
-       while (1) { /* keep-alive */
+       while (cmd_io == NULL || cmd_io->getc(cmd_io) < 0) { /* keep-alive */
                err = netconn_accept(thread_context->conn_listen, &thread_context->conn);
                if (err == ERR_OK) {
                        struct netbuf *netbuf;
@@ -192,7 +192,7 @@ static void es_thread(void *data)
        struct es_thread_context *thread_context = (struct es_thread_context*)data;
 
        /* Run the echoserver logic */
-       es_logic(data);
+       es_logic(NULL, data);
 
        /* It is mandatory to destroy the thread when leaving;
         * Be aware of the fact that we are terminating ourselves --
@@ -291,7 +291,7 @@ int cmd_do_init_es(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
 
        } else if (command == ES_COMMAND_RUN_FOREGROUND) {
                /* Run in the foreground */
-               es_logic((void *)thread_context);
+               es_logic(cmd_io, (void *)thread_context);
        } else if (command == ES_COMMAND_LIST_THREADS) {
                for (i = 0; i < MAX_THREADS_CNT; i++) {
                        if (es_threads[i].status == ES_THREAD_RUNNING) {