From bea38cb711f29e929d62ceed9a0684e43c548a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 11 May 2015 09:10:24 +0200 Subject: [PATCH] registrar: implemented auth port via launch_daemon. * get_roster_port_name() is no longer needed. * This also removes the app_server restart code from the debug server -- this will be done by the launch_daemon in the future. --- data/launch/system | 3 +++ headers/private/app/RegistrarDefs.h | 12 ++++++------ src/kits/app/Application.cpp | 2 +- src/kits/app/RegistrarDefs.cpp | 19 ++----------------- src/servers/debug/DebugServer.cpp | 18 ------------------ .../registrar/AuthenticationManager.cpp | 14 +++++++------- src/servers/registrar/Registrar.cpp | 6 ++---- src/servers/registrar/TRoster.cpp | 2 +- .../libroot/posix/user_group_common.cpp | 12 +++++++++--- 9 files changed, 31 insertions(+), 57 deletions(-) diff --git a/data/launch/system b/data/launch/system index 0653e5f68b..43b1b253c2 100644 --- a/data/launch/system +++ b/data/launch/system @@ -1,5 +1,8 @@ service x-vnd.Haiku-registrar { launch /system/servers/registrar + port auth { + capacity 100 + } } service x-vnd.Haiku-app_server { diff --git a/headers/private/app/RegistrarDefs.h b/headers/private/app/RegistrarDefs.h index ebc879408f..736edbf361 100644 --- a/headers/private/app/RegistrarDefs.h +++ b/headers/private/app/RegistrarDefs.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku, Inc. All Rights Reserved. + * Copyright 2001-2015, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -18,15 +18,13 @@ namespace BPrivate { + // names -extern const char* kRegistrarSignature; -extern const char* kRosterThreadName; extern const char* kRAppLooperPortName; -extern const char* get_roster_port_name(); - -#define REGISTRAR_AUTHENTICATION_PORT_NAME "system:registrar:auth manager" +#define B_REGISTRAR_SIGNATURE "application/x-vnd.haiku-registrar" +#define B_REGISTRAR_AUTHENTICATION_PORT_NAME "auth" // message constants @@ -179,7 +177,9 @@ struct flat_app_info { char ref_name[B_FILE_NAME_LENGTH + 1]; }; + } // namespace BPrivate + #endif // REGISTRAR_DEFS_H diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp index d6edd8a99b..8a08413ea7 100644 --- a/src/kits/app/Application.cpp +++ b/src/kits/app/Application.cpp @@ -362,7 +362,7 @@ BApplication::_InitData(const char* signature, bool initGUI, status_t* _error) #ifndef RUN_WITHOUT_REGISTRAR bool registerApp = signature == NULL - || (strcasecmp(signature, kRegistrarSignature) != 0 + || (strcasecmp(signature, B_REGISTRAR_SIGNATURE) != 0 && strcasecmp(signature, kLaunchDaemonSignature) != 0); // get team and thread team_id team = Team(); diff --git a/src/kits/app/RegistrarDefs.cpp b/src/kits/app/RegistrarDefs.cpp index b644d46589..9137c8da09 100644 --- a/src/kits/app/RegistrarDefs.cpp +++ b/src/kits/app/RegistrarDefs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2009, Haiku. + * Copyright 2001-2015, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -16,28 +16,13 @@ namespace BPrivate { + // names #ifdef HAIKU_TARGET_PLATFORM_HAIKU -const char* kRegistrarSignature = "application/x-vnd.haiku-registrar"; const char* kRAppLooperPortName = "rAppLooperPort"; #else -const char* kRegistrarSignature = "application/x-vnd.test-registrar"; const char* kRAppLooperPortName = "haiku-test:rAppLooperPort"; #endif -const char* kRosterThreadName = "_roster_thread_"; -/*! \brief Returns the name of the main request port of the registrar (roster). - \return the name of the registrar request port. -*/ -const char* -get_roster_port_name() -{ -#ifdef HAIKU_TARGET_PLATFORM_HAIKU - return "system:roster"; -#else - return "haiku-test:roster"; -#endif -} - } // namespace BPrivate diff --git a/src/servers/debug/DebugServer.cpp b/src/servers/debug/DebugServer.cpp index b438727662..764916f4a2 100644 --- a/src/servers/debug/DebugServer.cpp +++ b/src/servers/debug/DebugServer.cpp @@ -1021,8 +1021,6 @@ TeamDebugHandler::_HandlerThread() "initial message: %s", strerror(error)); } - bool isGuiServer = _IsGUIServer(); - // kill the team or hand it over to the debugger thread_id debuggerThread = -1; if (debugAction == kActionKillTeam) { @@ -1078,22 +1076,6 @@ TeamDebugHandler::_HandlerThread() // remove this handler from the roster and delete it TeamDebugHandlerRoster::Default()->RemoveHandler(fTeam); - if (isGuiServer) { - // wait till debugging is done - status_t dummy; - wait_for_thread(debuggerThread, &dummy); - - // find the registrar port - port_id rosterPort = find_port(BPrivate::get_roster_port_name()); - port_info info; - BMessenger messenger; - if (rosterPort >= 0 && get_port_info(rosterPort, &info) == B_OK) { - BMessenger::Private(messenger).SetTo(info.team, rosterPort, - B_PREFERRED_TOKEN); - } - messenger.SendMessage(kMsgRestartAppServer); - } - delete this; return B_OK; diff --git a/src/servers/registrar/AuthenticationManager.cpp b/src/servers/registrar/AuthenticationManager.cpp index 57742db88c..f8fa1072c3 100644 --- a/src/servers/registrar/AuthenticationManager.cpp +++ b/src/servers/registrar/AuthenticationManager.cpp @@ -3,6 +3,7 @@ * Distributed under the terms of the MIT License. */ + #include "AuthenticationManager.h" #include @@ -19,6 +20,7 @@ #include #include +#include #include #include @@ -723,12 +725,9 @@ AuthenticationManager::AuthenticationManager() AuthenticationManager::~AuthenticationManager() { - // delete port and wait for the request thread to finish - if (fRequestPort >= 0) - delete_port(fRequestPort); - - status_t dummy; - wait_for_thread(fRequestThread, &dummy); + // Quit the request thread and wait for it to finish + write_port(fRequestPort, 'quit', NULL, 0); + wait_for_thread(fRequestThread, NULL); delete fUserDB; delete fGroupDB; @@ -752,7 +751,8 @@ AuthenticationManager::Init() return B_NO_MEMORY; } - fRequestPort = create_port(100, REGISTRAR_AUTHENTICATION_PORT_NAME); + fRequestPort = BLaunchRoster().GetPort( + B_REGISTRAR_AUTHENTICATION_PORT_NAME); if (fRequestPort < 0) return fRequestPort; diff --git a/src/servers/registrar/Registrar.cpp b/src/servers/registrar/Registrar.cpp index f905ce3288..79b3d02a66 100644 --- a/src/servers/registrar/Registrar.cpp +++ b/src/servers/registrar/Registrar.cpp @@ -57,8 +57,7 @@ static const bigtime_t kRosterSanityEventInterval = 1000000LL; */ Registrar::Registrar(status_t* _error) : - BServer(kRegistrarSignature, BPrivate::get_roster_port_name(), -1, - false, _error), + BServer(B_REGISTRAR_SIGNATURE, "system:roster", -1, false, _error), fRoster(NULL), fClipboardHandler(NULL), fMIMEManager(NULL), @@ -434,7 +433,6 @@ main() // app thread. be_clipboard = new BClipboard(NULL); - // create and run the registrar application status_t error; Registrar *app = new Registrar(&error); @@ -445,7 +443,7 @@ main() } // rename the main thread - rename_thread(find_thread(NULL), kRosterThreadName); + rename_thread(find_thread(NULL), "roster"); PRINT("app->Run()...\n"); diff --git a/src/servers/registrar/TRoster.cpp b/src/servers/registrar/TRoster.cpp index 6ec58e3b9c..dab9b8f644 100644 --- a/src/servers/registrar/TRoster.cpp +++ b/src/servers/registrar/TRoster.cpp @@ -1247,7 +1247,7 @@ TRoster::Init() if (error == B_OK) { info->Init(be_app->Thread(), be_app->Team(), BMessenger::Private(be_app_messenger).Port(), - B_EXCLUSIVE_LAUNCH | B_BACKGROUND_APP, &ref, kRegistrarSignature); + B_EXCLUSIVE_LAUNCH | B_BACKGROUND_APP, &ref, B_REGISTRAR_SIGNATURE); info->state = APP_STATE_REGISTERED; info->registration_time = system_time(); error = AddApp(info); diff --git a/src/system/libroot/posix/user_group_common.cpp b/src/system/libroot/posix/user_group_common.cpp index 6249d3b900..5c234bf2f9 100644 --- a/src/system/libroot/posix/user_group_common.cpp +++ b/src/system/libroot/posix/user_group_common.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -54,9 +55,14 @@ BPrivate::user_group_unlock() port_id BPrivate::get_registrar_authentication_port() { - if (sRegistrarPort < 0) - sRegistrarPort = find_port(REGISTRAR_AUTHENTICATION_PORT_NAME); - + if (sRegistrarPort < 0) { + BPrivate::KMessage data; + if (BPrivate::get_launch_data(B_REGISTRAR_SIGNATURE, data) + == B_OK) { + sRegistrarPort = data.GetInt32( + B_REGISTRAR_AUTHENTICATION_PORT_NAME "_port", -1); + } + } return sRegistrarPort; }