lkml.org 
[lkml]   [2021]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 06/24] perf daemon: Add config file support
Hi Jiri,

On Tue, Feb 9, 2021 at 5:09 AM Jiri Olsa <jolsa@kernel.org> 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
>

\
 
 \ /
  Last update: 2021-02-11 07:03    [W:0.248 / U:1.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site