You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-520. Removed chmod stuff from MST and did a little cleaning.
This commit is contained in:
@ -45,7 +45,6 @@ BRMShmImpl::BRMShmImpl(unsigned key, off_t size, bool readOnly) :
|
|||||||
fKey(key), fSize(size), fReadOnly(readOnly)
|
fKey(key), fSize(size), fReadOnly(readOnly)
|
||||||
{
|
{
|
||||||
string keyName = ShmKeys::keyToName(fKey);
|
string keyName = ShmKeys::keyToName(fKey);
|
||||||
string shmLocation = "/dev/shm/";
|
|
||||||
|
|
||||||
if (fSize == 0)
|
if (fSize == 0)
|
||||||
{
|
{
|
||||||
@ -107,7 +106,7 @@ again:
|
|||||||
}
|
}
|
||||||
catch (exception &e) {
|
catch (exception &e) {
|
||||||
ostringstream o;
|
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());
|
log(o.str());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
@ -145,19 +144,7 @@ int BRMShmImpl::grow(unsigned newKey, off_t newSize)
|
|||||||
string oldName = fShmobj.get_name();
|
string oldName = fShmobj.get_name();
|
||||||
|
|
||||||
string keyName = ShmKeys::keyToName(newKey);
|
string keyName = ShmKeys::keyToName(newKey);
|
||||||
#if BOOST_VERSION < 104500
|
|
||||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
|
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);
|
shm.truncate(newSize);
|
||||||
|
|
||||||
bi::mapped_region region(shm, bi::read_write);
|
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 oldName = fShmobj.get_name();
|
||||||
|
|
||||||
string keyName = ShmKeys::keyToName(newKey);
|
string keyName = ShmKeys::keyToName(newKey);
|
||||||
#if BOOST_VERSION < 104500
|
|
||||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
|
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);
|
shm.truncate(newSize);
|
||||||
|
|
||||||
bi::mapped_region region(shm, bi::read_write);
|
bi::mapped_region region(shm, bi::read_write);
|
||||||
|
@ -75,51 +75,32 @@ MasterSegmentTableImpl::MasterSegmentTableImpl(int key, int size)
|
|||||||
{
|
{
|
||||||
string keyName = ShmKeys::keyToName(key);
|
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
|
try
|
||||||
{
|
{
|
||||||
#if BOOST_VERSION < 104500
|
|
||||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
|
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);
|
shm.truncate(size);
|
||||||
fShmobj.swap(shm);
|
fShmobj.swap(shm);
|
||||||
}
|
}
|
||||||
catch (bi::interprocess_exception& biex)
|
catch (bi::interprocess_exception& biex)
|
||||||
{
|
{
|
||||||
bi::shared_memory_object shm(bi::open_only, keyName.c_str(), bi::read_write);
|
if (biex.get_error_code() == bi::already_exists_error) {
|
||||||
#ifdef __linux__
|
try {
|
||||||
{
|
bi::shared_memory_object shm(bi::open_only, keyName.c_str(), bi::read_write);
|
||||||
string pname = shmLocation + keyName;
|
fShmobj.swap(shm);
|
||||||
chmod(pname.c_str(), 0666);
|
}
|
||||||
|
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);
|
bi::mapped_region region(fShmobj, bi::read_write);
|
||||||
fMapreg.swap(region);
|
fMapreg.swap(region);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user