Skip to content

Commit

Permalink
linux: use sd_notify_barrier if available
Browse files Browse the repository at this point in the history
If the sd_notify_barrier function is available, use it to synchronize
systemd notify notifications and make sure they were processed by
systemd.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Nov 25, 2021
1 parent 536de82 commit 78cf48b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ AS_IF([test "x$enable_systemd" != "xno"], [
AC_CHECK_HEADERS([systemd/sd-bus.h], [], [AC_MSG_ERROR([*** Missing libsystemd headers])])
AS_IF([test "$ac_cv_header_systemd_sd_bus_h" = "yes"], [
AC_SEARCH_LIBS(sd_bus_match_signal_async, [systemd], [AC_DEFINE([HAVE_SYSTEMD], 1, [Define if libsystemd is available])], [AC_MSG_ERROR([*** Failed to find libsystemd])])
AC_CHECK_FUNCS(sd_notify_barrier)
])
])

Expand Down
5 changes: 5 additions & 0 deletions src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,11 @@ handle_notify_socket (int notify_socketfd, libcrun_error_t *err)
if (UNLIKELY (ret < 0))
return crun_make_error (err, -ret, "sd_notify");

# if HAVE_SD_NOTIFY_BARRIER
/* Hard-code a 30 seconds timeout. Ignore errors. */
sd_notify_barrier (0, 30 * 1000000);
# endif

return 1;
}
return 0;
Expand Down

0 comments on commit 78cf48b

Please sign in to comment.