[systemd-devel] [PATCH] core: fix event source annotations

Lennart Poettering lennart at poettering.net
Wed May 13 09:30:35 PDT 2015


On Wed, 29.04.15 21:29, Mantas Mikulėnas (grawity at gmail.com) wrote:

> These looked like a mass-replace gone slightly wrong – two statements
> with no { }'s, and no error checking.
> ---
>  src/core/busname.c | 4 +++-
>  src/core/manager.c | 5 ++++-
>  src/core/socket.c  | 3 ++-
>  3 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/src/core/busname.c b/src/core/busname.c
> index 48cc045..94db122 100644
> --- a/src/core/busname.c
> +++ b/src/core/busname.c
> @@ -291,13 +291,15 @@ static int busname_watch_fd(BusName *n) {
>                  r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_ON);
>          else
>                  r = sd_event_add_io(UNIT(n)->manager->event, &n->starter_event_source, n->starter_fd, EPOLLIN, busname_dispatch_io, n);
> -                (void) sd_event_source_set_description(n->starter_event_source, "busname-starter");
> +
>          if (r < 0) {
>                  log_unit_warning_errno(UNIT(n)->id, r, "Failed to watch starter fd: %m");
>                  busname_unwatch_fd(n);
>                  return r;
>          }
>  
> +        (void) sd_event_source_set_description(n->starter_event_source, "busname-starter");
> +

Hmm, it sounds a bit unnecessary to set the same description over and
over again. We should really only set it when we allocate a new event
source, and not every single time we toggle is enablement state.

> --- a/src/core/socket.c
> +++ b/src/core/socket.c
> @@ -1272,11 +1272,12 @@ static int socket_watch_fds(Socket *s) {
>                  else
>                          r = sd_event_add_io(UNIT(s)->manager->event, &p->event_source, p->fd, EPOLLIN, socket_dispatch_io, p);
>  
> -                        (void) sd_event_source_set_description(p->event_source, "socket-port-io");
>                  if (r < 0) {
>                          log_unit_warning_errno(UNIT(s)->id, r, "Failed to watch listening fds: %m");
>                          goto fail;
>                  }
> +
> +                (void) sd_event_source_set_description(p->event_source, "socket-port-io");

Same here...

I fixed that now.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list