aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Morton <austinpmorton@gmail.com>2015-08-13 14:45:29 -0400
committerPaul Fertser <fercerpav@gmail.com>2015-09-28 08:01:02 +0100
commit8bffcc0cd4fd6a92c8f9bbb28ccc14e4b51a576a (patch)
tree9ee8a1ea972dbc0444852c45a755172056ccd8aa /src
parentd28ab08cfafb3ad7ff8dc539644883217e89f8c4 (diff)
downloadriscv-openocd-8bffcc0cd4fd6a92c8f9bbb28ccc14e4b51a576a.zip
riscv-openocd-8bffcc0cd4fd6a92c8f9bbb28ccc14e4b51a576a.tar.gz
riscv-openocd-8bffcc0cd4fd6a92c8f9bbb28ccc14e4b51a576a.tar.bz2
server: remove connection limit from tcl and telnet servers
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>
Diffstat (limited to 'src')
-rw-r--r--src/server/server.c9
-rw-r--r--src/server/server.h2
-rw-r--r--src/server/tcl_server.c2
-rw-r--r--src/server/telnet_server.c2
4 files changed, 10 insertions, 5 deletions
diff --git a/src/server/server.c b/src/server/server.c
index 7e90d89..24747f9 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -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) {
diff --git a/src/server/server.h b/src/server/server.h
index 34c870a..0615233 100644
--- a/src/server/server.h
+++ b/src/server/server.h
@@ -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 */
diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c
index 409567c..a4270a8 100644
--- a/src/server/tcl_server.c
+++ b/src/server/tcl_server.c
@@ -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);
}
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c
index 92d8c5e..2187dbe 100644
--- a/src/server/telnet_server.c
+++ b/src/server/telnet_server.c
@@ -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,