1
0

lvm2-2.03.20-dmeventd-no-idle-exit.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From ab3ae0a22dfbe20e2d17e7dc60e0f76184ec098c Mon Sep 17 00:00:00 2001
  2. From: "Robin H. Johnson" <robbat2@gentoo.org>
  3. Date: Wed, 24 Jul 2019 11:22:32 +0200
  4. Subject: [PATCH] dmeventd configurable idle exit time
  5. dmeventd nominally exits after 1 hour of idle time. There are use cases for
  6. this, esp. with socket activation, but also cases where users don't expect
  7. dmeventd to exit.
  8. Provide a tuning knob via environment variable, DMEVENTD_IDLE_EXIT_TIMEOUT,
  9. that can be -1 to not exit, or a configurable time for different idle exit.
  10. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
  11. Fixes: https://bugs.gentoo.org/682556
  12. --- a/daemons/dmeventd/dmeventd.c
  13. +++ b/daemons/dmeventd/dmeventd.c
  14. @@ -2169,6 +2169,18 @@
  15. .server_path = DM_EVENT_FIFO_SERVER
  16. };
  17. time_t now, idle_exit_timeout = DMEVENTD_IDLE_EXIT_TIMEOUT;
  18. +
  19. + /* Provide a basic way to config the idle timeout */
  20. + char* idle_exit_timeout_env = getenv("DMEVENTD_IDLE_EXIT_TIMEOUT") ? : NULL;
  21. + if(NULL != idle_exit_timeout_env) {
  22. + char* endptr;
  23. + idle_exit_timeout = strtol(idle_exit_timeout_env, &endptr, 10);
  24. + if (errno == ERANGE || *endptr != '\0') {
  25. + fprintf(stderr, "DMEVENTD_IDLE_EXIT_TIMEOUT: bad time input\n");
  26. + exit(EXIT_FAILURE);
  27. + }
  28. + }
  29. +
  30. opterr = 0;
  31. optind = 0;
  32. @@ -2265,7 +2277,7 @@
  33. _process_initial_registrations();
  34. for (;;) {
  35. - if (_idle_since) {
  36. + if (_idle_since || _exit_now) {
  37. if (_exit_now) {
  38. if (_exit_now == DM_SCHEDULED_EXIT)
  39. break; /* Only prints shutdown message */
  40. @@ -2274,7 +2286,7 @@
  41. (long) (time(NULL) - _idle_since));
  42. break;
  43. }
  44. - if (idle_exit_timeout) {
  45. + if (idle_exit_timeout && idle_exit_timeout > 0) {
  46. now = time(NULL);
  47. if (now < _idle_since)
  48. _idle_since = now; /* clock change? */
  49. --- a/man/dmeventd.8_main
  50. +++ b/man/dmeventd.8_main
  51. @@ -169,6 +169,10 @@
  52. Variable is set by thin and vdo plugin to prohibit recursive interaction
  53. with dmeventd by any executed lvm2 command from
  54. a thin_command, vdo_command environment.
  55. +.TP
  56. +.B DMEVENTD_IDLE_EXIT_TIMEOUT
  57. +Configure the dmeventd idle exit timeout behavior, value in seconds. Default
  58. +is 3600 (1 hour). -1 means do not exit.
  59. .
  60. .SH SEE ALSO
  61. .