1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-520. Removed chmod stuff from MST and did a little cleaning.

This commit is contained in:
Patrick LeBlanc
2018-10-04 11:27:08 -05:00
parent f514ed6775
commit a35009c8ee
2 changed files with 17 additions and 61 deletions

View File

@ -75,51 +75,32 @@ MasterSegmentTableImpl::MasterSegmentTableImpl(int key, int size)
{
string keyName = ShmKeys::keyToName(key);
bool rootUser = true;
//check if root-user
int user;
user = getuid();
if (user != 0)
rootUser = false;
string shmLocation = "/dev/shm/";
try
{
#if BOOST_VERSION < 104500
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
#ifdef __linux__
{
string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666);
}
#endif
#else
bi::permissions perms;
perms.set_unrestricted();
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write, perms);
#endif
shm.truncate(size);
fShmobj.swap(shm);
}
catch (bi::interprocess_exception& biex)
{
bi::shared_memory_object shm(bi::open_only, keyName.c_str(), bi::read_write);
#ifdef __linux__
{
string pname = shmLocation + keyName;
chmod(pname.c_str(), 0666);
if (biex.get_error_code() == bi::already_exists_error) {
try {
bi::shared_memory_object shm(bi::open_only, keyName.c_str(), bi::read_write);
fShmobj.swap(shm);
}
catch (exception &e) {
ostringstream o;
o << "BRM caught an exception attaching to a shared memory segment (" << keyName << "): " << e.what();
throw;
}
}
else {
ostringstream o;
o << "BRM caught an exception creating a shared memory segment (" << keyName << "): " << biex.what();
log(o.str());
throw;
}
#endif
fShmobj.swap(shm);
}
catch (...)
{
throw;
}
bi::mapped_region region(fShmobj, bi::read_write);
fMapreg.swap(region);
}