// remotely accessible
    boost::int32_t ObjectFactoryService::CreateObject(
        const std::string &objectName,
        Token &token)
    {
        RCF_LOG_3()(objectName);

        {
            Lock lock(mCleanupThresholdMutex);
            if (!mLazyStarted)
            {
                mTaskEntries[0].start();
                mLazyStarted = true;
            }
        }

        // TODO: seems unnecessary to be triggering a sweep here
        std::size_t nAvail = mTokenFactory->getAvailableTokenCount();
        std::size_t nTotal = mTokenFactory->getTokenSpace().size();
        float used = float(nTotal - nAvail) / float(nTotal);
        if (used > mCleanupThreshold)
        {
            Lock lock(mCleanupThresholdMutex);
            mCleanupThresholdCondition.notify_all(lock);
        }

        boost::int32_t ret = RcfError_Ok;

        StubFactoryPtr stubFactoryPtr( getStubFactory( objectName));
        if (stubFactoryPtr.get())
        {
            RcfClientPtr rcfClientPtr( stubFactoryPtr->makeServerStub());
            StubEntryPtr stubEntryPtr( new StubEntry(rcfClientPtr));

            ret = addObject(TokenMappedPtr(stubEntryPtr), token);
            
            if (ret == RcfError_Ok)
            {
                getTlsRcfSession().setCachedStubEntryPtr(stubEntryPtr);

                RCF_LOG_3()(objectName)(token) << "Dynamically bound object created.";
            }
        }
        else
        {
            ret = RcfError_ObjectFactoryNotFound;
        }

        return ret;
    }
Exemple #2
0
 HttpSession::HttpSession(const std::string & httpSessionId) :
     mRequestInProgress(false),
     mLastTouchMs(0),
     mHttpSessionId(httpSessionId),
     mHttpSessionIndex(0),
     mCachedReadBytesRequested(0)
 {
     RCF_LOG_3()(mHttpSessionId) << "HttpSession::HttpSession()";
 }
Exemple #3
0
    // remotely accessible
    boost::int32_t FilterService::RequestTransportFilters(const std::vector<boost::int32_t> &filterIds)
    {
        RCF_LOG_3()(filterIds) << "FilterService::RequestTransportFilters() - entry";

        ReadLock readLock(mFilterFactoryMapMutex);
        for (unsigned int i=0; i<filterIds.size(); ++i)
        {
            int filterId = filterIds[i];
            if (mFilterFactoryMap.find(filterId) == mFilterFactoryMap.end())
            {
                RCF_LOG_3()(filterId) << "FilterService::RequestTransportFilters() - unknown filter.";
                return RcfError_UnknownFilter;
            }
        }
        boost::shared_ptr< std::vector<FilterPtr> > filters(
            new std::vector<FilterPtr>());

        for (unsigned int i=0; i<filterIds.size(); ++i)
        {
            int filterId = filterIds[i];
            FilterFactoryPtr filterFactoryPtr = mFilterFactoryMap[filterId];
            FilterPtr filterPtr( filterFactoryPtr->createFilter() );
            filters->push_back(filterPtr);
        }
        RcfSession & session = getCurrentRcfSession();
        if (session.transportFiltersLocked())
        {
            RCF_LOG_3() << "FilterService::RequestTransportFilters() - filter sequence already locked.";
            return RcfError_FiltersLocked;
        }
        else
        {
            session.addOnWriteCompletedCallback( boost::bind(
                &FilterService::setTransportFilters, 
                this, 
                _1, 
                filters) );
        }        

        RCF_LOG_3() << "FilterService::RequestTransportFilters() - exit";
        return RcfError_Ok;
    }
Exemple #4
0
    void Win32NamedPipeServerTransport::onServerStart(RcfServer & server)
    {
        IocpServerTransport::onServerStart(server);

        RCF_LOG_3() << "Win32NamedPipeServerTransport - listening on pipe " << mPipeName << ".";

        mQueuedAccepts = 0;

        if (!mPipeName.empty())
        {
            createSessionState()->accept();
        }        
    }
    // remotely accessible
    boost::int32_t ObjectFactoryService::DeleteObject(const Token &token)
    {
        WriteLock writeLock(mStubMapMutex);
        RCF_UNUSED_VARIABLE(writeLock);

        if (mStubMap.find(token) == mStubMap.end())
        {
            return RcfError_DynamicObjectNotFound;
        }
        else
        {
            mStubMap[token].second.reset();
            mTokenFactory->returnToken(token);
            RCF_LOG_3()(token) << "Dynamically bound object deleted.";
            return RcfError_Ok;
        }
    }
    void ObjectFactoryService::cleanupStubMap(unsigned int timeoutS)
    {
        // Clean up the stub map
        std::size_t nAvail = mTokenFactory->getAvailableTokenCount();
        std::size_t nTotal = mTokenFactory->getTokenSpace().size();
        float used = float(nTotal - nAvail) / float(nTotal);
        if (used > mCleanupThreshold)
        {
            RCF_LOG_3() << "ObjectFactoryService - cleaning up stub map.";
            typedef std::vector<Token>::const_iterator Iter;
            for (
                Iter iter = mTokenFactory->getTokenSpace().begin();
                iter != mTokenFactory->getTokenSpace().end();
                ++iter)
            {
                Token token = *iter;

                bool removeStub = false;
                {
                    ReadLock readLock(mStubMapMutex);
                    RCF_ASSERT(mStubMap.find(token) != mStubMap.end())(token);
                    Lock lock(*mStubMap[token].first);
                    TokenMappedPtr & tokenMappedPtr = mStubMap[token].second;
                    if (
                        tokenMappedPtr.get() &&
                        tokenMappedPtr.unique() &&
                        tokenMappedPtr->getElapsedTimeS() > timeoutS)
                    {
                        removeStub = true;
                        tokenMappedPtr.reset();
                    }
                }
                if (removeStub)
                {
                    mTokenFactory->returnToken(token);
                }
            }
        }
    }
