server: fix confusing wording for incoming tcp connections
[openocd.git] / src / server / server.c
index 16f751079b017ed9f7c8432b6c2f3882326d5bf7..5169319c54905d0b8886ae7ccebf683374652189 100644 (file)
@@ -21,7 +21,7 @@
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -80,11 +80,12 @@ static int add_connection(struct service *service, struct command_context *cmd_c
                        (char *)&flag,                  /* the cast is historical cruft */
                        sizeof(int));                   /* length of option value */
 
-               LOG_INFO("accepting '%s' connection from %s", service->name, service->port);
+               LOG_INFO("accepting '%s' connection on tcp/%s", service->name, service->port);
                retval = service->new_connection(c);
                if (retval != ERROR_OK) {
                        close_socket(c->fd);
                        LOG_ERROR("attempted '%s' connection rejected", service->name);
+                       command_done(c->cmd_ctx);
                        free(c);
                        return retval;
                }
@@ -104,6 +105,7 @@ static int add_connection(struct service *service, struct command_context *cmd_c
                retval = service->new_connection(c);
                if (retval != ERROR_OK) {
                        LOG_ERROR("attempted '%s' connection rejected", service->name);
+                       command_done(c->cmd_ctx);
                        free(c);
                        return retval;
                }
@@ -124,6 +126,7 @@ static int add_connection(struct service *service, struct command_context *cmd_c
                retval = service->new_connection(c);
                if (retval != ERROR_OK) {
                        LOG_ERROR("attempted '%s' connection rejected", service->name);
+                       command_done(c->cmd_ctx);
                        free(c);
                        return retval;
                }
@@ -300,14 +303,14 @@ static int remove_services(void)
                struct service *next = c->next;
 
                if (c->name)
-                       free((void *)c->name);
+                       free(c->name);
 
                if (c->type == CONNECTION_PIPE) {
                        if (c->fd != -1)
                                close(c->fd);
                }
                if (c->port)
-                       free((void *)c->port);
+                       free(c->port);
 
                if (c->priv)
                        free(c->priv);
@@ -462,9 +465,10 @@ int server_loop(struct command_context *command_context)
                                                retval = service->input(c);
                                                if (retval != ERROR_OK) {
                                                        struct connection *next = c->next;
-                                                       if (service->type == CONNECTION_PIPE) {
+                                                       if (service->type == CONNECTION_PIPE ||
+                                                                       service->type == CONNECTION_STDINOUT) {
                                                                /* if connection uses a pipe then
-                                                                *shutdown openocd on error */
+                                                                * shutdown openocd on error */
                                                                shutdown_openocd = 1;
                                                        }
                                                        remove_connection(service, c);
@@ -608,7 +612,7 @@ int server_register_commands(struct command_context *cmd_ctx)
        return register_commands(cmd_ctx, NULL, server_command_handlers);
 }
 
-SERVER_PORT_COMMAND()
+COMMAND_HELPER(server_port_command, unsigned short *out)
 {
        switch (CMD_ARGC) {
                case 0:
@@ -627,7 +631,7 @@ SERVER_PORT_COMMAND()
        return ERROR_OK;
 }
 
-SERVER_PIPE_COMMAND()
+COMMAND_HELPER(server_pipe_command, char **out)
 {
        switch (CMD_ARGC) {
                case 0:
@@ -635,9 +639,12 @@ SERVER_PIPE_COMMAND()
                        break;
                case 1:
                {
-                       const char *t = strdup(CMD_ARGV[0]);
-                       free((void *)*out);
-                       *out = t;
+                       if (CMD_CTX->mode == COMMAND_EXEC) {
+                               LOG_WARNING("unable to change server port after init");
+                               return ERROR_COMMAND_ARGUMENT_INVALID;
+                       }
+                       free(*out);
+                       *out = strdup(CMD_ARGV[0]);
                        break;
                }
                default:

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)