コード例 #1
0
int LsapiConn::doWrite()
{
    if ( getConnector() )
    {
        int state = getConnector()->getState();
        if ((!state)||( state & (HEC_FWD_REQ_HEADER | HEC_FWD_REQ_BODY) ))
        {
            int ret = getConnector()->extOutputReady();
            if ( getState() == ABORT )
            {
                if ( getConnector() )
                {
                    incReqProcessed();
                    getConnector()->endResponse( 0, 0 );
                }
            }
            return ret;
        }
    }
    if ( m_iTotalPending > 0 )
        return flush();
    else
        suspendWrite();
    return 0;
}
コード例 #2
0
ファイル: proxyconn.cpp プロジェクト: 52M/openlitespeed
int ProxyConn::doWrite()
{
    int ret;
    if ((m_iSsl) && (!m_ssl.isConnected()))
    {
        ret = connectSSL();
        if (ret != 1)
            return ret;
    }
    if (getConnector())
    {
        int state = getConnector()->getState();
        if ((!state) || (state & (HEC_FWD_REQ_HEADER | HEC_FWD_REQ_BODY)))
        {
            int ret = getConnector()->extOutputReady();
            if (getState() == ABORT)
            {
                if (getConnector())
                {
                    incReqProcessed();
                    getConnector()->endResponse(0, 0);
                }
            }
            return ret;
        }
    }
    if (m_iTotalPending > 0)
        return flush();
    else
        suspendWrite();
    return 0;
}
コード例 #3
0
//interface defined by EdStream
int CgiConnection::onRead()
{
    if ( !getConnector() )
        return -1;
    if ( D_ENABLED( DL_MEDIUM ) )
        LOG_D(( getLogger(), "[%s] CgiConnection::onRead()\n", getLogId() ));
    int len = 0;
    int ret = 0;
    do
    {
        len = ret = read( HttpGlobals::g_achBuf, G_BUF_SIZE );
        if ( ret > 0 )
        {
            if ( D_ENABLED( DL_MEDIUM ) )
                LOG_D(( getLogger(), "[%s] process STDOUT %d bytes",
                    getLogId(), len ));
            //printf( ">>read %d bytes from CGI\n", len );
            //achBuf[ ret ] = 0;
            //printf( "%s", achBuf );
            ret = getConnector()->processRespData( HttpGlobals::g_achBuf, len );
            if ( ret == -1 )
                break;
        }
        else
        {
            if ( ret )
                getConnector()->endResponse( 0, 0 );
            break;
        }    
    }while( len == G_BUF_SIZE );
    if (( ret != -1 )&&( getConnector() ))
        getConnector()->flushResp();
    return ret;
}
コード例 #4
0
int LsapiConn::processPacketHeader( char * pBuf, int len )
{
    if ( m_iPacketHeaderLeft < len )
    {
        len = m_iPacketHeaderLeft;
    }
    memmove( ((char *)&m_respHeader) + sizeof( m_respHeader ) - m_iPacketHeaderLeft,
            pBuf, len );

    m_iPacketHeaderLeft -= len;

    if ( m_iPacketHeaderLeft == 0 )
    {
        m_iPacketLeft = verifyPacketHeader( &m_respHeader ) -
                LSAPI_PACKET_HEADER_LEN;
        if ( m_iPacketLeft < 0 )
        {
            LOG_WARN(( "[%s] LSAPI Packet header is invalid!",
                    getLogId() ));
			errno = EIO;
            return -1;
        }
//         if ( m_iPacketLeft > LSAPI_MAX_HEADER_LEN )
//         {
//             LOG_WARN(( "[%s] LSAPI Packet is too large: %d",
//                     getLogId(), m_iPacketLeft ));
// 			errno = EIO;
//             return -1;
//         }
        switch( m_respHeader.m_type )
        {
        case LSAPI_RESP_END:
			incReqProcessed();
            setInProcess( 0 );
            if ( getConnector() )
                getConnector()->endResponse( 0, 0 );
            return 0;
        case LSAPI_RESP_HEADER:
            if ( m_respState == LSAPI_CONN_READ_RESP_BODY )
            {
                LOG_WARN(( "[%s] Invalid LSAPI Response Header Packet following STREAM packet",
                    getLogId() ));
			    errno = EIO;
                return -1;
            }
            else
            {
                m_iCurRespHeader = 0;
                m_respState = LSAPI_CONN_READ_RESP_INFO;
                m_pRespHeaderProcess = (char *)&m_respInfo;
                setRespBuf( m_pRespHeaderProcess );
            }
            break;
        case LSAPI_REQ_RECEIVED:
            m_reqReceived       = 1;
            break;
        }
    }
    return len;
}
コード例 #5
0
void KSimIoJoin::updateConnName()
{
	if (getConnector() && (getConnector()->getInitName() == getConnector()->getName()))
	{
		// No user defined name -> set new default name
		getConnector()->setName(m_p->defaultConnectorName, true);
	}
}
コード例 #6
0
ファイル: jconn.cpp プロジェクト: ewwink/openlitespeed
int JConn::removeRequest( ExtRequest * pReq )
{
    if ( getConnector() )
    {
        getConnector()->setProcessor( NULL );
        setConnector( NULL );
    }
    return 0;
}
コード例 #7
0
ファイル: proxyconn.cpp プロジェクト: 52M/openlitespeed
void ProxyConn::onTimer()
{
//    if (!( getEvents() & POLLIN ))
//    {
//        LS_WARN( this, "Oops! POLLIN is turned off for this proxy connection,"
//                 " turn it on, this should never happen!!!!");
//        continueRead();
//    }
//    if (( m_iTotalPending > 0 )&& !( getEvents() & POLLOUT ))
//    {
//        LS_WARN( this, "Oops! POLLOUT is turned off while there is pending data,"
//                    " turn it on, this should never happen!!!!");
//        continueWrite();
//    }
    if (m_lLastRespRecvTime)
    {
        long tm = time(NULL);
        long delta = tm - m_lLastRespRecvTime;
        if ((delta > getWorker()->getTimeout()) && (m_iRespBodyRecv))
        {
            if (m_pChunkIS)
            {
                LS_INFO(this, "Timeout, partial chunk encoded body received,"
                        " received: %d, chunk len: %d, remain: %d!",
                        m_iRespBodyRecv, m_pChunkIS->getChunkLen(),
                        m_pChunkIS->getChunkRemain());
            }
            else
                LS_INFO(this, "Timeout, partial response body received,"
                        " body len: %d, received: %d!",
                        m_iRespBodySize, m_iRespBodyRecv);
            setState(ABORT);
            getConnector()->endResponse(0, 0);;
            return;
        }
        else if ((m_pChunkIS) && (!m_pChunkIS->getChunkLen()) && (delta > 1))
        {
            if ((getConnector()))
            {
                LS_DBG_L(this, "Missing trailing CRLF in Chunked Encoding,"
                         " remain: %d!", m_pChunkIS->getChunkRemain());
//                const char * p = m_pChunkIS->getLastBytes();
//                LS_INFO(this,
//                        "Last 8 bytes are: %#x %#x %#x %#x %#x %#x %#x %#x",
//                        p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
//                HttpReq * pReq = getConnector()->getHttpSession()->getReq();
//                pReq->dumpHeader();

                setState(CLOSING);
                getConnector()->endResponse(0, 0);
                return;
            }
        }
    }

    ExtConn::onTimer();
}
コード例 #8
0
int CgiConnection::onError()
{
    if ( !getConnector() )
        return -1;
    if ( D_ENABLED( DL_MEDIUM ) )
        LOG_D(( getLogger(), "[%s] CgiConnection::onError()\n", getLogId() ));
    //getState() = HEC_COMPLETE;
    getConnector()->endResponse( SC_500, 0 );
    return -1;
}
コード例 #9
0
ファイル: jconn.cpp プロジェクト: ewwink/openlitespeed
int JConn::processPacketHeader( unsigned char * &p )
{
    if (( *p != AJP_RESP_PREFIX_B1)||
        ( *(p+1) != AJP_RESP_PREFIX_B2 ))
    {
        LOG_ERR(( getLogger(), "[%s] Invalid AJP response signature %x%x",
                    getLogId(), (int) *p,
                    (int) *(p+1) ));
        return -1;
    }
    p+= 2;
    m_curPacketSize = getInt( p );
    if ( m_curPacketSize > AJP_MAX_PKT_BODY_SIZE )
    {
        LOG_ERR(( getLogger(), "[%s] packet size is too large - %d",
                getLogId(), m_curPacketSize ));
        return -1;
    }
    m_packetType = *p++;
    m_packetLeft = m_curPacketSize - 1;
    switch(m_packetType)
    {
    case AJP13_RESP_BODY_CHUNK:
        m_iPacketState = CHUNK_LEN;
        break;
    case AJP13_RESP_HEADERS:
        m_iPacketState = STATUS_CODE;
        break;
    case AJP13_END_RESP:
        if ( *p != 1)
        {
            if ( D_ENABLED( DL_LESS ) )
                LOG_D(( getLogger(),
                    "[%s] close connection required by servlet engine %s ",
                    getLogId(), getWorker()->getURL() ));
            
            setState( CLOSING );
        }
        p++;
        if ( getConnector() )
        {
            incReqProcessed();
            if ( getState() == ABORT )
                setState( PROCESSING );
            setInProcess( 0 );            
            getConnector()->endResponse( 0, 0 );
        }
        break;
    case AJP13_MORE_REQ_BODY:
    default:
        break;
    }
    return 0;    
}
コード例 #10
0
int CgiConnection::onWrite()
{
    if ( !getConnector() )
        return -1;
    if ( D_ENABLED( DL_MEDIUM ) )
        LOG_D(( getLogger(), "[%s] CgiConnection::onWrite()\n", getLogId() ));
    int ret = extOutputReady();
    if (!( getConnector()->getState() & HEC_FWD_REQ_BODY ))
    {
        suspendWrite();
    }
    return ret;
}
コード例 #11
0
void KSimIoJoin::setConnector(ConnectorBase * connector)
{
	Q_ASSERT(connector != (ConnectorBase *)0);
	
	m_connectorBase = connector;
	getConnector()->setName(m_p->defaultConnectorName, true);
	getConnector()->setWireName(QString::fromLatin1("Conn %1").arg(getSerialID()));

	// The join saves the connector!
	getConnector()->getAction().disable(KSimAction::STORAGE);
	
	connect(getConnector(), SIGNAL(signalDeleteRequest(ConnectorBase *)),
	        this, SLOT(slotConnDeleteRequest(ConnectorBase *)));
}
コード例 #12
0
ファイル: jconn.cpp プロジェクト: ewwink/openlitespeed
int JConn::processPacketData( unsigned char * &p )
{
    if ( m_iPacketState == PACKET_HEADER )
    {
        //m_respHeader + m_packetLeft
        if ( m_pCurPos - p >= AJP_MIN_PACKET_SIZE )
        {
            int ret = processPacketHeader( p );
            if ( ret )
                return -1;
        }
        else
            return 1;
    }
    if ( p == m_pCurPos )
        return 1;
    int ret = 0;
    unsigned char * pCur = p;
    unsigned char * pEnd = p + m_packetLeft;
    if ( pEnd > m_pCurPos )
        pEnd = m_pCurPos;
    if ( getConnector() )
        ret = processPacketContent( p, pEnd );
    else
        p = pEnd;
    if ( ret == -1 )
        return ret;
    m_packetLeft -= p - pCur;
    if ( m_packetLeft == 0 )
        m_iPacketState = PACKET_HEADER;
    return 0;
}
コード例 #13
0
// Connection and Mode setting
bool IntelHWComposerDrm::detectDisplayConnection(int disp)
{
    ALOGD_IF(ALLOW_MONITOR_PRINT,
              "%s: detecting display %d drm mode info...\n", __func__, disp);

    //get mipi0 info
    drmModeConnectorPtr connector = NULL;
    drmModeModeInfoPtr mode = NULL;
    uint32_t connector_type;

    connector = getConnector(disp);
    if (!connector) {
        ALOGW("%s: fail to get drm connector\n", __func__);
        return false;
    }

    //update connection status
    setOutputConnection(disp, connector->connection);

    if (connector->connection != DRM_MODE_CONNECTED) {
        freeConnector(connector);
        return false;
    }

    //update mode info
    mode = getSelectMode(NULL, connector);
    if (mode)
        setOutputMode(disp, mode, 1);

    freeConnector(connector);

    return true;
}
コード例 #14
0
ファイル: HierarchySubReferer.cpp プロジェクト: kniz/World
	type_result HierarchySubReferer::_render( D3DMATERIAL9& material )
	{
		_initializeMesh();
		//	main:
		//		DX9 바인딩:
		DX9& dx9 = getDependent();
		if( ! &dx9)
		{
			ALERT_ERROR(" : 디바이스 바인딩 실패로 중지");
			return RESULT_TYPE_ERROR;
		}
		LPDIRECT3DDEVICE9 device = dx9.getDevice();		
		//		월드좌표 갱신:
		D3DXMATRIX& world = getWorldMatrix();
		D3DXMATRIX origin;
		device->GetTransform(D3DTS_WORLD, &origin);
		device->SetTransform(D3DTS_WORLD, &world);

		device->SetRenderState(D3DRS_AMBIENT, 0xffffffff);

		//device->SetTexture(0, NULL);
		device->SetMaterial(&material);
		device->SetTexture(0, 0);
		if(_ball)
		{			
			_ball->DrawSubset(0);
		}

		//		자식과 선을 잇기:
		device->SetTransform(D3DTS_WORLD, &origin);

		_searchModuleSet(getConnector().getModuleCodeSetKey().getValue(), &ThisClass::_renderLineBetweenChild);			//		월드 좌표 복귀:
		return RESULT_SUCCESS;
	}
コード例 #15
0
bool drm_init()
{
    union drm_psb_extension_arg video_getparam_arg;
    const char video_getparam_ext[] = "lnc_video_getparam";

    memset(&gDrmCxt,0,sizeof(drmContext));
    gDrmCxt.hdmiConnector = NULL;
    gDrmCxt.drmFD = open(DRM_DEVICE_NAME, O_RDWR, 0);
    if (gDrmCxt.drmFD <= 0) {
        LOGE("%s: Failed to open %s", __func__, DRM_DEVICE_NAME);
        return false;
    }

    strncpy(video_getparam_arg.extension,
            video_getparam_ext, sizeof(video_getparam_arg.extension));
    int ret = drmCommandWriteRead(gDrmCxt.drmFD, DRM_PSB_EXTENSION,
            &video_getparam_arg, sizeof(video_getparam_arg));
    if (ret != 0) {
        LOGE("Failed to get ioctl offset.");
        drm_cleanup();
        return false;
    }

    gDrmCxt.ioctlOffset = video_getparam_arg.rep.driver_ioctl_offset;
    drmModeConnectorPtr connector = getConnector(gDrmCxt.drmFD, DRM_MODE_CONNECTOR_DVID);
    gDrmCxt.hdmiSupported = (connector != NULL);
    if (connector) {
        drmModeFreeConnector(connector);
        connector = NULL;
    }
    return true;
}
コード例 #16
0
bool drm_mipi_setMode(int mode)
{
    drmModeConnector *connector = getConnector(gDrmCxt.drmFD, DRM_MODE_CONNECTOR_MIPI);
    if (connector == NULL)
        return false;

    int i = 0;
    drmModePropertyPtr props = NULL;

    // Set MIPI On/Off
    for (i = 0; i < connector->count_props; i++) {
        props = drmModeGetProperty(gDrmCxt.drmFD, connector->props[i]);
        if (!props) continue;

        if (props->name != NULL &&
                !strncmp(props->name, "DPMS", sizeof("DPMS"))) {
            LOGV("%s: %s %u", __func__,
                  (mode == DRM_MIPI_ON) ? "On" : "Off",
                  connector->connector_id);
            drmModeConnectorSetProperty(gDrmCxt.drmFD,
                                        connector->connector_id,
                                        props->prop_id,
                                        (mode == DRM_MIPI_ON)
                                        ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF);
            drmModeFreeProperty(props);
            break;
        }
        drmModeFreeProperty(props);
    }

    drmModeFreeConnector(connector);
    return true;
}
コード例 #17
0
ファイル: jconn.cpp プロジェクト: ewwink/openlitespeed
int JConn::doWrite()
{
    if ( getConnector() )
    {
        int state = getConnector()->getState();
        if ((!state)||( state & (HEC_FWD_REQ_HEADER | HEC_FWD_REQ_BODY) ))
        {
            return getConnector()->extOutputReady();
        }
    }
    if ( m_iTotalPending > 0 )
        return flush();
    else
        suspendWrite();
    return 0;
}
コード例 #18
0
int CgiConnection::readResp( char * pBuf, int size )
{
    int len = read( pBuf, size );
    if ( len == -1 )
        getConnector()->endResponse( 0, 0 );
    return len;
    
}
コード例 #19
0
void KSimIoJoin::slotConnDeleteRequest(ConnectorBase * conn)
{
	if (conn == getConnector())
	{
		getIoComponent()->undoChangeProperty(i18n("Delete IO"));
		getIoComponent()->setModified();
		getIoComponent()->getConnList()->removeRef(getConnector());
		getIoComponent()->updateLayout();
		getIoComponent()->refresh();
		delete this;
	}
	else
	{
		KSIMDEBUG(QString::fromLatin1("Connector %1 is not from KSimIoJoin %2")
		          .arg(conn->getName()).arg(getDefaultPinName()));
	}
}
コード例 #20
0
ファイル: fcgirequest.cpp プロジェクト: bizonix/openlitespeed
int  FcgiRequest::processStdErr( char * pBuf, int size )
{
    HttpExtConnector * pConnector = getConnector();
    assert( pConnector );
    if ( D_ENABLED( DL_MEDIUM ) )
        LOG_D(( pConnector->getLogger(), "[%s] process STDERR %d bytes",
            pConnector->getLogId(), size ));
    return pConnector->processErrData( pBuf, size );
}
コード例 #21
0
ファイル: fcgirequest.cpp プロジェクト: bizonix/openlitespeed
int FcgiRequest::sendAbortRec( )
{
    if ( D_ENABLED( DL_LESS ) )
        LOG_D(( getLogger(), "[%s] [FCGI] send abort packet!",
            getConnector()->getLogId() ));
    FCGI_Header rec;
    FcgiRecord::setRecordHeader( rec, FCGI_ABORT_REQUEST, m_iId, 0 );
    return m_pFcgiConn->sendRecord( (const char *)&rec, sizeof( rec ) );
}
コード例 #22
0
ファイル: jconn.cpp プロジェクト: ewwink/openlitespeed
int JConn::doRead()
{
    int len = 0;
    int ret = 0;
    while( true )
    {
        int toRead = m_pRespBufEnd - m_pCurPos;
        len = read( (char *)m_pCurPos, toRead);
        if ( len > 0 )
        {
            if ( D_ENABLED( DL_MEDIUM ) )
                LOG_D(( getLogger(), "[%s] process STDOUT %d bytes",
                    getLogId(), len ));
            //printf( ">>read %d bytes from CGI\n", len );
            //::write( 1, m_pCurPos, len );
            m_pCurPos += len;
            ret = processRespData();
            if ( ret == -1 )
            {
                errno = EIO;
                len = -1;
                break;
            }
            if ( len < toRead )
            {
                if (( m_packetType != AJP13_END_RESP )&&
                    ( getConnector() ))
                    getConnector()->flushResp();
                break;
            }
        }
        else 
            break;
    }
    if ( getState() == ABORT )
    {
        if ( getConnector() )
        {
            incReqProcessed();
            getConnector()->endResponse( 0, 0 );
        }
    }    
    return len;
}
コード例 #23
0
static drmModeConnectorPtr getHdmiConnector()
{
    if (gDrmCxt.hdmiConnector == NULL)
        gDrmCxt.hdmiConnector = getConnector(gDrmCxt.drmFD, DRM_MODE_CONNECTOR_DVID);
    if (gDrmCxt.hdmiConnector == NULL || gDrmCxt.hdmiConnector->modes == NULL) {
        ALOGI("Failed to get HDMI state, please check HDMI cable is connected or not");
        return NULL;
    }
    return gDrmCxt.hdmiConnector;
}
コード例 #24
0
ファイル: proxyconn.cpp プロジェクト: 52M/openlitespeed
int ProxyConn::doError(int err)
{
    LS_DBG_L(this, "ProxyConn::doError()");
    if (getConnector())
    {
        int state = getConnector()->getState();
        if (!(state & (HEC_FWD_RESP_BODY | HEC_ABORT_REQUEST
                       | HEC_ERROR | HEC_COMPLETE)))
        {
            LS_DBG_L(this, "Proxy Peer closed connection, "
                     "try another connection!");
            connError(err);
            return 0;
        }
        if (!(state & HEC_COMPLETE))
            getConnector()->endResponse(SC_500, -1);
    }
    return 0;
}
コード例 #25
0
drmModeConnectorPtr
IntelHWComposerDrm::getHdmiConnector() {
    if (mHdmiConnector == NULL)
        mHdmiConnector = getConnector(OUTPUT_HDMI);
    if (mHdmiConnector == NULL || mHdmiConnector->modes == NULL) {
        ALOGE("%s: Failed to get HDMI connector", __func__);
        return NULL;
    }
    return mHdmiConnector;
}
コード例 #26
0
void KSimIoJoinBoolIn::calculate() const
{
	KSimIoJoin::calculate();
	
	bool value;

	getDevice()->getIO(getPin()->getPinID(), &value);

	((ConnectorBoolOut *)getConnector())->setOutput(value);
}
コード例 #27
0
int CgidConn::doWrite()
{
    if ( !getConnector() )
        return -1;
    if ( D_ENABLED( DL_MEDIUM ) )
        LOG_D(( getLogger(), "[%s] CgidConn::onWrite()\n", getLogId() ));
    int ret = getConnector()->extOutputReady();
    if (!( getConnector()->getState() & HEC_FWD_REQ_BODY ))
    {
        if ( m_iTotalPending > 0 )
            return flush();
        else
        {
            suspendWrite();
            ::shutdown( getfd(), SHUT_WR );
        }
    }
    return ret;
}
コード例 #28
0
ファイル: fcgirequest.cpp プロジェクト: bizonix/openlitespeed
int FcgiRequest::onStdOut()
{
    HttpExtConnector * pConnector = getConnector();
    assert( pConnector );
    if ( D_ENABLED( DL_MEDIUM ) )
        LOG_D(( pConnector->getLogger(), "[%s] onStdOut()",
            pConnector->getLogId() ));
    return pConnector->extInputReady();

}
コード例 #29
0
int LsapiConn::doRead()
{
    if ( D_ENABLED( DL_LESS ) )
        LOG_D(( getLogger(), "[%s] LsapiConn::doRead()\n", getLogId() ));
    int ret;
    ret = processResp();
//    if ( m_respState )
//        ret = processResp();
//    else
//        ret = processRespBuffed();
    if ( getState() == ABORT )
    {
        if ( getConnector() )
        {
            incReqProcessed();
            getConnector()->endResponse( 0, 0 );
        }
    }
    return ret;
}
コード例 #30
0
int LsapiConn::doError( int err)
{
    if ( D_ENABLED( DL_LESS ) )
        LOG_D(( getLogger(), "[%s] LsapiConn::doError()", getLogId() ));
    if ( getConnector())
    {
        int state = getConnector()->getState();
        if ( !(state & (HEC_FWD_RESP_BODY | HEC_ABORT_REQUEST
                        | HEC_ERROR|HEC_COMPLETE) ))
        {
            if ( D_ENABLED( DL_LESS ) )
                LOG_D(( getLogger(), "[%s] Lsapi Peer closed connection, "
                            "try another connection!", getLogId() ));
            connError( err );
            return 0;
        }
        if ( !(state & HEC_COMPLETE) )
            getConnector()->endResponse( SC_500, -1 );
    }
    return 0;
}