From: Jaroslav Kysela Date: Wed, 19 Dec 2018 11:36:02 +0000 (+0100) Subject: api: add id=all for the connections/cancel, issue #4937 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a7b56a269319397de30976bccb8f48f8b5b6911;p=thirdparty%2Ftvheadend.git api: add id=all for the connections/cancel, issue #4937 --- diff --git a/src/api/api_status.c b/src/api/api_status.c index c8ac14e63..9b8e5c99a 100644 --- a/src/api/api_status.c +++ b/src/api/api_status.c @@ -101,9 +101,17 @@ api_connections_cancel htsmsg_field_t *f; htsmsg_t *ids; uint32_t id; + const char *s; if (!(f = htsmsg_field_find(args, "id"))) return EINVAL; + s = htsmsg_field_get_str(f); + if (s && strcmp(s, "all") == 0) { + tvh_mutex_lock(&global_lock); + tcp_connection_cancel_all(); + tvh_mutex_unlock(&global_lock); + return 0; + } if (!(ids = htsmsg_field_get_list(f))) if (htsmsg_field_get_u32(f, &id)) return EINVAL; diff --git a/src/tcp.c b/src/tcp.c index cf500eb2d..6a21bab96 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -665,6 +665,21 @@ tcp_connection_cancel(uint32_t id) } } +/** + * + */ +void +tcp_connection_cancel_all(void) +{ + tcp_server_launch_t *tsl; + + lock_assert(&global_lock); + + LIST_FOREACH(tsl, &tcp_server_active, alink) + if (tsl->ops.cancel) + tsl->ops.cancel(tsl->opaque); +} + /* * */ diff --git a/src/tcp.h b/src/tcp.h index c88c3b19b..ea210600b 100644 --- a/src/tcp.h +++ b/src/tcp.h @@ -160,6 +160,7 @@ void *tcp_connection_launch(int fd, int streaming, struct access *aa); void tcp_connection_land(void *tcp_id); void tcp_connection_cancel(uint32_t id); +void tcp_connection_cancel_all(void); htsmsg_t *tcp_server_connections ( void );