X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fserver%2Fserver.c;h=7a3c890d082496bcad91d2905f8f9a5da2da3b43;hb=0c2f8b6eb8f4b379aa0c78caba73ec1ebaae8414;hp=01d91d30fe5f92f90ac4b5dad0528830ef17b2a0;hpb=45de3b1fbe875de7ed322d76bb517bdb48e20a5a;p=openocd.git diff --git a/src/server/server.c b/src/server/server.c index 01d91d30fe..7a3c890d08 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -29,6 +29,7 @@ #include "server.h" #include +#include #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 */ @@ -200,7 +204,7 @@ int add_service(char *name, const char *port, int max_connections, new_connectio } else { char *end; - strtol(c->port, &end, 0); + portnumber = strtol(c->port, &end, 0); if (!*end && (parse_long(c->port, &portnumber) == ERROR_OK)) { c->portnumber = portnumber; @@ -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; }