Commit 26e1bb7e authored by chrfranke's avatar chrfranke
Browse files

smartd.cpp: Prevent systemd unit startup timeout when registering many devices.

Patch by GH user 'themylogin' (GH pull/138).

git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk@5395 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent b2dffa1e
$Id$
2022-06-07 themylogin <themylogin@gmail.com>
smartd.cpp: Prevent systemd unit startup timeout when registering
many devices (GH pull/138).
2022-05-30 Douglas Gilbert <dgilbert@interlog.com>
[SCSI]: rework scsiGetIEString() so it should now output
......
......@@ -236,6 +236,7 @@ static void PrintOut(int priority, const char *fmt, ...)
// systemd notify support
static bool notify_enabled = false;
static bool notify_ready = false;
static inline void notify_init()
{
......@@ -255,6 +256,20 @@ static inline bool notify_post_init()
return true;
}
static inline void notify_extend_timeout()
{
if (!notify_enabled)
return;
if (notify_ready)
return;
const char * notify = "EXTEND_TIMEOUT_USEC=20000000"; // typical drive spinup time is 20s tops
if (debugmode) {
pout("sd_notify(0, \"%s\")\n", notify);
return;
}
sd_notify(0, notify);
}
static void notify_msg(const char * msg, bool ready = false)
{
if (!notify_enabled)
......@@ -285,9 +300,8 @@ static void notify_wait(time_t wakeuptime, int numdev)
char msg[64];
snprintf(msg, sizeof(msg), "Next check of %d device%s will start at %s",
numdev, (numdev != 1 ? "s" : ""), ts);
static bool ready = true; // first call notifies READY=1
notify_msg(msg, ready);
ready = false;
notify_msg(msg, !notify_ready); // first call notifies READY=1
notify_ready = true;
}
static void notify_exit(int status)
......@@ -322,6 +336,7 @@ static inline bool notify_post_init()
}
static inline void notify_init() { }
static inline void notify_extend_timeout() { }
static inline void notify_msg(const char *) { }
static inline void notify_check(int) { }
static inline void notify_wait(time_t, int) { }
......@@ -5578,6 +5593,9 @@ static bool register_devices(const dev_config_vector & conf_entries, smart_devic
}
}
// Prevent systemd unit startup timeout when registering many devices
notify_extend_timeout();
// Register device
// If scanning, pass dev_idinfo of previous devices for duplicate check
dev_state state;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment