Skip to content

Commit

Permalink
Only mark rdeps dirty if main service is nohup
Browse files Browse the repository at this point in the history
This patch changes a behavior that's been default since Finit 4.0,
introduced in 4d05bf9 with 4.0-rc2.

If service B depends on A and A needs to be reloaded, then B may be
affected.  If A is declared as NOHUP <!>, then A will be stopped and
restarted, during which time the condition it provides is removed,
and B will also be stopped.

However, and as of this patch, if A is declared supporting HUP, then the
condition A provides will only go into flux, during which time B will be
SIGSTOPed instead of needing to be reloaded.

Fix #415

Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Oct 17, 2024
1 parent 5470142 commit 46ffa81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,10 @@ static void svc_mark_affected(char *cond)
* Called on conf_reload() to update service reverse dependencies.
* E.g., if ospfd depends on zebra and the zebra Finit conf has
* changed, we need to mark the ospfd Finit conf as changed too.
*
* However, a daemon that depends on syslogd (sysklogd project), need
* not be reloeaded (SIGHUP'ed or stop/started) because syslogd support
* reloading its configuration file on SIGHUP.
*/
void service_update_rdeps(void)
{
Expand All @@ -2012,6 +2016,10 @@ void service_update_rdeps(void)
if (!svc_is_changed(svc))
continue;

/* Service supports reloading conf without stop/start */
if (!svc_is_nohup(svc))
continue; /* Yup, no need to stop start rdeps */

svc_mark_affected(mkcond(svc, cond, sizeof(cond)));
}
}
Expand Down
1 change: 1 addition & 0 deletions src/svc.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ static inline int svc_is_tty (svc_t *svc) { return svc && SVC_TYPE_TTY
static inline int svc_is_runtask (svc_t *svc) { return svc && (SVC_TYPE_RUNTASK & svc->type);}
static inline int svc_is_forking (svc_t *svc) { return svc && svc->forking; }
static inline int svc_is_manual (svc_t *svc) { return svc && svc->manual; }
static inline int svc_is_nohup (svc_t *svc) { return svc && (0 == svc->sighup); }

static inline int svc_in_runlevel (svc_t *svc, int runlevel) { return svc && ISSET(svc->runlevels, runlevel); }
static inline int svc_nohup (svc_t *svc) { return svc && (0 == svc->sighup || 0 != svc->args_dirty); }
Expand Down

0 comments on commit 46ffa81

Please sign in to comment.