Skip to content

Commit

Permalink
Add new exported function to terminate the crash handler
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyStreamlabs committed Oct 24, 2018
1 parent 6b0bfd8 commit 8e0ffb4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
14 changes: 13 additions & 1 deletion obs-studio-client/source/nodeobs_api.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "nodeobs_api.hpp"
#include "controller.hpp"
#include "error.hpp"
#include "nodeobs_api.hpp"
#include "utility-v8.hpp"

#include <node.h>
Expand Down Expand Up @@ -141,6 +141,17 @@ void api::SetWorkingDirectory(const v8::FunctionCallbackInfo<v8::Value>& args)
ValidateResponse(response);
}

void api::StopCrashHandler(const v8::FunctionCallbackInfo<v8::Value>& args)
{
auto conn = GetConnection();
if (!conn)
return;

std::vector<ipc::value> response = conn->call_synchronous_helper("API", "StopCrashHandler", {});

ValidateResponse(response);
}

INITIALIZER(nodeobs_api)
{
initializerFunctions.push([](v8::Local<v8::Object> exports) {
Expand All @@ -152,5 +163,6 @@ INITIALIZER(nodeobs_api)
exports, "OBS_API_getOBS_existingSceneCollections", api::OBS_API_getOBS_existingSceneCollections);
NODE_SET_METHOD(exports, "OBS_API_isOBS_installed", api::OBS_API_isOBS_installed);
NODE_SET_METHOD(exports, "SetWorkingDirectory", api::SetWorkingDirectory);
NODE_SET_METHOD(exports, "StopCrashHandler", api::StopCrashHandler);
});
}
1 change: 1 addition & 0 deletions obs-studio-client/source/nodeobs_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ namespace api
static void OBS_API_getOBS_existingSceneCollections(const v8::FunctionCallbackInfo<v8::Value>& args);
static void OBS_API_isOBS_installed(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetWorkingDirectory(const v8::FunctionCallbackInfo<v8::Value>& args);
static void StopCrashHandler(const v8::FunctionCallbackInfo<v8::Value>& args);
} // namespace api
14 changes: 13 additions & 1 deletion obs-studio-server/source/nodeobs_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ void OBS_API::Register(ipc::server& srv)
std::make_shared<ipc::function>("OBS_API_isOBS_installed", std::vector<ipc::type>{}, OBS_API_isOBS_installed));
cls->register_function(std::make_shared<ipc::function>(
"SetWorkingDirectory", std::vector<ipc::type>{ipc::type::String}, SetWorkingDirectory));
cls->register_function(std::make_shared<ipc::function>(
"StopCrashHandler", std::vector<ipc::type>{}, StopCrashHandler));

srv.register_collection(cls);
}
Expand Down Expand Up @@ -800,11 +802,21 @@ static void SaveProfilerData(const profiler_snapshot_t* snap)
blog(LOG_WARNING, "Could not save profiler data to '%s'", dst.c_str());
}

void OBS_API::destroyOBS_API(void)
void OBS_API::StopCrashHandler(
void* data,
const int64_t id,
const std::vector<ipc::value>& args,
std::vector<ipc::value>& rval)
{
writeCrashHandler(unregisterProcess());
writeCrashHandler(terminateCrashHandler());

rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
AUTO_DEBUG;
}

void OBS_API::destroyOBS_API(void)
{
os_cpu_usage_info_destroy(cpuUsageInfo);

#ifdef _WIN32
Expand Down
5 changes: 5 additions & 0 deletions obs-studio-server/source/nodeobs_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class OBS_API
const int64_t id,
const std::vector<ipc::value>& args,
std::vector<ipc::value>& rval);
static void StopCrashHandler(
void* data,
const int64_t id,
const std::vector<ipc::value>& args,
std::vector<ipc::value>& rval);

private:
static void initAPI(void);
Expand Down

0 comments on commit 8e0ffb4

Please sign in to comment.