cmd: add missing usage vars
[fw/openocd] / src / server / server.c
index 1feb744b46569e9fa3ffcf9ef9bee96629c4e676..7a3c890d082496bcad91d2905f8f9a5da2da3b43 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "server.h"
 #include <target/target.h>
+#include <target/target_request.h>
 #include "openocd.h"
 #include "tcl_server.h"
 #include "telnet_server.h"
@@ -70,8 +71,11 @@ static int add_connection(struct service *service, struct command_context *cmd_c
                c->fd_out = c->fd;
 
                /* This increases performance dramatically for e.g. GDB load which
-                * does not have a sliding window protocol. */
-               retval = setsockopt(c->fd,      /* socket affected */
+                * does not have a sliding window protocol. 
+                *
+                * Ignore errors from this fn as it probably just means less performance
+                */
+               setsockopt(c->fd,       /* socket affected */
                                IPPROTO_TCP,            /* set option at TCP level */
                                TCP_NODELAY,            /* name of option */
                                (char *)&flag,          /* the cast is historical cruft */
@@ -306,7 +310,7 @@ static int remove_services(void)
                struct service *next = c->next;
 
                if (c->name)
-                       free(c->name);
+                       free((void *)c->name);
 
                if (c->type == CONNECTION_PIPE)
                {
@@ -443,6 +447,13 @@ int server_loop(struct command_context *command_context)
                        poll_ok = true;
                }
 
+               /* This is a simple back-off algorithm where we immediately
+                * re-poll if we did something this time around.
+                *
+                * This greatly improves performance of DCC.
+                */
+               poll_ok = poll_ok || target_got_message();
+
                for (service = services; service; service = service->next)
                {
                        /* handle new connections on listeners */
@@ -476,7 +487,8 @@ int server_loop(struct command_context *command_context)
                                {
                                        if ((FD_ISSET(c->fd, &read_fds)) || c->input_pending)
                                        {
-                                               if ((retval = service->input(c)) != ERROR_OK)
+                                               retval = service->input(c);
+                                               if (retval != ERROR_OK)
                                                {
                                                        struct connection *next = c->next;
                                                        if (service->type == CONNECTION_PIPE)
@@ -485,7 +497,7 @@ int server_loop(struct command_context *command_context)
                                                                shutdown_openocd = 1;
                                                        }
                                                        remove_connection(service, c);
-                                                       LOG_INFO("dropped '%s' connection - error %d", service->name, retval);
+                                                       LOG_INFO("dropped '%s' connection", service->name);
                                                        c = next;
                                                        continue;
                                                }
@@ -613,6 +625,7 @@ static const struct command_registration server_command_handlers[] = {
                .name = "shutdown",
                .handler = &handle_shutdown_command,
                .mode = COMMAND_ANY,
+               .usage = "",
                .help = "shut the server down",
        },
        COMMAND_REGISTRATION_DONE
@@ -645,7 +658,7 @@ SERVER_PORT_COMMAND()
                break;
        }
        default:
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
        return ERROR_OK;
 }
@@ -664,7 +677,7 @@ SERVER_PIPE_COMMAND()
                break;
        }
        default:
-               return ERROR_INVALID_ARGUMENTS;
+               return ERROR_COMMAND_SYNTAX_ERROR;
        }
        return ERROR_OK;
 }