You've already forked mariadb-columnstore-engine
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:
@ -45,16 +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);
|
||||||
|
|
||||||
bool rootUser = true;
|
|
||||||
|
|
||||||
//check if root-user
|
|
||||||
int user;
|
|
||||||
user = getuid();
|
|
||||||
|
|
||||||
if (user != 0)
|
|
||||||
rootUser = false;
|
|
||||||
|
|
||||||
string shmLocation = "/dev/shm/";
|
string shmLocation = "/dev/shm/";
|
||||||
|
|
||||||
if (fSize == 0)
|
if (fSize == 0)
|
||||||
@ -98,43 +88,42 @@ again:
|
|||||||
|
|
||||||
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
|
|
||||||
idbassert(fSize > 0);
|
idbassert(fSize > 0);
|
||||||
shm.truncate(fSize);
|
shm.truncate(fSize);
|
||||||
fShmobj.swap(shm);
|
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;
|
off_t curSize = 0;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
bi::offset_t tmp = 0;
|
bi::offset_t tmp = 0;
|
||||||
shm.get_size(tmp);
|
shm.get_size(tmp);
|
||||||
curSize = static_cast<off_t>(tmp);
|
curSize = static_cast<off_t>(tmp);
|
||||||
#else
|
#else
|
||||||
shm.get_size(curSize);
|
shm->get_size(curSize);
|
||||||
#endif
|
#endif
|
||||||
idbassert(curSize > 0);
|
idbassert(curSize > 0);
|
||||||
idbassert(curSize >= fSize);
|
idbassert(curSize >= fSize);
|
||||||
fShmobj.swap(shm);
|
fShmobj.swap(*shm);
|
||||||
fSize = curSize;
|
fSize = curSize;
|
||||||
}
|
}
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fReadOnly)
|
if (fReadOnly)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user