1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-27 21:01:50 +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

@ -45,7 +45,6 @@ BRMShmImpl::BRMShmImpl(unsigned key, off_t size, bool readOnly) :
fKey(key), fSize(size), fReadOnly(readOnly)
{
string keyName = ShmKeys::keyToName(fKey);
string shmLocation = "/dev/shm/";
if (fSize == 0)
{
@ -107,7 +106,7 @@ again:
}
catch (exception &e) {
ostringstream o;
o << "BRM caught an exception attaching to a shared memory segment: " << b.what();
o << "BRM caught an exception attaching to a shared memory segment (" << keyName << "): " << b.what();
log(o.str());
throw;
}
@ -145,19 +144,7 @@ int BRMShmImpl::grow(unsigned newKey, off_t newSize)
string oldName = fShmobj.get_name();
string keyName = ShmKeys::keyToName(newKey);
#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(newSize);
bi::mapped_region region(shm, bi::read_write);
@ -192,19 +179,7 @@ int BRMShmImpl::clear(unsigned newKey, off_t newSize)
string oldName = fShmobj.get_name();
string keyName = ShmKeys::keyToName(newKey);
#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(newSize);
bi::mapped_region region(shm, bi::read_write);

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);
}