mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-23 11:16:57 -04:00
git subrepo clone https://github.com/Atmosphere-NX/libstratosphere stratosphere/libstratosphere
subrepo: subdir: "stratosphere/libstratosphere" merged: "0c5dab80" upstream: origin: "https://github.com/Atmosphere-NX/libstratosphere" branch: "master" commit: "0c5dab80" git-subrepo: version: "0.4.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "5d6aba9"
This commit is contained in:
parent
3ea9f444db
commit
f534d3498e
166 changed files with 20474 additions and 0 deletions
47
stratosphere/libstratosphere/source/mitm_server.cpp
Normal file
47
stratosphere/libstratosphere/source/mitm_server.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mutex>
|
||||
#include <switch.h>
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
static HosMutex g_server_query_mutex;
|
||||
static HosThread g_server_query_manager_thread;
|
||||
static SessionManagerBase *g_server_query_manager = nullptr;
|
||||
|
||||
static void ServerQueryManagerThreadFunc(void *arg) {
|
||||
g_server_query_manager->Process();
|
||||
}
|
||||
|
||||
void RegisterMitmServerQueryHandle(Handle query_h, ServiceObjectHolder &&service) {
|
||||
std::scoped_lock<HosMutex> lock(g_server_query_mutex);
|
||||
|
||||
const bool exists = g_server_query_manager != nullptr;
|
||||
if (!exists) {
|
||||
/* Create a new waitable manager if it doesn't exist already. */
|
||||
static auto s_server_query_manager = WaitableManager(1);
|
||||
g_server_query_manager = &s_server_query_manager;
|
||||
}
|
||||
|
||||
/* Add session to the manager. */
|
||||
g_server_query_manager->AddSession(query_h, std::move(service));
|
||||
|
||||
/* If this is our first time, launch thread. */
|
||||
if (!exists) {
|
||||
R_ASSERT(g_server_query_manager_thread.Initialize(&ServerQueryManagerThreadFunc, nullptr, 0x4000, 27));
|
||||
R_ASSERT(g_server_query_manager_thread.Start());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue