[lttng-dev] [RFC PATCH lttng-tools] relayd pipes and error handling

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Fri Jul 20 14:15:11 EDT 2012


* David Goulet (dgoulet at efficios.com) wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
> 
> I'm pretty OK with that.
> 
> I have utils_* function for that in lttng-sessiond/ ... I think I'm
> going to move them to common/ since they are pretty useful for the
> complete code tree.

since this was a RFC patch, does Christian need to resend it, after
update ?

> 
> Cheers!
> David
> 
> Christian Babeux:
> > Hi,
> > 
> > The current relayd employ two set of pipes for command relaying
> > and thread quit signalling. The relay_cmd_pipe pipes are never
> > closed. Also, the thread_quit_pipe pipes are not closed in some
> > error cases (fail to parse args, fail to daemonize, etc.). Here is
> > a proposed way to cleanup and handle error cases.
> > 
> > Thoughts?
> > 
> > Thanks,
> > 
> > Christian
> > 
> > Fix: relayd relay_cmd_pipe/thread_quit_pipe should be closed on
> > exit/error.
> > 
> > diff --git a/src/bin/lttng-relayd/main.c
> > b/src/bin/lttng-relayd/main.c index acc6ca8..55452b3 100644 ---
> > a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@
> > -231,14 +231,26 @@ void cleanup(void)
> > 
> > DBG("Cleaning up");
> > 
> > +       /* Close thread quit pipes */ for (i = 0; i < 2; i++) { if
> > (thread_quit_pipe[i] >= 0) { ret = close(thread_quit_pipe[i]); if
> > (ret) { -                               PERROR("close"); +
> > PERROR("close quit pipe"); } } } + +       /* Close relay cmd pipes
> > */ +       for (i = 0; i < 2; i++) { +               if
> > (relay_cmd_pipe[i] >= 0) { +                       ret =
> > close(relay_cmd_pipe[i]); +                       if (ret) { +
> > PERROR("close cmd pipe"); +                       } +
> > } +       } + }
> > 
> > /* @@ -1479,7 +1491,7 @@ int main(int argc, char **argv) /* Parse
> > arguments */ progname = argv[0]; if ((ret = parse_args(argc, argv)
> > < 0)) { -               goto error; +               goto exit; }
> > 
> > if ((ret = set_signal_handler()) < 0) { @@ -1491,7 +1503,7 @@ int
> > main(int argc, char **argv) ret = daemon(0, 0); if (ret < 0) { 
> > PERROR("daemon"); -                       goto error; +
> > goto exit; } }
> > 
> > @@ -1502,7 +1514,7 @@ int main(int argc, char **argv) if
> > (control_uri->port < 1024 || data_uri->port < 1024) { ERR("Need to
> > be root to use ports < 1024"); ret = -1; -
> > goto error; +                       goto exit; } }
> > 
> > @@ -1567,6 +1579,7 @@ exit: if (!ret) { exit(EXIT_SUCCESS); } + 
> > error: exit(EXIT_FAILURE); }
> > 
> > _______________________________________________ lttng-dev mailing
> > list lttng-dev at lists.lttng.org 
> > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> -----BEGIN PGP SIGNATURE-----
> 
> iQEcBAEBCgAGBQJQBtxQAAoJEELoaioR9I02hjoH/RKfCg0r4nq5AnKDpxJIQEaC
> Cy0QUmLZ812prSDaHgoPBL8ItJ4XiLGmFxwj+F0RXP9sT2QuOsiHYRc3aKk1+X5u
> RMnIuqx4ZdkakeGkTtZMr3ujmy/vOj9NOMuZsigV9z7g/jL5uXzfL0eJcW9kJLQ3
> cNEtdO519q9hInoxpRBkRQtJya1LHoT66oc5AK8TWMBCLjHzvTvvqWNSEBEOfQqH
> b7CulD3x6//DvnlVImA3zFNB2YXLvY6bL3XnU9I/DIEENjG1uAP+9/h+IzWRMNcS
> F0bttSrK9faUqBedMB81hadx0uLjpQxnIB9oFR2NEW/W1J3HAwwVN5YntZFo+lw=
> =BfP8
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list