]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
api: add id=all for the connections/cancel, issue #4937
authorJaroslav Kysela <perex@perex.cz>
Wed, 19 Dec 2018 11:36:02 +0000 (12:36 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 19 Dec 2018 11:37:18 +0000 (12:37 +0100)
src/api/api_status.c
src/tcp.c
src/tcp.h

index c8ac14e630dda0fecfff0d493829bba91b4d2e58..9b8e5c99a954c160e8f54fea11d93b3d684b51c6 100644 (file)
@@ -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;
index cf500eb2d46a38116576256020c70074280c0322..6a21bab962149e40af915454bd85459ac4a72815 100644 (file)
--- 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);
+}
+
 /*
  *
  */
index c88c3b19baead58784fa848dbc801841a7ab01b9..ea210600bd6cb803454072ba863176913e335ba2 100644 (file)
--- 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 );