bool cac::accessRightsRespAction (
    callbackManager & mgr, tcpiiu &,
    const epicsTime &, const caHdrLargeArray & hdr, void * /* pMsgBody */ )
{
    epicsGuard < epicsMutex > guard ( this->mutex );
    nciu * pChan = this->chanTable.lookup ( hdr.m_cid );
    if ( pChan ) {
        unsigned ar = hdr.m_available;
        caAccessRights accessRights ( 
            ( ar & CA_PROTO_ACCESS_RIGHT_READ ) ? true : false, 
            ( ar & CA_PROTO_ACCESS_RIGHT_WRITE ) ? true : false); 
        pChan->accessRightsStateChange ( accessRights, mgr.cbGuard, guard );
    }

    return true;
}
Exemple #2
0
PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection protection)
{
    DWORD desiredAccess = accessRights(protection);

    void* baseAddress = ::MapViewOfFile(handle.m_handle, desiredAccess, 0, 0, handle.m_size);
    if (!baseAddress)
        return 0;

    RefPtr<SharedMemory> memory = adoptRef(new SharedMemory);
    memory->m_size = handle.m_size;
    memory->m_data = baseAddress;

    // Adopt the HANDLE.
    memory->m_handle = handle.m_handle;
    handle.m_handle = 0;

    return memory.release();
}
PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection protection)
{
    if (handle.isNull())
        return 0;

    DWORD desiredAccess = accessRights(protection);

    void* baseAddress = ::MapViewOfFile(handle.m_handle, desiredAccess, 0, 0, handle.m_size);
    ASSERT_WITH_MESSAGE(baseAddress, "::MapViewOfFile failed with error %lu", ::GetLastError());
    if (!baseAddress)
        return 0;

    RefPtr<SharedMemory> memory = adoptRef(new SharedMemory);
    memory->m_size = handle.m_size;
    memory->m_data = baseAddress;

    // Adopt the HANDLE.
    memory->m_handle = handle.m_handle;
    handle.m_handle = 0;

    return memory.release();
}
bool SharedMemory::createHandle(Handle& handle, Protection protection)
{
    ASSERT_ARG(handle, !handle.m_handle);
    ASSERT_ARG(handle, !handle.m_size);

    HANDLE processHandle = ::GetCurrentProcess();

    HANDLE duplicatedHandle;
    if (!::DuplicateHandle(processHandle, m_handle, processHandle, &duplicatedHandle, accessRights(protection), FALSE, 0))
        return false;

    handle.m_handle = duplicatedHandle;
    handle.m_size = m_size;
    return true;
}