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. More untested changes.
Went down the list in shmkeys.h, added sane error msgs on perms errors accessing rest of the shmsegs there. Realized we probably do need 666 to the shmsegs. Also deleted a little dead code that was copy-pasted everywhere.
This commit is contained in:
@ -32,10 +32,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <boost/interprocess/shared_memory_object.hpp>
|
||||
#include <boost/interprocess/mapped_region.hpp>
|
||||
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
|
||||
|
||||
#include "calpontsystemcatalog.h"
|
||||
#include "sessionmanager.h"
|
||||
#include "shmkeys.h"
|
||||
|
@ -584,18 +584,6 @@ int main(int argc, char* argv[])
|
||||
if (temp > 0)
|
||||
serverQueueSize = temp;
|
||||
|
||||
|
||||
bool rootUser = true;
|
||||
#ifndef _MSC_VER
|
||||
//check if root-user
|
||||
int user;
|
||||
user = getuid();
|
||||
|
||||
if (user != 0)
|
||||
rootUser = false;
|
||||
|
||||
#endif
|
||||
|
||||
//read and cleanup port before trying to use
|
||||
try
|
||||
{
|
||||
|
@ -73,7 +73,9 @@ bool getshm(const string &name, int size, bi::shared_memory_object &target) {
|
||||
bool created = false;
|
||||
try
|
||||
{
|
||||
bi::shared_memory_object shm(bi::create_only, name.c_str(), bi::read_write);
|
||||
bi::permissions perms;
|
||||
perms.set_unrestricted();
|
||||
bi::shared_memory_object shm(bi::create_only, name.c_str(), bi::read_write, perms);
|
||||
created = true;
|
||||
shm.truncate(size);
|
||||
target.swap(shm);
|
||||
|
@ -220,7 +220,6 @@ int main(int argc, char** argv)
|
||||
shmDoit(BrmKeys.PROCESSSTATUS_SYSVKEY, "PROC_STAT ");
|
||||
shmDoit(BrmKeys.SYSTEMSTATUS_SYSVKEY, "SYS_STAT ");
|
||||
shmDoit(BrmKeys.SWITCHSTATUS_SYSVKEY, "SW_STAT ");
|
||||
shmDoit(BrmKeys.STORAGESTATUS_SYSVKEY, "STORE_STAT ");
|
||||
shmDoit(BrmKeys.NICSTATUS_SYSVKEY, "NIC_STAT ");
|
||||
shmDoit(BrmKeys.DBROOTSTATUS_SYSVKEY, "DBROOT_STAT");
|
||||
}
|
||||
@ -239,7 +238,6 @@ int main(int argc, char** argv)
|
||||
semDoit(BrmKeys.PROCESSSTATUS_SYSVKEY, "PROC_STAT ");
|
||||
semDoit(BrmKeys.SYSTEMSTATUS_SYSVKEY, "SYS_STAT ");
|
||||
semDoit(BrmKeys.SWITCHSTATUS_SYSVKEY, "SW_STAT ");
|
||||
semDoit(BrmKeys.STORAGESTATUS_SYSVKEY, "STORE_STAT ");
|
||||
semDoit(BrmKeys.NICSTATUS_SYSVKEY, "NIC_STAT ");
|
||||
shmDoit(BrmKeys.DBROOTSTATUS_SYSVKEY, "DBROOT_STAT");
|
||||
}
|
||||
|
@ -188,13 +188,9 @@ void initCtlShm()
|
||||
}
|
||||
catch (bi::interprocess_exception&)
|
||||
{
|
||||
#if BOOST_VERSION < 104500
|
||||
bi::shared_memory_object shm(bi::create_only, DecomShmName.c_str(), bi::read_write);
|
||||
#else
|
||||
bi::permissions perms;
|
||||
perms.set_unrestricted();
|
||||
bi::shared_memory_object shm(bi::create_only, DecomShmName.c_str(), bi::read_write, perms);
|
||||
#endif
|
||||
shm.truncate(sizeof(CtlShmImage));
|
||||
bi::mapped_region region(shm, bi::read_write);
|
||||
tmpptr = new (region.get_address()) CtlShmImage;
|
||||
|
@ -143,32 +143,11 @@ RWLockShmImpl::RWLockShmImpl(int key, bool excl)
|
||||
string keyName = BRM::ShmKeys::keyToName(key);
|
||||
fKeyString = keyName;
|
||||
|
||||
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(sizeof(struct State));
|
||||
fStateShm.swap(shm);
|
||||
bi::mapped_region region(fStateShm, bi::read_write);
|
||||
@ -190,10 +169,7 @@ RWLockShmImpl::RWLockShmImpl(int key, bool excl)
|
||||
catch (bi::interprocess_exception&)
|
||||
{
|
||||
if (excl)
|
||||
{
|
||||
//don't think we can get here anymore...
|
||||
throw not_excl();
|
||||
}
|
||||
|
||||
bi::shared_memory_object shm(bi::open_only, keyName.c_str(), bi::read_write);
|
||||
fStateShm.swap(shm);
|
||||
|
@ -64,12 +64,7 @@ again:
|
||||
#endif
|
||||
|
||||
if (curSize == 0) throw
|
||||
#if BOOST_VERSION < 104500
|
||||
bi::interprocess_exception();
|
||||
|
||||
#else
|
||||
bi::interprocess_exception("shm size is zero");
|
||||
#endif
|
||||
}
|
||||
catch (bi::interprocess_exception&)
|
||||
{
|
||||
@ -87,7 +82,9 @@ again:
|
||||
|
||||
try
|
||||
{
|
||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
|
||||
bi::permissions perms;
|
||||
perms.set_unrestricted();
|
||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write, perms);
|
||||
idbassert(fSize > 0);
|
||||
shm.truncate(fSize);
|
||||
fShmobj.swap(shm);
|
||||
@ -113,7 +110,7 @@ again:
|
||||
off_t curSize = 0;
|
||||
#ifdef _MSC_VER
|
||||
bi::offset_t tmp = 0;
|
||||
shm.get_size(tmp);
|
||||
shm->get_size(tmp);
|
||||
curSize = static_cast<off_t>(tmp);
|
||||
#else
|
||||
shm->get_size(curSize);
|
||||
@ -121,6 +118,7 @@ again:
|
||||
idbassert(curSize > 0);
|
||||
idbassert(curSize >= fSize);
|
||||
fShmobj.swap(*shm);
|
||||
delete shm;
|
||||
fSize = curSize;
|
||||
}
|
||||
|
||||
@ -144,7 +142,9 @@ int BRMShmImpl::grow(unsigned newKey, off_t newSize)
|
||||
string oldName = fShmobj.get_name();
|
||||
|
||||
string keyName = ShmKeys::keyToName(newKey);
|
||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
|
||||
bi::permissions perms;
|
||||
perms.set_unrestricted();
|
||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write, perms);
|
||||
shm.truncate(newSize);
|
||||
|
||||
bi::mapped_region region(shm, bi::read_write);
|
||||
@ -179,7 +179,9 @@ int BRMShmImpl::clear(unsigned newKey, off_t newSize)
|
||||
string oldName = fShmobj.get_name();
|
||||
|
||||
string keyName = ShmKeys::keyToName(newKey);
|
||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
|
||||
bi::permissions perms;
|
||||
perms.set_unrestricted();
|
||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write, perms);
|
||||
shm.truncate(newSize);
|
||||
|
||||
bi::mapped_region region(shm, bi::read_write);
|
||||
|
@ -77,7 +77,9 @@ MasterSegmentTableImpl::MasterSegmentTableImpl(int key, int size)
|
||||
|
||||
try
|
||||
{
|
||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write);
|
||||
bi::permissions perms;
|
||||
perms.set_unrestricted();
|
||||
bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write, perms);
|
||||
shm.truncate(size);
|
||||
fShmobj.swap(shm);
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ ShmKeys::ShmKeys()
|
||||
PROCESSSTATUS_SYSVKEY = 0xfd000000 | BRM_UID;
|
||||
SYSTEMSTATUS_SYSVKEY = 0xfc000000 | BRM_UID;
|
||||
SWITCHSTATUS_SYSVKEY = 0xfb000000 | BRM_UID;
|
||||
STORAGESTATUS_SYSVKEY = 0xfa000000 | BRM_UID;
|
||||
NICSTATUS_SYSVKEY = 0xf9000000 | BRM_UID;
|
||||
DBROOTSTATUS_SYSVKEY = 0xf8000000 | BRM_UID;
|
||||
DECOMSVRMUTEX_SYSVKEY = 0xf7000000 | BRM_UID;
|
||||
|
@ -61,7 +61,6 @@ public:
|
||||
uint32_t PROCESSSTATUS_SYSVKEY;
|
||||
uint32_t SYSTEMSTATUS_SYSVKEY;
|
||||
uint32_t SWITCHSTATUS_SYSVKEY;
|
||||
uint32_t STORAGESTATUS_SYSVKEY;
|
||||
uint32_t NICSTATUS_SYSVKEY;
|
||||
uint32_t DBROOTSTATUS_SYSVKEY;
|
||||
uint32_t DECOMSVRMUTEX_SYSVKEY;
|
||||
|
Reference in New Issue
Block a user