Skip to content
This repository has been archived by the owner on May 3, 2021. It is now read-only.

Commit

Permalink
Fixed Issue #322 (Memory spike at opening service)
Browse files Browse the repository at this point in the history
* Shared memory mapped files now opened in "shared_mem" folder adjacent PSMoveService.exe
* This fixes occasional weird issues with trying to open temp folders in c:\ProgramData\boost_interprocess
  • Loading branch information
HipsterSloth committed Jan 7, 2017
1 parent e6792bd commit b82a563
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/psmoveprotocol/SharedTrackerState.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef SHARED_TRACKER_STATE_H
#define SHARED_TRACKER_STATE_H

#ifdef WIN32
#define BOOST_INTERPROCESS_SHARED_DIR_PATH "shared_mem"
#endif // WIN32

#include <boost/interprocess/sync/interprocess_mutex.hpp>

class SharedVideoFrameHeader
Expand Down
18 changes: 17 additions & 1 deletion src/psmoveservice/Server/PSMoveService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "ServerNetworkManager.h"
#include "ServerRequestHandler.h"
#include "DeviceManager.h"
#include "ProtocolVersion.h"
#include "ServerLog.h"
#include "SharedTrackerState.h"
#include "TrackerManager.h"

#include <boost/asio.hpp>
Expand Down Expand Up @@ -137,6 +139,20 @@ class PSMoveServiceImpl
bool startup()
{
bool success= true;

/** Make sure the shared memory directory exists (if non-default path is defined) */
#if defined(BOOST_INTERPROCESS_SHARED_DIR_PATH)
boost::filesystem::path shared_mem_dir(BOOST_INTERPROCESS_SHARED_DIR_PATH);
boost::system::error_code ec;
if (!boost::filesystem::create_directory(shared_mem_dir, ec))
{
if(ec.value() != boost::interprocess::already_exists_error && ec.value() != boost::interprocess::no_error)
{
SERVER_LOG_FATAL("PSMoveService") << "Failed to create the shared memory directory: " << ec.message();
success= false;
}
}
#endif // BOOST_INTERPROCESS_SHARED_DIR_PATH

/** Start listening for client connections */
if (success)
Expand Down Expand Up @@ -503,7 +519,7 @@ int PSMoveService::exec(int argc, char *argv[])
log_init(this->getProgramSettings()->log_level, "PSMoveService.log");

// Start the service app
SERVER_LOG_INFO("main") << "Starting PSMoveService";
SERVER_LOG_INFO("main") << "Starting PSMoveService v" << PSM_DETAILED_VERSION_STRING;
try
{
PSMoveServiceImpl app;
Expand Down

0 comments on commit b82a563

Please sign in to comment.