[haiku-commits] BRANCH axeld-github.launch_daemon [e8097e94eb1c] src/kits/app headers/private/app

  • From: axeld-github.launch_daemon <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 9 Jun 2015 22:46:44 +0200 (CEST)

added 1 changeset to branch 'refs/remotes/axeld-github/launch_daemon'
old head: 9539843dbfba9b2c2e54e6cb2a51eea59227df06
new head: e8097e94eb1c1ee987d2e14d08bca4b4af8942e4
overview: https://github.com/axeld/haiku/compare/9539843dbfba...e8097e94eb1c

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

e8097e94eb1c: libbe: Fixed current_team() to work after a fork.

* This allows to start a valid looper in the forked child, for example.

[ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]

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

Commit: e8097e94eb1c1ee987d2e14d08bca4b4af8942e4
Author: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date: Tue Jun 9 20:37:09 2015 UTC

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

3 files changed, 17 insertions(+), 5 deletions(-)
headers/private/app/AppMisc.h | 1 +
src/kits/app/AppMisc.cpp | 19 ++++++++++++++-----
src/kits/app/InitTerminateLibBe.cpp | 2 ++

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

diff --git a/headers/private/app/AppMisc.h b/headers/private/app/AppMisc.h
index 37a1ab4..4ddac85 100644
--- a/headers/private/app/AppMisc.h
+++ b/headers/private/app/AppMisc.h
@@ -25,6 +25,7 @@ status_t get_app_ref(team_id team, entry_ref *ref, bool
traverse = true);
status_t get_app_ref(entry_ref *ref, bool traverse = true);

team_id current_team();
+void init_team_after_fork();
thread_id main_thread_for(team_id team);

bool is_app_showing_modal_window(team_id team);
diff --git a/src/kits/app/AppMisc.cpp b/src/kits/app/AppMisc.cpp
index 9568713..1a607f7 100644
--- a/src/kits/app/AppMisc.cpp
+++ b/src/kits/app/AppMisc.cpp
@@ -27,6 +27,9 @@
namespace BPrivate {


+static team_id sCurrentTeam = -1;
+
+
/*! \brief Returns the path to an application's executable.
\param team The application's team ID.
\param buffer A pointer to a pre-allocated character array of at least
@@ -125,13 +128,19 @@ get_app_ref(entry_ref *ref, bool traverse)
team_id
current_team()
{
- static team_id team = -1;
- if (team < 0) {
+ if (sCurrentTeam < 0) {
thread_info info;
if (get_thread_info(find_thread(NULL), &info) == B_OK)
- team = info.team;
+ sCurrentTeam = info.team;
}
- return team;
+ return sCurrentTeam;
+}
+
+
+void
+init_team_after_fork()
+{
+ sCurrentTeam = -1;
}


@@ -149,7 +158,7 @@ main_thread_for(team_id team)
// a team info to verify the existence of the team.
team_info info;
status_t error = get_team_info(team, &info);
- return (error == B_OK ? team : error);
+ return error == B_OK ? team : error;
}


diff --git a/src/kits/app/InitTerminateLibBe.cpp
b/src/kits/app/InitTerminateLibBe.cpp
index 469e270..03f4a02 100644
--- a/src/kits/app/InitTerminateLibBe.cpp
+++ b/src/kits/app/InitTerminateLibBe.cpp
@@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>

+#include <AppMisc.h>
#include <LooperList.h>
#include <MessagePrivate.h>
#include <RosterPrivate.h>
@@ -35,6 +36,7 @@ initialize_forked_child()
BMessage::Private::StaticReInitForkedChild();
BPrivate::gLooperList.InitAfterFork();
BPrivate::gDefaultTokens.InitAfterFork();
+ BPrivate::init_team_after_fork();

DBG(OUT("initialize_forked_child() done\n"));
}


Other related posts: