Exemple #1
0
static void dma_dump_state(struct NCR_ESP *esp)
{
	ESPLOG(("esp%d: dma -- cond_reg<%02x>\n",
		esp->esp_id, ((struct fastlane_dma_registers *)
			      (esp->dregs))->cond_reg));
	ESPLOG(("intreq:<%04x>, intena:<%04x>\n",
		custom.intreqr, custom.intenar));
}
void CEsdlSvcEngineSoapBindingEx::handleSoapRequestException(IException *e, const char *source)
{
    WsErrorType  errorType = WSERR_NOERR;

    const int    errorcode = e->errorCode();
    StringBuffer errorMessage;
    e->errorMessage(errorMessage);

    ESPLOG(LogMax,"EsdlBindingImpl:HandleSoapRequest response error code: %d /nmerror message: %s",  errorcode, errorMessage.str());

    IWsException *wsex = dynamic_cast<IWsException *> (e);

    switch (errorcode){
    case ERR_ESDL_BINDING_AUTHERROR: case ERR_ESDL_BINDING_BADACCOUNT: case ERR_ESDL_BINDING_BADABI:
    case ERR_ESDL_BINDING_BADBRAND:  case ERR_ESDL_BINDING_BADBROKER:  case ERR_ESDL_BINDING_TESTCASE:
        errorType = WSERR_CLIENT ;
        break;
    case 2:
        e->Release();
        wsex = makeWsException(ERR_ESDL_BINDING_BADREQUEST, WSERR_CLIENT, source, errorMessage.str());
        break;
    default:
        errorType = WSERR_SERVER;
        break;
    }

    if ( wsex )
        throw wsex;
    else
        throw makeWsException( *e, errorType, source );
}
ESPMemCached::ESPMemCached()
{
#if (LIBMEMCACHED_VERSION_HEX < 0x01000010)
    VStringBuffer msg("ESPMemCached: libmemcached version '%s' incompatible with min version>=1.0.10", LIBMEMCACHED_VERSION_STRING);
    ESPLOG(LogNormal, "%s", msg.str());
#endif
}
bool CLoggingManager::getTransactionID(StringAttrMapping* transFields, StringBuffer& transactionID, StringBuffer& status)
{
    if (!initialized)
        throw MakeStringException(-1,"LoggingManager not initialized");

    try
    {
        for (unsigned int x = 0; x < loggingAgentThreads.size(); x++)
        {
            IUpdateLogThread* loggingThread = loggingAgentThreads[x];
            if (!loggingThread->hasService(LGSTGetTransactionID))
                continue;

            IEspLogAgent* loggingAgent = loggingThread->getLogAgent();
            loggingAgent->getTransactionID(transFields, transactionID);
            if (!transactionID.isEmpty())
                ESPLOG(LogMax, "Got TransactionID '%s'", transactionID.str());
            return true;
        }
    }
    catch (IException* e)
    {
        e->errorMessage(status);
        e->Release();
    }

    return false;
}
bool CLoggingManager::saveToTankFile(IEspUpdateLogRequestWrap& logRequest, CLogRequestInFile* reqInFile)
{
    if (!logFailSafe.get())
    {
        ERRLOG("CLoggingManager::saveToTankFile: logFailSafe not configured.");
        return false;
    }

    unsigned startTime = (getEspLogLevel()>=LogNormal) ? msTick() : 0;

    StringBuffer GUID;
    logFailSafe->GenerateGUID(GUID, NULL);
    reqInFile->setGUID(GUID);
    reqInFile->setOption(logRequest.getOption());

    StringBuffer reqBuf;
    Owned<IEspUpdateLogRequestWrap> logRequestFiltered = logContentFilter.filterLogContent(&logRequest);
    if (!serializeLogRequestContent(logRequestFiltered, GUID, reqBuf))
    {
        ERRLOG("CLoggingManager::saveToTankFile: failed in serializeLogRequestContent().");
        return false;
    }

    logFailSafe->AddACK(GUID);//Ack this logging request since the task will be done as soon as the next line is called.
    logFailSafe->Add(GUID, reqBuf, reqInFile);

    ESPLOG(LogNormal, "LThread:saveToTankFile: %dms\n", msTick() - startTime);
    return true;
}
Exemple #6
0
static void dma_dump_state(struct NCR_ESP *esp)
{
	struct sparc_dma_registers *dregs =
		(struct sparc_dma_registers *) esp->dregs;

	ESPLOG(("esp%d: dma -- cond_reg<%08lx> addr<%p>\n",
		esp->esp_id, dregs->cond_reg, dregs->st_addr));
}
void ESPMemCached::assertOnError(memcached_return_t rc, const char * _msg)
{
    if (rc != MEMCACHED_SUCCESS)
    {
        VStringBuffer msg("ESPMemCached: %s%s", _msg, memcached_strerror(connection, rc));
        ESPLOG(LogNormal, "%s", msg.str());
    }
}
void ESPMemCached::assertPool()
{
    if (!pool)
    {
        StringBuffer msg = "ESPMemCached: Failed to instantiate server pool with:";
        msg.newline().append(options);
        ESPLOG(LogNormal, "%s", msg.str());
    }
}
static void dma_dump_state(struct NCR_ESP * esp)
{
#ifdef DEBUG_MAC_ESP
	printk("mac_esp: dma_dump_state: called\n");
#endif
#if 0
	ESPLOG(("esp%d: dma -- cond_reg<%02x>\n",
		esp->esp_id, ((struct mac_dma_registers *)
		(esp->dregs))->cond_reg));
#endif
}
bool ESPMemCached::checkServersUp()
{
    memcached_return_t rc;
    char* args = nullptr;
    OwnedMalloc<memcached_stat_st> stats;
    stats.setown(memcached_stat(connection, args, &rc));

    unsigned int numberOfServers = memcached_server_count(connection);
    if (numberOfServers < 1)
    {
        ESPLOG(LogMin,"ESPMemCached: no server connected.");
        return false;
    }

    unsigned int numberOfServersDown = 0;
    for (unsigned i = 0; i < numberOfServers; ++i)
    {
        if (stats[i].pid == -1)//perhaps not the best test?
        {
            numberOfServersDown++;
            VStringBuffer msg("ESPMemCached: Failed connecting to entry %u\nwithin the server list: %s", i+1, options.str());
            ESPLOG(LogMin, "%s", msg.str());
        }
    }
    if (numberOfServersDown == numberOfServers)
    {
        ESPLOG(LogMin,"ESPMemCached: Failed connecting to ALL servers. Check memcached on all servers and \"memcached -B ascii\" not used.");
        return false;
    }

    //check memcached version homogeneity
    for (unsigned i = 0; i < numberOfServers-1; ++i)
    {
        if (!streq(stats[i].version, stats[i+1].version))
            DBGLOG("ESPMemCached: Inhomogeneous versions of memcached across servers.");
    }
    return true;
}
Exemple #11
0
static void dma_dump_state(struct NCR_ESP *esp)
{
	ESPLOG(("intreq:<%04x>, intena:<%04x>\n",
		custom.intreqr, custom.intenar));
}
void CwsstoreEx::init(IPropertyTree *_cfg, const char *_process, const char *_service)
{
   if(_cfg == nullptr)
        throw MakeStringException(-1, "CwsstoreEx::init: Empty configuration provided.");

#ifdef _DEBUG
    StringBuffer thexml;
    toXML(_cfg, thexml,0,0);
    fprintf(stderr, "%s", thexml.str());
#endif

    StringBuffer xpath;
    xpath.appendf("Software/EspProcess[@name=\"%s\"]/EspService[@name=\"%s\"]", _process, _service);
    m_serviceConfig.setown(_cfg->getPropTree(xpath.str()));

    if(!m_serviceConfig)
        throw MakeStringException(-1, "CwsstoreEx::init: Config not found for service %s/%s",_process, _service);

    IPropertyTree * storeProviderTree = m_serviceConfig->queryPropTree("StoreProvider[1]");

    if (storeProviderTree == nullptr)
         throw MakeStringException(-1, "CwsstoreEx::init: Store provider configuration not found for service %s/%s",_process, _service);

    const char * providerLibraryName = storeProviderTree->queryProp("@lib");
    if (!providerLibraryName || !*providerLibraryName)
        throw MakeStringException(-1, "CwsstoreEx::init: Must provide store provider library name for service %s/%s",_process, _service);

    const char * providerInstanceName = storeProviderTree->queryProp("@name");
    const char * providerFactoryMethod = storeProviderTree->queryProp("@factoryMethod");

    m_storeProvider.setown(loadStoreProvider(providerInstanceName, providerLibraryName, (providerFactoryMethod && *providerFactoryMethod) ? providerFactoryMethod : DEFAULT_ESP_STORE_FACTORY_METHOD));
    if (!m_storeProvider)
        throw MakeStringException(-1, "CwsstoreEx::init: Couldn't instantiate storeprovider lib: '%s' method: '%s'",providerLibraryName, (providerFactoryMethod && *providerFactoryMethod) ? providerFactoryMethod : DEFAULT_ESP_STORE_FACTORY_METHOD);

    m_storeProvider->init(providerInstanceName, "type", storeProviderTree);

    if (!m_isDetachedFromDali)
    {
        ESPLOG(LogMin, "CwsstoreEx: Ensuring configured stores are created:");
        Owned<IPropertyTreeIterator> iter = m_serviceConfig->getElements("Stores/Store");

        StringBuffer owner;
        owner.setf("%s/%s", _process, _service);

        m_defaultStore.clear();

        ForEach(*iter)
        {
            StringBuffer id;
            StringBuffer type;
            StringBuffer description;
            bool isDefault = false;

            iter->query().getProp("@name", id);
            iter->query().getProp("@type", type);
            iter->query().getProp("@description", description);
            isDefault = iter->query().getPropBool("@default", false);

            ESPLOG(LogMin, "CwsstoreEx: Creating Store: '%s'%s", id.str(), isDefault ? " - as Default" : "");
            m_storeProvider->createStore(type.str(), id.str(), description.str(), new CSecureUser(owner.str(), nullptr));
            if (isDefault)
            {
                if (!m_defaultStore.isEmpty())
                   throw MakeStringException(-1, "ws_store init(): Multiple stores erroneously configured as default store!");

                m_defaultStore.set(id.str());
            }
        }
    }
bool CHttpThread::onRequest()
{
    keepAlive = false;
    ActiveRequests recording;

    Owned<CEspHttpServer> httpserver;
    
    Owned<ISecureSocket> secure_sock;
    if(m_is_ssl && m_ssctx && m_persistentHandler == nullptr)
    {
        ESPLOG(LogMax, "Creating secure socket");
        secure_sock.setown(m_ssctx->createSecureSocket(m_socket.getLink(), getEspLogLevel()));
        int res = 0;
        try
        {
            ESPLOG(LogMax, "Accepting from secure socket");
            res = secure_sock->secure_accept();
            if(res < 0)
            {
                ESPLOG(LogMin, "Error accepting from secure socket");
                return false;
            }
        }
        catch(IException* e)
        {
            StringBuffer emsg;
            e->errorMessage(emsg);
            IERRLOG("%s", emsg.str());
            return false;
        }
        catch(...)
        {
            IERRLOG("Unknown exception accepting from secure socket");
            return false;
        }
        ESPLOG(LogMax, "Request from secure socket");
        m_socket.set(secure_sock);
        httpserver.setown(new CEspHttpServer(*secure_sock.get(), m_apport, m_viewConfig, getMaxRequestEntityLength()));
    }
    else
    {
        httpserver.setown(new CEspHttpServer(*m_socket, m_apport, m_viewConfig, getMaxRequestEntityLength()));
    }

    time_t t = time(NULL);  
    initThreadLocal(sizeof(t), &t);

    httpserver->setIsSSL(m_is_ssl);
    httpserver->setShouldClose(m_shouldClose);
    httpserver->processRequest();

    if (m_persistentHandler == nullptr)
    {
        keepAlive = !m_shouldClose && m_apport->queryProtocol()->persistentEnabled() && httpserver->persistentEligible();
        if (keepAlive)
            m_apport->queryProtocol()->addPersistent(m_socket.get());
    }
    else
    {
        keepAlive = !m_shouldClose && httpserver->persistentEligible();
        m_persistentHandler->doneUsing(m_socket, keepAlive);
    }
    clearThreadLocal();

    return false;
}
bool CSecureHttpProtocol::notifySelected(ISocket *sock,unsigned selected, IPersistentHandler* persistentHandler, bool shouldClose)
{
    try
    {
        char name[256];
        int port = sock->name(name, 255);

        CEspApplicationPort *apport = queryApplicationPort(port);
        if(apport == NULL)
            throw MakeStringException(-1, "binding not found!");
        
        if(apport != NULL)
        {
            Owned<ISocket>accepted;
            if(persistentHandler == nullptr)
                accepted.setown(sock->accept());
            else
                accepted.set(sock);
            if (accepted.get() != NULL)
            {
                char peername[256];
                int port = accepted->peer_name(peername, 256);
                DBGLOG("HTTPS connection from %s:%d on %s socket", peername, port, persistentHandler?"persistent":"new");
                if(m_ssctx != NULL)
                {
                    if(m_maxConcurrentThreads > 0)
                    {
                        // Using Threading pool instead of generating one thread per request.
                        void ** holder = new void*[7];
                        holder[0] = (void*)accepted.getLink();
                        holder[1] = (void*)apport;
                        int maxEntityLength = getMaxRequestEntityLength();
                        holder[2] = (void*)&maxEntityLength;
                        bool useSSL = true;
                        holder[3] = (void*)&useSSL;
                        holder[4] = (void*)m_ssctx.get();
                        holder[5] = (void*)persistentHandler;
                        holder[6] = (void*)&shouldClose;
                        http_thread_pool->start((void*)holder);
                        delete [] holder;
                    }
                    else
                    {
                        /* create one thread per request */
                        CHttpThread *workthread = new CHttpThread(accepted.getLink(), apport, CEspProtocol::getViewConfig(), true, m_ssctx.get(), persistentHandler);
                        workthread->setMaxRequestEntityLength(getMaxRequestEntityLength());
                        workthread->setShouldClose(shouldClose);
                        workthread->start();
                        ESPLOG(LogMax, "Request processing thread started.");
                        workthread->Release();
                    }
                }
                else
                {
                    return false;
                }
            }
        }
        else
        {
            throw MakeStringException(-1, "can't acquire bindings IEspHttpBinding interface (via dynamic_cast)!");
        }
    }
    catch (IException *e) 
    {
        StringBuffer estr;
        IERRLOG("Exception(%d, %s) in CSecureHttpProtocol::notifySelected()", e->errorCode(), e->errorMessage(estr).str());
        e->Release();
    }
    catch(...)
    {
        IERRLOG("Unknown Exception in CSecureHttpProtocol::notifySelected()");
    }

    return false;
}
Exemple #15
0
static void dma_dump_state(struct NCR_ESP *esp)
{
    
    ESPLOG(("esp%d: dma -- enable <%08x> residue <%08x\n",
	    esp->esp_id, vdma_get_enable((int)esp->dregs), vdma_get_residue((int)esp->dregs)));
}