]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Add sender subcommand "status".
authorAndre Noll <maan@systemlinux.org>
Thu, 19 Jun 2014 09:46:31 +0000 (11:46 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 14 Aug 2014 06:35:41 +0000 (08:35 +0200)
Currently, the si (server info) command prints information about each
sender, like the number of connected clients and the access control
lists. As this information is related to senders, the sender command
seems to be a better fit.

This commit introduces the new sender subcommand "status" for this
purpose and changes com_si() to not print the sender information any
more, making the output of com_si() bounded.  It also renames the
->info() function of the senders to ->status() to make it clear that
this function is related to the new status subcommand.

The Networking paragraph of the manual is adjusted accordingly and
now contains an example of the status command.

command.c
dccp_send.c
http_send.c
send.h
send_common.c
server.cmd
udp_send.c
web/manual.m4

index 92002c340e62c0593bc2b534193d8fecb1ea997b..585bb31c54b8df7395c8330f7f4d6e7b15890ad8 100644 (file)
--- a/command.c
+++ b/command.c
@@ -344,7 +344,10 @@ static int com_sender(struct command_context *cc)
        if (ret < 0) {
                if (scd.sender_num < 0)
                        return ret;
        if (ret < 0) {
                if (scd.sender_num < 0)
                        return ret;
-               msg = senders[scd.sender_num].help();
+               if (strcmp(cc->argv[2], "status") == 0)
+                       msg = senders[scd.sender_num].status();
+               else
+                       msg = senders[scd.sender_num].help();
                return send_sb(&cc->scc, msg, strlen(msg), SBD_OUTPUT, false);
        }
 
                return send_sb(&cc->scc, msg, strlen(msg), SBD_OUTPUT, false);
        }
 
@@ -374,17 +377,12 @@ static int com_sender(struct command_context *cc)
 /* server info */
 static int com_si(struct command_context *cc)
 {
 /* server info */
 static int com_si(struct command_context *cc)
 {
-       int i, ret;
-       char *msg, *ut, *sender_info = NULL;
+       int ret;
+       char *msg, *ut;
 
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
        mutex_lock(mmd_mutex);
 
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
        mutex_lock(mmd_mutex);
-       for (i = 0; senders[i].name; i++) {
-               char *info = senders[i].info();
-               sender_info = para_strcat(sender_info, info);
-               free(info);
-       }
        ut = get_server_uptime_str(now);
        ret = xasprintf(&msg,
                "up: %s\nplayed: %u\n"
        ut = get_server_uptime_str(now);
        ret = xasprintf(&msg,
                "up: %s\nplayed: %u\n"
@@ -392,8 +390,7 @@ static int com_si(struct command_context *cc)
                "afs_pid: %d\n"
                "connections (active/accepted/total): %u/%u/%u\n"
                "current loglevel: %s\n"
                "afs_pid: %d\n"
                "connections (active/accepted/total): %u/%u/%u\n"
                "current loglevel: %s\n"
-               "supported audio formats: %s\n"
-               "%s",
+               "supported audio formats: %s\n",
                ut, mmd->num_played,
                (int)getppid(),
                (int)mmd->afs_pid,
                ut, mmd->num_played,
                (int)getppid(),
                (int)mmd->afs_pid,
@@ -401,12 +398,10 @@ static int com_si(struct command_context *cc)
                mmd->num_commands,
                mmd->num_connects,
                conf.loglevel_arg,
                mmd->num_commands,
                mmd->num_connects,
                conf.loglevel_arg,
-               AUDIO_FORMAT_HANDLERS,
-               sender_info
+               AUDIO_FORMAT_HANDLERS
        );
        mutex_unlock(mmd_mutex);
        free(ut);
        );
        mutex_unlock(mmd_mutex);
        free(ut);
-       free(sender_info);
        return send_sb(&cc->scc, msg, ret, SBD_OUTPUT, false);
 }
 
        return send_sb(&cc->scc, msg, ret, SBD_OUTPUT, false);
 }
 
index 1e95aac6401cf43cf7368a0ad61a2c37e6428587..f80787d259e8d72861d51296f5042d6138580ba8 100644 (file)
@@ -199,13 +199,13 @@ static const char *dccp_list_available_ccids(void)
        return list;
 }
 
        return list;
 }
 
