冰羚中间件使用问题
当该中间件在某些平台中的系统内核不支持ACL的时候,启动守护进程RouDi时会出现报错。
问题描述
某些平台中的系统内核不支持ACL的时候,启动守护进程RouDi时会出现报错。
涉及的代码如下:
template <typename SharedMemoryObjectType, typename MemoryManagerType>
inline MePooSegment<SharedMemoryObjectType, MemoryManagerType>::MePooSegment(
const MePooConfig& mempoolConfig,
posix::Allocator& managementAllocator,
const posix::PosixGroup& readerGroup,
const posix::PosixGroup& writerGroup,
const iox::mepoo::MemoryInfo& memoryInfo) noexcept
: m_sharedMemoryObject(std::move(createSharedMemoryObject(mempoolConfig, writerGroup)))
, m_readerGroup(readerGroup)
, m_writerGroup(writerGroup)
, m_memoryInfo(memoryInfo)
{
using namespace posix;
AccessController accessController;
if (!(readerGroup == writerGroup))
{
accessController.addPermissionEntry(
AccessController::Category::SPECIFIC_GROUP, AccessController::Permission::READ, readerGroup.getName());
}
accessController.addPermissionEntry(
AccessController::Category::SPECIFIC_GROUP, AccessController::Permission::READWRITE, writerGroup.getName());
accessController.addPermissionEntry(AccessController::Category::USER, AccessController::Permission::READWRITE);
accessController.addPermissionEntry(AccessController::Category::GROUP, AccessController::Permission::READWRITE);
accessController.addPermissionEntry(AccessController::Category::OTHERS, AccessController::Permission::NONE);
if (!accessController.writePermissionsToFile(m_sharedMemoryObject.getFileHandle()))
{
errorHandler(Error::kMEPOO__SEGMENT_COULD_NOT_APPLY_POSIX_RIGHTS_TO_SHARED_MEMORY);
}
m_memoryManager.configureMemoryManager(mempoolConfig, managementAllocator, *m_sharedMemoryObject.getAllocator());
m_sharedMemoryObject.finalizeAllocation();
}
原因分析:
系统内核不支持ACL
解决方案:
之间注释掉相关代码块
template <typename SharedMemoryObjectType, typename MemoryManagerType>
inline MePooSegment<SharedMemoryObjectType, MemoryManagerType>::MePooSegment(
const MePooConfig& mempoolConfig,
posix::Allocator& managementAllocator,
const posix::PosixGroup& readerGroup,
const posix::PosixGroup& writerGroup,
const iox::mepoo::MemoryInfo& memoryInfo) noexcept
: m_sharedMemoryObject(std::move(createSharedMemoryObject(mempoolConfig, writerGroup)))
, m_readerGroup(readerGroup)
, m_writerGroup(writerGroup)
, m_memoryInfo(memoryInfo)
{
using namespace posix;
AccessController accessController;
if (!(readerGroup == writerGroup))
{
accessController.addPermissionEntry(
AccessController::Category::SPECIFIC_GROUP, AccessController::Permission::READ, readerGroup.getName());
}
accessController.addPermissionEntry(
AccessController::Category::SPECIFIC_GROUP, AccessController::Permission::READWRITE, writerGroup.getName());
accessController.addPermissionEntry(AccessController::Category::USER, AccessController::Permission::READWRITE);
accessController.addPermissionEntry(AccessController::Category::GROUP, AccessController::Permission::READWRITE);
accessController.addPermissionEntry(AccessController::Category::OTHERS, AccessController::Permission::NONE);
// if (!accessController.writePermissionsToFile(m_sharedMemoryObject.getFileHandle()))
// {
// errorHandler(Error::kMEPOO__SEGMENT_COULD_NOT_APPLY_POSIX_RIGHTS_TO_SHARED_MEMORY);
// }
m_memoryManager.configureMemoryManager(mempoolConfig, managementAllocator, *m_sharedMemoryObject.getAllocator());
m_sharedMemoryObject.finalizeAllocation();
}