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

MCOL-520. Got rid of the chmods on shmsegs & added

better error msgs.  Untested.
This commit is contained in:
Patrick LeBlanc
2018-10-04 11:11:35 -05:00
parent 1b1026bbe4
commit f514ed6775

View File

@ -45,16 +45,6 @@ BRMShmImpl::BRMShmImpl(unsigned key, off_t size, bool readOnly) :
fKey(key), fSize(size), fReadOnly(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 (fSize == 0)
@ -98,43 +88,42 @@ again:
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
idbassert(fSize > 0);
shm.truncate(fSize);
fShmobj.swap(shm);
}
catch (bi::interprocess_exception&)
catch (bi::interprocess_exception &b)
{
bi::shared_memory_object shm(bi::open_only, keyName.c_str(), bi::read_write);
if (b.get_error_code() != bi::already_exists_error) {
ostringstream o;
o << "BRM caught an exception creating a shared memory segment: " << b.what();
log(o.str());
throw;
}
bi::shared_memory_object *shm = NULL;
try {
shm = new bi::shared_memory_object(bi::open_only, keyName.c_str(), bi::read_write);
}
catch (exception &e) {
ostringstream o;
o << "BRM caught an exception attaching to a shared memory segment: " << b.what();
log(o.str());
throw;
}
off_t curSize = 0;
#ifdef _MSC_VER
bi::offset_t tmp = 0;
shm.get_size(tmp);
curSize = static_cast<off_t>(tmp);
#else
shm.get_size(curSize);
shm->get_size(curSize);
#endif
idbassert(curSize > 0);
idbassert(curSize >= fSize);
fShmobj.swap(shm);
fShmobj.swap(*shm);
fSize = curSize;
}
catch (...)
{
throw;
}
if (fReadOnly)
{