From 71f3f63a97dda6e6297bfad058741506ec2029a6 Mon Sep 17 00:00:00 2001 From: Stefan Saraev Date: Mon, 10 Mar 2014 22:10:45 +0200 Subject: [PATCH] xbmc: init takes care of reboot and shutdown when one decides to reboot/shutdown via xbmc GUI, he/she expects it to happen immediately or with minimal delay. there are addons (trakt, watchdog) that are known to cause high (1+ minute) shutdown. ---- 16:19:15 T:140287759476608 DEBUG: CAnnouncementManager - Announcement: OnQuit from xbmc 16:19:15 T:140287759476608 DEBUG: GOT ANNOUNCEMENT, type: 8, from xbmc, message OnQuit 16:19:15 T:140287759476608 NOTICE: Storing total System Uptime 16:19:15 T:140287759476608 NOTICE: Saving settings 16:19:15 T:140287759476608 NOTICE: stop all ^^ CJobManager::GetInstance().CancelJobs() comes in 16:19:15 T:140286952978176 DEBUG: Thread JobWorker 140286952978176 terminating (autodelete) 16:19:15 T:140286978156288 DEBUG: Thread JobWorker 140286978156288 terminating (autodelete) 16:19:15 T:140286676150016 DEBUG: Thread JobWorker 140286676150016 terminating (autodelete) 16:19:19 T:140286676150016 NOTICE: Thread FileCache start, auto delete: false ^^ so far so good but this should never happen once CApplication::Stop is called. but it does 16:19:30 T:140286676150016 ERROR: CCurlFile::FillBuffer - Failed: Timeout was reached(28) 16:19:30 T:140286676150016 NOTICE: CCurlFile::FillBuffer - Reconnect, (re)try 1 16:19:50 T:140286676150016 ERROR: CCurlFile::FillBuffer - Failed: Timeout was reached(28) 16:19:50 T:140286676150016 NOTICE: CCurlFile::FillBuffer - Reconnect, (re)try 2 16:20:10 T:140286676150016 ERROR: CCurlFile::FillBuffer - Failed: Timeout was reached(28) 16:20:10 T:140286676150016 ERROR: CCurlFile::FillBuffer - Reconnect failed! 16:20:10 T:140286676150016 INFO: CFileCache::Process - Hit eof. 16:20:10 T:140286676150016 DEBUG: Thread FileCache 140286676150016 terminating ^^ 1 minute shutdown delay.. ---- with this patch now xbmc can handle SIGTERM and attempt clean exit, systemd will take care of the rest if xbmc fails to exit. --- ...it-takes-care-of-reboot-and-shutdown.patch | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 packages/mediacenter/xbmc/patches/xbmc-999.03-init-takes-care-of-reboot-and-shutdown.patch diff --git a/packages/mediacenter/xbmc/patches/xbmc-999.03-init-takes-care-of-reboot-and-shutdown.patch b/packages/mediacenter/xbmc/patches/xbmc-999.03-init-takes-care-of-reboot-and-shutdown.patch new file mode 100644 index 0000000000..65b3080900 --- /dev/null +++ b/packages/mediacenter/xbmc/patches/xbmc-999.03-init-takes-care-of-reboot-and-shutdown.patch @@ -0,0 +1,73 @@ +From 3141728598291186cc4c9d243a1e258ce6e914ae Mon Sep 17 00:00:00 2001 +From: Stefan Saraev +Date: Mon, 10 Mar 2014 22:00:40 +0200 +Subject: [PATCH 1/2] handle SIGTERM + +--- + xbmc/main/main.cpp | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/xbmc/main/main.cpp b/xbmc/main/main.cpp +index ec86426..aa4a925 100644 +--- a/xbmc/main/main.cpp ++++ b/xbmc/main/main.cpp +@@ -40,9 +40,22 @@ + #include "input/linux/LIRC.h" + #endif + #include "XbmcContext.h" ++#include "Application.h" ++ ++void xbmc_term_handler(int signum) ++{ ++ CLog::Log(LOGINFO, "Received SIGTERM..."); ++ g_application.Stop(0); ++} + + int main(int argc, char* argv[]) + { ++ // SIGTERM handler ++ struct sigaction action; ++ memset(&action, 0, sizeof(struct sigaction)); ++ action.sa_handler = xbmc_term_handler; ++ sigaction(SIGTERM, &action, NULL); ++ + // set up some xbmc specific relationships + XBMC::Context context; + +-- +1.9.0 + + +From 4945dbdeff5da8b162fdf0700f4026e9d71ffe04 Mon Sep 17 00:00:00 2001 +From: Stefan Saraev +Date: Mon, 10 Mar 2014 22:02:02 +0200 +Subject: [PATCH 2/2] dont Stop() on shutdown/reboot + +SIGTERM should be handled instead. systemd will take care +--- + xbmc/ApplicationMessenger.cpp | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/xbmc/ApplicationMessenger.cpp b/xbmc/ApplicationMessenger.cpp +index 3524e89..c5521f7 100644 +--- a/xbmc/ApplicationMessenger.cpp ++++ b/xbmc/ApplicationMessenger.cpp +@@ -259,7 +259,6 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) + + case TMSG_POWERDOWN: + { +- g_application.Stop(EXITCODE_POWERDOWN); + g_powerManager.Powerdown(); + } + break; +@@ -287,7 +286,6 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) + case TMSG_RESTART: + case TMSG_RESET: + { +- g_application.Stop(EXITCODE_REBOOT); + g_powerManager.Reboot(); + } + break; +-- +1.9.0 +