-static char *dccp_info(void)
+static char *dccp_status(void)
 {
 {
-       char *info = get_sender_info(dss, "dccp");
-       char *ret  = make_message("%s" "\tsupported ccids: %s\n",
-                                 info, dccp_list_available_ccids());
-       free(info);
-       return ret;
+       char *status = generic_sender_status(dss, "dccp");
+       char *result = make_message("%ssupported ccids: %s\n", status,
+               dccp_list_available_ccids());
+       free(status);
+       return result;
 }
 
 /**
 }
 
 /**
@@ -220,7 +220,7 @@ void dccp_send_init(struct sender *s)
 {
        int ret, k, n;
 
 {
        int ret, k, n;
 
-       s->info = dccp_info;
+       s->status = dccp_status;
        s->send = NULL;
        s->pre_select = dccp_pre_select;
        s->post_select = dccp_post_select;
        s->send = NULL;
        s->pre_select = dccp_pre_select;
        s->post_select = dccp_post_select;
index 3e9c95393c5120c82bd91cc4bd84e5ea9c56f60c..aba61e9de04da67f0c022a751f3caa4689326354 100644 (file)
@@ -235,9 +235,9 @@ static int http_com_allow(struct sender_command_data *scd)
        return 1;
 }
 
        return 1;
 }
 
-static char *http_info(void)
+static char *http_status(void)
 {
 {
-       return get_sender_info(hss, "http");
+       return generic_sender_status(hss, "http");
 }
 
 /**
 }
 
 /**
@@ -251,7 +251,7 @@ static char *http_info(void)
 void http_send_init(struct sender *s)
 {
        int ret;
 void http_send_init(struct sender *s)
 {
        int ret;
-       s->info = http_info;
+       s->status = http_status;
        s->send = http_send;
        s->pre_select = http_pre_select;
        s->post_select = http_post_select;
        s->send = http_send;
        s->pre_select = http_pre_select;
        s->post_select = http_post_select;
diff --git a/send.h b/send.h
index f577c9a7153980dbbfc9cd84ab744843d92c5084..0736b1bc18105d4001263dc383b7fb50d22d622b 100644 (file)
--- a/send.h
+++ b/send.h
@@ -45,7 +45,7 @@ struct sender {
         *
         * The result must be dynamically allocated and is freed by the caller.
         */
         *
         * The result must be dynamically allocated and is freed by the caller.
         */
-       char* (*info)(void);
+       char* (*status)(void);
        /**
         * The send-hook.
         *
        /**
         * The send-hook.
         *
@@ -179,7 +179,7 @@ void shutdown_client(struct sender_client *sc, struct sender_status *ss);
 void shutdown_clients(struct sender_status *ss);
 void init_sender_status(struct sender_status *ss, char **access_arg, int num_access_args,
        int port, int max_clients, int default_deny);
 void shutdown_clients(struct sender_status *ss);
 void init_sender_status(struct sender_status *ss, char **access_arg, int num_access_args,
        int port, int max_clients, int default_deny);
-char *get_sender_info(struct sender_status *ss, const char *name);
+char *generic_sender_status(struct sender_status *ss, const char *name);
 
 void generic_com_allow(struct sender_command_data *scd,
                struct sender_status *ss);
 
 void generic_com_allow(struct sender_command_data *scd,
                struct sender_status *ss);
index 0baac3a6f5c9713e810f97b53d13275f4178c610..f75b9a076e14e6371ce82752ffc814c4128d8299 100644 (file)
@@ -159,7 +159,7 @@ void init_sender_status(struct sender_status *ss, char **access_arg,
  *
  * \return The string printed in the "si" command.
  */
  *
  * \return The string printed in the "si" command.
  */
-char *get_sender_info(struct sender_status *ss, const char *name)
+char *generic_sender_status(struct sender_status *ss, const char *name)
 {
        char *clnts = NULL, *ret;
        struct sender_client *sc, *tmp_sc;
 {
        char *clnts = NULL, *ret;
        struct sender_client *sc, *tmp_sc;
@@ -171,14 +171,12 @@ char *get_sender_info(struct sender_status *ss, const char *name)
                clnts = tmp;
        }
        ret = make_message(
                clnts = tmp;
        }
        ret = make_message(
-               "%s sender:\n"
-               "\tstatus: %s\n"
-               "\tport: %s\n"
-               "\tnumber of connected clients: %d\n"
-               "\tmaximal number of clients: %d%s\n"
-               "\tconnected clients: %s\n"
-               "\taccess %s list: %s\n",
-               name,
+               "status: %s\n"
+               "port: %s\n"
+               "number of connected clients: %d\n"
+               "maximal number of clients: %d%s\n"
+               "connected clients: %s\n"
+               "access %s list: %s\n",
                (ss->listen_fd >= 0)? "on" : "off",
                stringify_port(ss->port, strcmp(name, "http") ? "dccp" : "tcp"),
                ss->num_clients,
                (ss->listen_fd >= 0)? "on" : "off",
                stringify_port(ss->port, strcmp(name, "http") ? "dccp" : "tcp"),
                ss->num_clients,
index eba992f86d8964de3fbea8a997ea5350c30dbfcf..ebe372b7da67442c11dd2854300aa867fed0408a 100644 (file)
@@ -75,7 +75,7 @@ U: sender [s cmd [arguments]]
 H: Send a command to a specific sender. The following commands are available, but
 H: not all senders support every command.
 H:
 H: Send a command to a specific sender. The following commands are available, but
 H: not all senders support every command.
 H:
-H:     help, on, off, add, delete, allow, deny.
+H:     help, on, off, add, delete, allow, deny, status.
 H:
 H: The help command prints the help text of the given sender. If no command is
 H: given the list of compiled in senders is shown.
 H:
 H: The help command prints the help text of the given sender. If no command is
 H: given the list of compiled in senders is shown.
index 6ed5026ac31102932d4fb3b23e6e87d375002096..4315b7d756437bc21edb6f69499abbfed79844e7 100644 (file)
@@ -355,7 +355,7 @@ err:
        return ret;
 }
 
        return ret;
 }
 
-static char *udp_info(void)
+static char *udp_status(void)
 {
        struct sender_client *sc;
        char *ret, *tgts = NULL;
 {
        struct sender_client *sc;
        char *ret, *tgts = NULL;
@@ -371,10 +371,9 @@ static char *udp_info(void)
                tgts = tmp;
        }
        ret = make_message(
                tgts = tmp;
        }
        ret = make_message(
-               "udp sender:\n"
-               "\tstatus: %s\n"
-               "\tport: %s\n"
-               "\ttargets: %s\n",
+               "status: %s\n"
+               "port: %s\n"
+               "targets: %s\n",
                (sender_status == SENDER_ON)? "on" : "off",
                stringify_port(conf.udp_default_port_arg, "udp"),
                tgts? tgts : "(none)"
                (sender_status == SENDER_ON)? "on" : "off",
                stringify_port(conf.udp_default_port_arg, "udp"),
                tgts? tgts : "(none)"
@@ -427,7 +426,7 @@ static char *udp_help(void)
 void udp_send_init(struct sender *s)
 {
        INIT_LIST_HEAD(&targets);
 void udp_send_init(struct sender *s)
 {
        INIT_LIST_HEAD(&targets);
-       s->info = udp_info;
+       s->status = udp_status;
        s->help = udp_help;
        s->send = NULL;
        s->pre_select = NULL;
        s->help = udp_help;
        s->send = NULL;
        s->pre_select = NULL;
index 73eafbb4fa4be257ef7301d4dd5a51198dc14ed7..50b2d46c8b63ecc3a5441efa6e471a73178d40fc 100644 (file)
@@ -1452,15 +1452,21 @@ the stream.
 Examples
 ~~~~~~~~
 
 Examples
 ~~~~~~~~
 
-The sender command of para_server allows to (de-)activate senders
-and to change the access permissions senders at runtime. The "si"
-(server info) command is used to list the streaming options of the
-currently running server as well as the various sender access lists.
+The "si" (server info) command lists some information about the
+currently running server process.
 
 
--> Show client/target/access lists:
+-> Show PIDs, number of connected clients, uptime, and more:
 
        para_client si
 
 
        para_client si
 
+The sender command of para_server prints information about senders,
+like the various access control lists, and it allows to (de-)activate
+senders and to change the access permissions at runtime.
+
+-> List all senders
+
+       para_client sender
+
 -> Obtain general help for the sender command:
 
        para_client help sender
 -> Obtain general help for the sender command:
 
        para_client help sender
@@ -1470,6 +1476,10 @@ currently running server as well as the various sender access lists.
        s=http # or dccp or udp
        para_client sender $s help
 
        s=http # or dccp or udp
        para_client sender $s help
 
+-> Show status of the http sender
+
+       para_client sender http status
+
 By default para_server activates both the HTTP and th DCCP sender on
 startup. This can be changed via command line options or para_server's
 config file.
 By default para_server activates both the HTTP and th DCCP sender on
 startup. This can be changed via command line options or para_server's
 config file.