1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-27 21:01:50 +03:00

MCOL-520 - initial changes for /dev/shm

This commit is contained in:
David Hill
2018-10-01 14:39:17 -05:00
parent 05bcd58e76
commit 8d3ce9757f
6 changed files with 68 additions and 12 deletions

View File

@ -36,6 +36,8 @@ namespace bi = boost::interprocess;
#include "brmshmimpl.h"
#include "brmtypes.h"
#include "installdir.h"
namespace BRM
{
@ -44,6 +46,19 @@ BRMShmImpl::BRMShmImpl(unsigned key, off_t size, bool readOnly) :
{
string keyName = ShmKeys::keyToName(fKey);
bool rootUser = true;
//check if root-user
int user;
user = getuid();
if (user != 0)
rootUser = false;
string shmLocation = "/dev/shm/";
if ( !rootUser)
shmLocation = startup::StartUp::installDir() + "/dev/shm/";
if (fSize == 0)
{
unsigned tries = 0;
@ -89,7 +104,7 @@ again:
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__
{
string pname = "/dev/shm/" + keyName;
string pname = "shmLocation + keyName;
chmod(pname.c_str(), 0666);
}
#endif
@ -147,7 +162,7 @@ int BRMShmImpl::grow(unsigned newKey, off_t newSize)
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__
{
string pname = "/dev/shm/" + keyName;
string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666);
}
#endif
@ -194,7 +209,7 @@ int BRMShmImpl::clear(unsigned newKey, off_t newSize)
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__
{
string pname = "/dev/shm/" + keyName;
string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666);
}
#endif