On Sun, Apr 3, 2016 at 1:18 PM, Friedrich, Eugen (ADITG/SW1) < efriedr...@de.adit-jv.com> wrote:
> systemd provides a feature of socket-based activation, details in [1] > This commit adds an implementation to check if sockets were provided by > systemd and adds this as an additional socket to wayland display. > before adding sockets are checked for the correctness: > only AF_UNIX of type SOCK_STREAM are accepted > > This is usefull for early rendering use-cases where weston and > early-rendering-application can be started parallel. > > [1] https://www.freedesktop.org/software/systemd/man/systemd.socket.html > > Signed-off-by: Eugen Friedrich <efriedr...@de.adit-jv.com> > --- > configure.ac | 5 ++++- > src/systemd-notify.c | 27 +++++++++++++++++++++++++++ > 2 files changed, 31 insertions(+), 1 deletion(-) > mode change 100644 => 100755 src/systemd-notify.c > > diff --git a/configure.ac b/configure.ac > index 9e8115a..447cf6b 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -634,7 +634,10 @@ AC_ARG_ENABLE(systemd_notify, > AS_HELP_STRING([--enable-systemd-notify], > [Enables systemd notifications to > notify systemd about weston state > - and update watchdog.]),, > + and update watchdog. > + Also sockets provided by systemd > + in case of socket-base activation > + are added to wayland display]),, > enable_systemd_notify=no) > AM_CONDITIONAL(SYSTEMD_NOTIFY_SUPPORT, test x$enable_systemd_notify = > xyes) > if test "x$enable_systemd_notify" = "xyes"; then > diff --git a/src/systemd-notify.c b/src/systemd-notify.c > old mode 100644 > new mode 100755 > index e61db0f..0be1f6f > --- a/src/systemd-notify.c > +++ b/src/systemd-notify.c > @@ -28,6 +28,7 @@ > #include <errno.h> > #include <stdlib.h> > #include <systemd/sd-daemon.h> > +#include <sys/socket.h> > #include <wayland-server.h> > #include "shared/helpers.h" > #include "shared/zalloc.h" > @@ -79,6 +80,8 @@ module_init(struct weston_compositor *compositor, > struct wl_event_loop *loop; > long watchdog_time_conv; > struct systemd_notifier *notifier; > + int fd; > I think you can move this declaration into the loop next to "int current_fd = 0;" > + int systemd_socket_fds = 0; > > notifier = zalloc(sizeof *notifier); > if (notifier == NULL) > @@ -89,6 +92,30 @@ module_init(struct weston_compositor *compositor, > wl_signal_add(&compositor->destroy_signal, > ¬ifier->compositor_destroy_listener); > > + /*take additional display sockets if provided by systemd*/ > + systemd_socket_fds = sd_listen_fds(1); > + > + if (systemd_socket_fds > 0) { > + int current_fd = 0; > ie put it here. > + > + for (;current_fd < systemd_socket_fds; current_fd++) { > + fd = SD_LISTEN_FDS_START + current_fd; > + > + if (sd_is_socket(fd, AF_UNIX, SOCK_STREAM,1) > 0) { > + if > (wl_display_add_socket_fd(compositor->wl_display, fd)) { > + > weston_log("wl_display_add_socket_fd failed\n"); > + return -1; > + } > + } else { > + weston_log("invalid socket provided from > systemd\n"); > + return -1; > + } > + } > + > + weston_log("info: add %d socket(s) provided by systemd\n", > + current_fd); > + } > + > sd_notify(0, "READY=1"); > > /* 'WATCHDOG_USEC' is environment variable that is set > -- > 2.4.11 > _______________________________________________ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/wayland-devel >
_______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel