[haiku-commits] haiku: hrev53643 - src/kits/app src/servers/registrar src/servers/launch headers/private/app

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 21 Dec 2019 15:32:35 -0500 (EST)

hrev53643 adds 2 changesets to branch 'master'
old head: a02f7c7baec10508f955e604849f240e3d5288a8
new head: 0749734769cd1bf9aca1152ffb9790bf11ac3b9a
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=0749734769cd+%5Ea02f7c7baec1

----------------------------------------------------------------------------

feeb4b5d93eb: RosterPrivate: add IsShutDownInProgress()
  
  enable to check whether a shutdown process is in progress.
  
  Change-Id: I8efdddb3caa80e9fd188f202b6e92a888a7608e5
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2042
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

0749734769cd: launch_daemon: don't relaunch when a shutdown is in progress
  
  Change-Id: Ice0dd504f65f592eb64ec0e2192ef42b88486daa
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2043
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                                   [ Jérôme Duval <jerome.duval@xxxxxxxxx> ]

----------------------------------------------------------------------------

7 files changed, 70 insertions(+), 3 deletions(-)
headers/os/app/Roster.h             |  1 +
headers/private/app/RegistrarDefs.h |  1 +
headers/private/app/RosterPrivate.h |  2 ++
src/kits/app/Roster.cpp             | 37 +++++++++++++++++++++++++++++++++
src/servers/launch/LaunchDaemon.cpp | 12 ++++++++---
src/servers/registrar/Registrar.cpp | 19 +++++++++++++++++
src/servers/registrar/Registrar.h   |  1 +

############################################################################

Commit:      feeb4b5d93ebae9cf068c7e184854c873597505d
URL:         https://git.haiku-os.org/haiku/commit/?id=feeb4b5d93eb
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Sat Dec 21 16:27:33 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat Dec 21 20:32:31 2019 UTC

RosterPrivate: add IsShutDownInProgress()

enable to check whether a shutdown process is in progress.

