hrev51845 adds 2 changesets to branch 'master'
old head: 7de029128e99b6c341ffbb0bc5601d48a20b3733
new head: 09320f38d70a683ac45b1ac40032aeaf2d0caa5b
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=09320f38d70a+%5E7de029128e99
----------------------------------------------------------------------------
6899a856fe0e: Shutdown: follow up on ff6135f474eed07e58bbd1557cd2cd8ee8027677
* calling TRoster::GetShutdownApps() multiple times with the same lists
leads to problems because the lists aren't emptied first.
* instead we watch the user app launches, add them in the fUserApps list,
and let _QuitApps() iterates through the fUserApps list until it is empty.
09320f38d70a: Roster: fix debug build on x86_64.
[ Jérôme Duval <jerome.duval@xxxxxxxxx> ]
----------------------------------------------------------------------------
5 files changed, 81 insertions(+), 53 deletions(-)
src/kits/app/Roster.cpp | 30 ++++++-----
src/servers/registrar/ShutdownProcess.cpp | 77 ++++++++++++++-------------
src/servers/registrar/ShutdownProcess.h | 2 -
src/servers/registrar/TRoster.cpp | 24 +++++++++
src/servers/registrar/TRoster.h | 1 +
############################################################################
Commit: 6899a856fe0e9bfbf5b5f95ae35b4c530c76f635
URL: http://cgit.haiku-os.org/haiku/commit/?id=6899a856fe0e
Author: Jérôme Duval <jerome.duval@xxxxxxxxx>
Date: Sat Mar 10 14:48:26 2018 UTC
Shutdown: follow up on ff6135f474eed07e58bbd1557cd2cd8ee8027677
* calling TRoster::GetShutdownApps() multiple times with the same lists
leads to problems because the lists aren't emptied first.
* instead we watch the user app launches, add them in the fUserApps list,
and let _QuitApps() iterates through the fUserApps list until it is empty.
----------------------------------------------------------------------------
diff --git a/src/servers/registrar/ShutdownProcess.cpp
b/src/servers/registrar/ShutdownProcess.cpp
index f1bfff7227..51a5e86288 100644
--- a/src/servers/registrar/ShutdownProcess.cpp
+++ b/src/servers/registrar/ShutdownProcess.cpp
@@ -593,7 +593,7 @@ private:
ShutdownProcess::ShutdownProcess(TRoster* roster, EventQueue* eventQueue)
:
BLooper("shutdown process"),
- EventMaskWatcher(BMessenger(this), B_REQUEST_QUIT),
+ EventMaskWatcher(BMessenger(this), B_REQUEST_QUIT | B_REQUEST_LAUNCHED),
fWorkerLock("worker lock"),
fRequest(NULL),
fRoster(roster),
@@ -769,6 +769,26 @@ ShutdownProcess::MessageReceived(BMessage* message)
break;
}
+ case B_SOME_APP_LAUNCHED:
+ {
+ // get the team
+ team_id team;
+ if (message->FindInt32("be:team", &team) != B_OK) {
+ // should not happen
+ return;
+ }
+
+ PRINT("ShutdownProcess::MessageReceived():
B_SOME_APP_LAUNCHED: %"
+ B_PRId32 "\n", team);
+
+ // add the user app info to the respective list
+ {
+ BAutolock _(fWorkerLock);
+ fRoster->AddAppInfo(fUserApps, team);
+ }
+ break;
+ }
+
case MSG_PHASE_TIMED_OUT:
{
// get the phase the event is intended for
@@ -1232,20 +1252,6 @@ ShutdownProcess::_Worker()
}
-status_t
-ShutdownProcess::_GetUserAndSystemAppList()
-{
- fWorkerLock.Lock();
- // Get a list of all applications to shut down
- status_t status = fRoster->GetShutdownApps(fUserApps, fSystemApps,
- fBackgroundApps, fVitalSystemApps);
- fUserApps.Sort(&inverse_compare_by_registration_time);
- fWorkerLock.Unlock();
-
- return status;
-}
-
-
void
ShutdownProcess::_WorkerDoShutdown()
{
@@ -1289,6 +1295,21 @@ ShutdownProcess::_WorkerDoShutdown()
throw_error(B_SHUTDOWN_CANCELLED);
}
+ fWorkerLock.Lock();
+ // get a list of all applications to shut down and sort them
+ status_t status = fRoster->GetShutdownApps(fUserApps, fSystemApps,
+ fBackgroundApps, fVitalSystemApps);
+ if (status != B_OK) {
+ fWorkerLock.Unlock();
+ fRoster->RemoveWatcher(this);
+ return;
+ }
+
+ fUserApps.Sort(&inverse_compare_by_registration_time);
+ fSystemApps.Sort(&inverse_compare_by_registration_time);
+
+ fWorkerLock.Unlock();
+
// make the shutdown window ready and show it
_InitShutdownWindow();
_SetShutdownWindowCurrentApp(-1);
@@ -1302,36 +1323,16 @@ ShutdownProcess::_WorkerDoShutdown()
// phase 1: terminate the user apps
_SetPhase(USER_APP_TERMINATION_PHASE);
- status_t status;
- // Since, new apps can still be launched,
- // loop until all are gone
- while ((status = _GetUserAndSystemAppList()) == B_OK
- && !fUserApps.IsEmpty()) {
+
+ // since, new apps can still be launched, loop until all are gone
+ if (!fUserApps.IsEmpty()) {
_QuitApps(fUserApps, false);
_WaitForDebuggedTeams();
}
- if (status != B_OK) {
- fRoster->RemoveWatcher(this);
- return;
- }
-
// tell TRoster not to accept new applications anymore
fRoster->SetShuttingDown(true);
- // Check once again for any user apps to quit
- status = _GetUserAndSystemAppList();
- if (status != B_OK) {
- fRoster->RemoveWatcher(this);
- return;
- }
- _QuitApps(fUserApps, false);
- _WaitForDebuggedTeams();
-
- fWorkerLock.Lock();
- fSystemApps.Sort(&inverse_compare_by_registration_time);
- fWorkerLock.Unlock();
-
// phase 2: terminate the system apps
_SetPhase(SYSTEM_APP_TERMINATION_PHASE);
_QuitApps(fSystemApps, true);
diff --git a/src/servers/registrar/ShutdownProcess.h
b/src/servers/registrar/ShutdownProcess.h
index 259fe8fdd1..bc60f66999 100644
--- a/src/servers/registrar/ShutdownProcess.h
+++ b/src/servers/registrar/ShutdownProcess.h
@@ -88,8 +88,6 @@ private:
void
_DisplayAbortingApp(team_id team);
void _WaitForDebuggedTeams();
- status_t
_GetUserAndSystemAppList();
-
private:
class TimeoutEvent;
class InternalEvent;
diff --git a/src/servers/registrar/TRoster.cpp
b/src/servers/registrar/TRoster.cpp
index e8cd9a8765..ac91c421b2 100644
--- a/src/servers/registrar/TRoster.cpp
+++ b/src/servers/registrar/TRoster.cpp
@@ -1486,6 +1486,30 @@ TRoster::GetShutdownApps(AppInfoList& userApps,
AppInfoList& systemApps,
}
+status_t
+TRoster::AddAppInfo(AppInfoList& apps, team_id team)
+{
+ BAutolock _(fLock);
+
+ for (AppInfoList::Iterator it(fRegisteredApps.It());
+ RosterAppInfo* info = *it; ++it) {
+ if (info->team == team) {
+ RosterAppInfo* clonedInfo = info->Clone();
+ status_t error = B_NO_MEMORY;
+ if (clonedInfo != NULL) {
+ if (!apps.AddInfo(clonedInfo))
+ delete clonedInfo;
+ else
+ error = B_OK;
+ }
+ return error;
+ }
+ }
+
+ return B_BAD_TEAM_ID;
+}
+
+
status_t
TRoster::AddWatcher(Watcher* watcher)
{
diff --git a/src/servers/registrar/TRoster.h b/src/servers/registrar/TRoster.h
index a9303f7811..a305aa3019 100644
--- a/src/servers/registrar/TRoster.h
+++ b/src/servers/registrar/TRoster.h
@@ -78,6 +78,7 @@ public:
AppInfoList&
systemApps,
AppInfoList&
backgroundApps,
hash_set<team_id>& vitalSystemApps);
+ status_t AddAppInfo(AppInfoList& apps,
team_id team);
status_t AddWatcher(Watcher* watcher);
void RemoveWatcher(Watcher* watcher);
############################################################################
Revision: hrev51845
Commit: 09320f38d70a683ac45b1ac40032aeaf2d0caa5b
URL: http://cgit.haiku-os.org/haiku/commit/?id=09320f38d70a
Author: Jérôme Duval <jerome.duval@xxxxxxxxx>
Date: Sat Mar 10 15:01:39 2018 UTC
Roster: fix debug build on x86_64.
----------------------------------------------------------------------------
diff --git a/src/kits/app/Roster.cpp b/src/kits/app/Roster.cpp
index 1f0e98f478..f8c5103cca 100644
--- a/src/kits/app/Roster.cpp
+++ b/src/kits/app/Roster.cpp
@@ -1239,7 +1239,7 @@ BRoster::AddToRecentDocuments(const entry_ref* document,
if (error != B_OK) {
DBG(OUT("WARNING: BRoster::AddToRecentDocuments() failed with
error "
- "0x%lx\n", error));
+ "0x%" B_PRIx32 "\n", error));
}
}
@@ -1286,7 +1286,7 @@ BRoster::AddToRecentFolders(const entry_ref* folder,
if (error != B_OK) {
DBG(OUT("WARNING: BRoster::AddToRecentDocuments() failed with
error "
- "0x%lx\n", error));
+ "0x%" B_PRIx32 "\n", error));
}
}
@@ -1878,14 +1878,15 @@ BRoster::_LaunchApp(const char* mimeType, const
entry_ref* ref,
char signature[B_MIME_TYPE_LENGTH];
error = _ResolveApp(mimeType, docRef, &appRef, signature,
&appFlags, &wasDocument);
- DBG(OUT(" find app: %s (%lx)\n", strerror(error), error));
+ DBG(OUT(" find app: %s (%" B_PRIx32 ") %s \n",
strerror(error), error,
+ signature));
if (error != B_OK)
return error;
// build an argument vector
error = argVector.Init(argc, args, &appRef,
wasDocument ? docRef : NULL);
- DBG(OUT(" build argv: %s (%lx)\n", strerror(error), error));
+ DBG(OUT(" build argv: %s (%" B_PRIx32 ")\n", strerror(error),
error));
if (error != B_OK)
return error;
@@ -1908,12 +1909,13 @@ BRoster::_LaunchApp(const char* mimeType, const
entry_ref* ref,
team = appInfo.team;
}
}
- DBG(OUT(" pre-register: %s (%lx)\n", strerror(error),
error));
+ DBG(OUT(" pre-register: %s (%" B_PRIx32 ")\n",
strerror(error),
+ error));
}
// launch the app
if (error == B_OK && !alreadyRunning) {
- DBG(OUT(" token: %lu\n", appToken));
+ DBG(OUT(" token: %" B_PRIu32 "\n", appToken));
// load the app image
appThread = load_image(argVector.Count(),
const_cast<const char**>(argVector.Args()),
environment);
@@ -1929,18 +1931,20 @@ BRoster::_LaunchApp(const char* mimeType, const
entry_ref* ref,
else
error = appThread;
- DBG(OUT(" load image: %s (%lx)\n", strerror(error),
error));
+ DBG(OUT(" load image: %s (%" B_PRIx32 ")\n",
strerror(error),
+ error));
// finish the registration
if (error == B_OK && !isScript && !fNoRegistrar)
error = _SetThreadAndTeam(appToken, appThread,
team, &appPort);
- DBG(OUT(" set thread and team: %s (%lx)\n",
strerror(error),
- error));
+ DBG(OUT(" set thread and team: %s (%" B_PRIx32 ")\n",
+ strerror(error), error));
// resume the launched team
if (error == B_OK && !launchSuspended)
error = resume_thread(appThread);
- DBG(OUT(" resume thread: %s (%lx)\n", strerror(error),
error));
+ DBG(OUT(" resume thread: %s (%" B_PRIx32 ")\n",
strerror(error),
+ error));
// on error: kill the launched team and unregister the
app
if (error != B_OK) {
if (appThread >= 0)
@@ -2007,7 +2011,7 @@ BRoster::_LaunchApp(const char* mimeType, const
entry_ref* ref,
*_appToken = appToken;
}
- DBG(OUT("BRoster::_LaunchApp() done: %s (%lx)\n",
+ DBG(OUT("BRoster::_LaunchApp() done: %s (%" B_PRIx32 ")\n",
strerror(error), error));
return error;
@@ -2676,8 +2680,8 @@ BRoster::_InitMimeMessenger(void* data)
DBG(OUT(" got reply from roster\n"));
reply.FindMessenger("messenger",
&roster->fMimeMessenger);
} else {
- DBG(OUT(" no (useful) reply from roster: error: %lx: %s\n",
error,
- strerror(error)));
+ DBG(OUT(" no (useful) reply from roster: error: %" B_PRIx32 ":
%s\n",
+ error, strerror(error)));
if (error == B_OK)
DBG(reply.PrintToStream());
}