Reload log file on SIGHUP

There's a report about a nightly "crash" when users download, compile
from source, and replace their distro's mindlnad binary.  This is because
the Debian package includes a patch that uses SIGUSR2 to reopen the log
file and sends SIGUSR2 from logrotate instead of just using the
"copytruncate" logrotate option.  Then logrotate sends SIGUSR2 at 6:25AM,
which causes us to abort due to the unhandled signal.

I don't want to sacrifice SIGUSR2 just for log rotation, especially when
we already do some reload operations on SIGHUP.  So to avoid this
Debian/Ubuntu issue, we'll explicitly ignore SIGUSR2, and add log file
reopening to the SIGHUP handler.  Then hopefully a future Debian package
version will remove the SIGUSR2 patch and use SIGHUP instead (or
copytruncate).

Fixes: SF Bug #313 (log rotation kills minidlna service)
This commit is contained in:
Justin Maggard
2018-01-23 22:01:10 -08:00
parent 7a8ef80af0
commit 138d03db19
5 changed files with 67 additions and 50 deletions

View File

@ -68,6 +68,12 @@
#define USE_FORK 1
#define DB_VERSION 11
#ifdef READYNAS
# define LOGFILE_NAME "upnp-av.log"
#else
# define LOGFILE_NAME "minidlna.log"
#endif
#ifdef ENABLE_NLS
#define _(string) gettext(string)
#else
@ -229,8 +235,8 @@ extern const char *minissdpdsocketpath;
extern sqlite3 *db;
#define FRIENDLYNAME_MAX_LEN 64
extern char friendly_name[];
extern char db_path[];
extern char log_path[];
extern char db_path[1024];
extern char log_path[1024];
extern struct media_dir_s *media_dirs;
extern struct album_art_name_s *album_art_names;
extern volatile short int quitting;