Re: [PATCH 06/24] perf daemon: Add config file support

From: Namhyung Kim
Date: Thu Feb 11 2021 - 01:02:20 EST


Hi Jiri,

On Tue, Feb 9, 2021 at 5:09 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> +static int daemon__reconfig(struct daemon *daemon)
> +{
> + struct daemon_session *session, *n;
> +
> + list_for_each_entry_safe(session, n, &daemon->sessions, list) {
> + /* No change. */
> + if (session->state == OK)
> + continue;
> +
> + /* Remove session. */
> + if (session->state == KILL) {
> + if (session->pid > 0) {
> + daemon_session__kill(session);
> + pr_info("reconfig: session '%s' killed\n", session->name);
> + }
> + daemon_session__remove(session);
> + continue;
> + }
> +
> + /* Reconfig session. */
> + if (session->pid > 0) {
> + daemon_session__kill(session);
> + pr_info("reconfig: session '%s' killed\n", session->name);
> + }
> + if (daemon_session__run(session, daemon))
> + return -1;

Shouldn't it be 'continue'? If there's a problematic session
it'll prevent others from being processed. And it seems this
code will try to run it again and again. Maybe we can put it
in the KILL state (or a new FAILED state) IMHO.

Thanks,
Namhyung

> +
> + session->state = OK;
> + }
> +
> + return 0;
> +}
> +
> static int setup_config(struct daemon *daemon)
> {
> if (daemon->base_user) {
> @@ -278,6 +614,9 @@ static int __cmd_start(struct daemon *daemon, struct option parent_options[],
> return -1;
> }
>
> + if (setup_server_config(daemon))
> + return -1;
> +
> debug_set_file(daemon->out);
> debug_set_display_time(true);
>
> @@ -297,15 +636,23 @@ static int __cmd_start(struct daemon *daemon, struct option parent_options[],
> signal(SIGTERM, sig_handler);
>
> while (!done && !err) {
> - if (fdarray__poll(&fda, -1)) {
> + err = daemon__reconfig(daemon);
> +
> + if (!err && fdarray__poll(&fda, -1)) {
> + bool reconfig = false;
> +
> if (fda.entries[sock_pos].revents & POLLIN)
> err = handle_server_socket(daemon, sock_fd);
> +
> + if (reconfig)
> + err = setup_server_config(daemon);
> }
> }
>
> out:
> fdarray__exit(&fda);
>
> + daemon__kill(daemon);
> daemon__exit(daemon);
>
> if (sock_fd != -1)
> --
> 2.29.2
>