Exemple #7
0
    // remotely accessible
    boost::int32_t FilterService::RequestTransportFilters(const std::vector<boost::int32_t> &filterIds)
    {
        RCF_LOG_3()(filterIds) << "FilterService::RequestTransportFilters() - entry";

        RcfSession & session = getCurrentRcfSession();
        RcfServer & server = session.getRcfServer();

        boost::shared_ptr< std::vector<FilterPtr> > filters(
            new std::vector<FilterPtr>());

        ReadLock readLock(mFilterFactoryMapMutex);
        for (unsigned int i=0; i<filterIds.size(); ++i)
        {
            int filterId = filterIds[i];

            if (filterId == RcfFilter_SspiSchannel || filterId == RcfFilter_OpenSsl)
            {               
                if (server.getSslImplementation() == RCF::Si_Schannel)
                {
                    filterId = RcfFilter_SspiSchannel;
                }
                else
                {
                    filterId = RcfFilter_OpenSsl;
                }
            }

            if (mFilterFactoryMap.find(filterId) == mFilterFactoryMap.end())
            {
                RCF_LOG_3()(filterId) << "FilterService::RequestTransportFilters() - filter not supported.";
                return RcfError_UnknownFilter;
            }

            FilterFactoryPtr filterFactoryPtr = mFilterFactoryMap[filterId];
            FilterPtr filterPtr( filterFactoryPtr->createFilter(server) );
            filters->push_back(filterPtr);
        }

        // Determine which protocol, if any, the filter sequence represents.
        
        session.mEnableCompression = false;

        FilterPtr filterPtr;
        if (filters->size() > 0)
        {
            if ( (*filters)[0]->getFilterId() == RcfFilter_ZlibCompressionStateful )
            {
                session.mEnableCompression = true;
                if (filters->size() > 1)
                {
                    filterPtr = (*filters)[1];
                }
            }
            else
            {
                if (filters->size() > 0)
                {
                    filterPtr = (*filters)[0];
                }
            }
        }

        TransportProtocol protocol = Tp_Unspecified;
        if (!filterPtr)
        {
            protocol = Tp_Clear;
        }
        else
        {
            int filterId = filterPtr->getFilterId();
            switch (filterId)
            {
            case RcfFilter_SspiNtlm:        protocol = Tp_Ntlm;         break;
            case RcfFilter_SspiKerberos:    protocol = Tp_Kerberos;     break;
            case RcfFilter_SspiNegotiate:   protocol = Tp_Negotiate;    break;
            case RcfFilter_SspiSchannel:    protocol = Tp_Ssl;          break;
            case RcfFilter_OpenSsl:         protocol = Tp_Ssl;          break;
            default:                        protocol = Tp_Unspecified;  break;
            }
        }

        // Check that the filter sequence is allowed.
        const std::vector<TransportProtocol> & protocols = server.getSupportedTransportProtocols();
        if (protocols.size() > 0)
        {
            if (std::find(protocols.begin(), protocols.end(), protocol) == protocols.end())
            {
                RCF_THROW( Exception(_RcfError_ProtocolNotSupported()) );
            }
        }

        if (protocol != Tp_Unspecified)
        {
            session.mTransportProtocol = protocol;
        }
        
        if (session.transportFiltersLocked())
        {
            RCF_LOG_3() << "FilterService::RequestTransportFilters() - filter sequence already locked.";
            return RcfError_FiltersLocked;
        }
        else
        {
            session.addOnWriteCompletedCallback( boost::bind(
                &FilterService::setTransportFilters, 
                this, 
                _1, 
                filters) );
        }        

        RCF_LOG_3() << "FilterService::RequestTransportFilters() - exit";
        return RcfError_Ok;
    }
Exemple #8
0
 HttpSession::~HttpSession()
 {
     RCF_LOG_3()(mHttpSessionId) << "HttpSession::~HttpSession()";
 }