diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index c96be1034..bb4c1317d 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -3509,7 +3509,7 @@ static int gdb_target_start(struct target *target, const char *port) ret = add_service("gdb", port, target->gdb_max_connections, &gdb_new_connection, &gdb_input, - &gdb_connection_closed, gdb_service); + &gdb_connection_closed, gdb_service, NULL); /* initialize all targets gdb service with the same pointer */ { struct target_list *head; diff --git a/src/server/server.c b/src/server/server.c index e53f37d0b..114af7632 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -210,7 +210,8 @@ int add_service(char *name, new_connection_handler_t new_connection_handler, input_handler_t input_handler, connection_closed_handler_t connection_closed_handler, - void *priv) + void *priv, + struct service **new_service) { struct service *c, **p; struct hostent *hp; @@ -346,6 +347,10 @@ int add_service(char *name, ; *p = c; + /* if new_service is not NULL, return the created service into it */ + if (new_service) + *new_service = c; + return ERROR_OK; } diff --git a/src/server/server.h b/src/server/server.h index ff2ada9cb..99f5fe2ed 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -77,7 +77,7 @@ struct service { int add_service(char *name, const char *port, int max_connections, new_connection_handler_t new_connection_handler, input_handler_t in_handler, connection_closed_handler_t close_handler, - void *priv); + void *priv, struct service **new_service); int remove_service(const char *name, const char *port); int server_host_os_entry(void); diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c index 1ecb827a1..07213ae79 100644 --- a/src/server/tcl_server.c +++ b/src/server/tcl_server.c @@ -285,7 +285,7 @@ int tcl_init(void) return add_service("tcl", tcl_port, CONNECTION_LIMIT_UNLIMITED, &tcl_new_connection, &tcl_input, - &tcl_closed, NULL); + &tcl_closed, NULL, NULL); } COMMAND_HANDLER(handle_tcl_port_command) diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 407ab68ae..4f88d3a54 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -694,7 +694,7 @@ int telnet_init(char *banner) int ret = add_service("telnet", telnet_port, CONNECTION_LIMIT_UNLIMITED, telnet_new_connection, telnet_input, telnet_connection_closed, - telnet_service); + telnet_service, NULL); if (ret != ERROR_OK) { free(telnet_service); diff --git a/src/target/openrisc/jsp_server.c b/src/target/openrisc/jsp_server.c index 4dbe63527..b4b25665d 100644 --- a/src/target/openrisc/jsp_server.c +++ b/src/target/openrisc/jsp_server.c @@ -207,7 +207,8 @@ int jsp_init(struct or1k_jtag *jtag_info, char *banner) jsp_new_connection, jsp_input, jsp_connection_closed, - jsp_service); + jsp_service, + NULL); } COMMAND_HANDLER(handle_jsp_port_command)