server: remove connection limit from tcl and telnet servers 37/2937/2
authorAustin Morton <austinpmorton@gmail.com>
Thu, 13 Aug 2015 18:45:29 +0000 (14:45 -0400)
committerPaul Fertser <fercerpav@gmail.com>
Mon, 28 Sep 2015 07:01:02 +0000 (08:01 +0100)
Add constant CONNECTION_LIMIT_UNLIMITED which indicates a service
has no connection limit

Change-Id: I008d31264010c25fa44ca74eb6d5740eca38bee1
Signed-off-by: Austin Morton <austinpmorton@gmail.com>
Reviewed-on: http://openocd.zylin.com/2937
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
src/server/server.c
src/server/server.h
src/server/tcl_server.c
src/server/telnet_server.c

index 7e90d89fd2d6af7d1a3cc89b80a70186e84a6c6e..24747f9387dc36258a3374042c64a13ad931227d 100644 (file)
@@ -145,7 +145,8 @@ static int add_connection(struct service *service, struct command_context *cmd_c
                ;
        *p = c;
 
-       service->max_connections--;
+       if (service->max_connections != CONNECTION_LIMIT_UNLIMITED)
+               service->max_connections--;
 
        return ERROR_OK;
 }
@@ -172,7 +173,9 @@ static int remove_connection(struct service *service, struct connection *connect
                        *p = c->next;
                        free(c);
 
-                       service->max_connections++;
+                       if (service->max_connections != CONNECTION_LIMIT_UNLIMITED)
+                               service->max_connections++;
+
                        break;
                }
 
@@ -446,7 +449,7 @@ int server_loop(struct command_context *command_context)
                        /* handle new connections on listeners */
                        if ((service->fd != -1)
                            && (FD_ISSET(service->fd, &read_fds))) {
-                               if (service->max_connections > 0)
+                               if (service->max_connections != 0)
                                        add_connection(service, command_context);
                                else {
                                        if (service->type == CONNECTION_TCP) {
index 34c870aabc4a836e07d65ac0225f8b5a63d482f7..061523346caa52d8e22404ead24ffb5852fc0870 100644 (file)
@@ -39,6 +39,8 @@ enum connection_type {
        CONNECTION_STDINOUT
 };
 
+#define CONNECTION_LIMIT_UNLIMITED             (-1)
+
 struct connection {
        int fd;
        int fd_out;     /* When using pipes we're writing to a different fd */
index 409567c9d90e9e515cee078dea3b3048409daf4e..a4270a8445667445a448730e8d627ad455342d29 100644 (file)
@@ -250,7 +250,7 @@ int tcl_init(void)
                return ERROR_OK;
        }
 
-       return add_service("tcl", tcl_port, 1,
+       return add_service("tcl", tcl_port, CONNECTION_LIMIT_UNLIMITED,
                &tcl_new_connection, &tcl_input,
                &tcl_closed, NULL);
 }
index 92d8c5ea6903486387b2a6fe34f28679ed27a1e9..2187dbe280bdf71585ad2905acd40cd5f6194879 100644 (file)
@@ -625,7 +625,7 @@ int telnet_init(char *banner)
 
        return add_service("telnet",
                telnet_port,
-               1,
+               CONNECTION_LIMIT_UNLIMITED,
                telnet_new_connection,
                telnet_input,
                telnet_connection_closed,

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)