lkml.org 
[lkml]   [2022]   [Oct]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] perf daemon: Check err before calling setup_server_config in __cmd_start
Em Mon, Oct 24, 2022 at 08:46:44AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Sat, Oct 22, 2022 at 05:27:33PM +0800, Yang Jihong escreveu:
> > If err!=0 before calling setup_server_config and reconfig==true,
> > setup_server_config function may return 0 and err becomes 0.
> > As a result, previous error is overwritten, need to check value of err first.

Applied patches 2 and 3 meanwhile, thanks.

- Arnaldo

> > Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
> > ---
> > tools/perf/builtin-daemon.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
> > index 6cb3f6cc36d0..b82bd902602a 100644
> > --- a/tools/perf/builtin-daemon.c
> > +++ b/tools/perf/builtin-daemon.c
> > @@ -1333,7 +1333,7 @@ static int __cmd_start(struct daemon *daemon, struct option parent_options[],
> > if (fda.entries[signal_pos].revents & POLLIN)
> > err = handle_signalfd(daemon) < 0;
> >
> > - if (reconfig)
> > + if (!err && reconfig)
> > err = setup_server_config(daemon);
> > }
>
> Expanding the context a bit:
>
> while (!done && !err) {
> 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 (fda.entries[file_pos].revents & POLLIN)
> err = handle_config_changes(daemon, conf_fd, &reconfig);
> if (fda.entries[signal_pos].revents & POLLIN)
> err = handle_signalfd(daemon) < 0;
>
> if (!err && reconfig)
> err = setup_server_config(daemon);
> }
> }
>
> The err you're checking may be the last one, that may have overwritten
> 'err' from handle_config_changes(), perhaps moving things around helps?
> I.e.:
> if (!err && fdarray__poll(&fda, -1)) {
> bool reconfig = false;
>
> if (fda.entries[sock_pos].revents & POLLIN)
> err = handle_server_socket(daemon, sock_fd);
> if (fda.entries[signal_pos].revents & POLLIN)
> err = handle_signalfd(daemon) < 0;
> if (fda.entries[file_pos].revents & POLLIN)
> err = handle_config_changes(daemon, conf_fd, &reconfig);
>
> if (!err && reconfig)
> err = setup_server_config(daemon);
> }
>
>
> ?
>
> Jiri?
>
> - Arnaldo
>
> > }
> > --
> > 2.30.GIT
>
> --
>
> - Arnaldo

--

- Arnaldo

\
 
 \ /
  Last update: 2022-10-24 14:08    [W:0.068 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site