server/server: Add ability to remove services
Add the ability to remove services while OpenOCD is running. Change-Id: I4067916fda6d03485463fa40901b40484d94e24e Signed-off-by: Marc Schink <openocd-dev@marcschink.de> Reviewed-on: http://openocd.zylin.com/4054 Tested-by: jenkins Reviewed-by: Fredrik Hederstierna <fredrik@hederstierna.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
parent
9ec306e95a
commit
9bcd2b2fa3
|
@ -364,6 +364,35 @@ static void remove_connections(struct service *service)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int remove_service(const char *name, const char *port)
|
||||||
|
{
|
||||||
|
struct service *tmp;
|
||||||
|
struct service *prev;
|
||||||
|
|
||||||
|
prev = services;
|
||||||
|
|
||||||
|
for (tmp = services; tmp; prev = tmp, tmp = tmp->next) {
|
||||||
|
if (!strcmp(tmp->name, name) && !strcmp(tmp->port, port)) {
|
||||||
|
remove_connections(tmp);
|
||||||
|
|
||||||
|
if (tmp == services)
|
||||||
|
services = tmp->next;
|
||||||
|
else
|
||||||
|
prev->next = tmp->next;
|
||||||
|
|
||||||
|
if (tmp->type != CONNECTION_STDINOUT)
|
||||||
|
close_socket(tmp->fd);
|
||||||
|
|
||||||
|
free(tmp->priv);
|
||||||
|
free_service(tmp);
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static int remove_services(void)
|
static int remove_services(void)
|
||||||
{
|
{
|
||||||
struct service *c = services;
|
struct service *c = services;
|
||||||
|
|
|
@ -78,6 +78,7 @@ int add_service(char *name, const char *port,
|
||||||
int max_connections, new_connection_handler_t new_connection_handler,
|
int max_connections, new_connection_handler_t new_connection_handler,
|
||||||
input_handler_t in_handler, connection_closed_handler_t close_handler,
|
input_handler_t in_handler, connection_closed_handler_t close_handler,
|
||||||
void *priv);
|
void *priv);
|
||||||
|
int remove_service(const char *name, const char *port);
|
||||||
|
|
||||||
int server_preinit(void);
|
int server_preinit(void);
|
||||||
int server_init(struct command_context *cmd_ctx);
|
int server_init(struct command_context *cmd_ctx);
|
||||||
|
|
Loading…
Reference in New Issue