Change-Id: I8efdddb3caa80e9fd188f202b6e92a888a7608e5
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2042
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/headers/os/app/Roster.h b/headers/os/app/Roster.h
index 5127e5a8ee..6d08702ad2 100644
--- a/headers/os/app/Roster.h
+++ b/headers/os/app/Roster.h
@@ -147,6 +147,7 @@ private:
 
                        status_t                        _ShutDown(bool reboot, 
bool confirm,
                                                                        bool 
synchronous);
+                       status_t                        
_IsShutDownInProgress(bool* inProgress);
 
                        status_t                        _AddApplication(const 
char* signature,
                                                                        const 
entry_ref* ref, uint32 flags,
diff --git a/headers/private/app/RegistrarDefs.h 
b/headers/private/app/RegistrarDefs.h
index 4df6c3d776..0bb5d8545b 100644
--- a/headers/private/app/RegistrarDefs.h
+++ b/headers/private/app/RegistrarDefs.h
@@ -46,6 +46,7 @@ enum {
        B_REG_GET_CLIPBOARD_MESSENGER                   = 'rgcm',
        B_REG_GET_DISK_DEVICE_MESSENGER                 = 'rgdm',
        B_REG_SHUT_DOWN                                                 = 
'rgsh',
+       B_REG_IS_SHUT_DOWN_IN_PROGRESS                  = 'rgsi',
 
        // roster requests
        B_REG_ADD_APP                                                   = 
'rgaa',
diff --git a/headers/private/app/RosterPrivate.h 
b/headers/private/app/RosterPrivate.h
index 251476640b..bba25972bf 100644
--- a/headers/private/app/RosterPrivate.h
+++ b/headers/private/app/RosterPrivate.h
@@ -39,6 +39,8 @@ class BRoster::Private {
 
                status_t ShutDown(bool reboot, bool confirm, bool synchronous)
                        { return fRoster->_ShutDown(reboot, confirm, 
synchronous); }
+               status_t IsShutDownInProgress(bool* inProgress)
+                       { return fRoster->_IsShutDownInProgress(inProgress); }
 
                // needed by BApplication
 
diff --git a/src/kits/app/Roster.cpp b/src/kits/app/Roster.cpp
index 1c1d2381cd..7fc3ec86dd 100644
--- a/src/kits/app/Roster.cpp
+++ b/src/kits/app/Roster.cpp
@@ -1343,6 +1343,43 @@ BRoster::_ShutDown(bool reboot, bool confirm, bool 
synchronous)
 }
 
 
+/*!    Checks whether a shutdown process is in progress.
+
+       \param inProgress: Pointer to a pre-allocated bool to be filled in
+              by this method, indicating whether or not a shutdown process
+              is in progress.
+       \return A status code, \c B_OK on success or another error code in case
+               something went wrong.
+*/
+status_t
+BRoster::_IsShutDownInProgress(bool* inProgress)
+{
+       status_t error = B_OK;
+
+       // compose the request message
+       BMessage request(B_REG_IS_SHUT_DOWN_IN_PROGRESS);
+
+       // send the request
+       BMessage reply;
+       if (error == B_OK)
+               error = fMessenger.SendMessage(&request, &reply);
+
+       // evaluate the reply
+       if (error == B_OK) {
+               if (reply.what == B_REG_SUCCESS) {
+                       if (inProgress != NULL
+                               && reply.FindBool("in-progress", inProgress) != 
B_OK) {
+                               error = B_ERROR;
+                       }
+               } else if (reply.FindInt32("error", &error) != B_OK)
+                       error = B_ERROR;
+       }
+
+       return error;
+}
+
+
+
 /*!    (Pre-)Registers an application with the registrar.
 
        This methods is invoked either to register or to pre-register an
diff --git a/src/servers/registrar/Registrar.cpp 
b/src/servers/registrar/Registrar.cpp
index e5283b2415..29321ab036 100644
--- a/src/servers/registrar/Registrar.cpp
+++ b/src/servers/registrar/Registrar.cpp
@@ -248,6 +248,13 @@ Registrar::_MessageReceived(BMessage *message)
                        _HandleShutDown(message);
                        break;
                }
+               case B_REG_IS_SHUT_DOWN_IN_PROGRESS:
+               {
+                       PRINT("B_REG_IS_SHUT_DOWN_IN_PROGRESS\n");
+
+                       _HandleIsShutDownInProgress(message);
+                       break;
+               }
                case B_REG_TEAM_DEBUGGER_ALERT:
                {
                        if (fShutdownProcess != NULL)
@@ -416,6 +423,18 @@ Registrar::_HandleShutDown(BMessage *request)
 }
 
 
+/*!    \brief Handle a is shut down in progress request message.
+       \param request The request to be handled.
+*/
+void
+Registrar::_HandleIsShutDownInProgress(BMessage *request)
+{
+       BMessage reply(B_REG_SUCCESS);
+       reply.AddBool("in-progress", fShutdownProcess != NULL);
+       request->SendReply(&reply);
+}
+
+
 //     #pragma mark -
 
 
diff --git a/src/servers/registrar/Registrar.h 
b/src/servers/registrar/Registrar.h
index 302bc769ce..978c468edd 100644
--- a/src/servers/registrar/Registrar.h
+++ b/src/servers/registrar/Registrar.h
@@ -58,6 +58,7 @@ public:
 private:
        void _MessageReceived(BMessage *message);
        void _HandleShutDown(BMessage *message);
+       void _HandleIsShutDownInProgress(BMessage *message);
 
        TRoster                                 *fRoster;
        ClipboardHandler                *fClipboardHandler;

############################################################################

Revision:    hrev53643
Commit:      0749734769cd1bf9aca1152ffb9790bf11ac3b9a
URL:         https://git.haiku-os.org/haiku/commit/?id=0749734769cd
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Sat Dec 21 16:29:11 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sat Dec 21 20:32:31 2019 UTC

launch_daemon: don't relaunch when a shutdown is in progress

Change-Id: Ice0dd504f65f592eb64ec0e2192ef42b88486daa
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2043
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/servers/launch/LaunchDaemon.cpp 
b/src/servers/launch/LaunchDaemon.cpp
index 6d00ed052d..411f09a771 100644
--- a/src/servers/launch/LaunchDaemon.cpp
+++ b/src/servers/launch/LaunchDaemon.cpp
@@ -527,9 +527,15 @@ LaunchDaemon::MessageReceived(BMessage* message)
                                job->TeamDeleted();
 
                                if (job->IsService()) {
-                                       // TODO: take restart throttle into 
account
-                                       // TODO: don't restart on shutdown
-                                       _LaunchJob(job);
+                                       bool inProgress = false;
+                                       BRoster roster;
+                                       BRoster::Private rosterPrivate(roster);
+                                       status_t status = 
rosterPrivate.IsShutDownInProgress(
+                                               &inProgress);
+                                       if (status != B_OK || !inProgress) {
+                                               // TODO: take restart throttle 
into account
+                                               _LaunchJob(job);
+                                       }
                                }
                        }
                        break;


Other related posts:

  • » [haiku-commits] haiku: hrev53643 - src/kits/app src/servers/registrar src/servers/launch headers/private/app - waddlesplash