当前位置: 代码迷 >> CGI >> 连接数据库的fcgi程序直接运行可以,用apache当fcgi调用却老报500异常
  详细解决方案

连接数据库的fcgi程序直接运行可以,用apache当fcgi调用却老报500异常

热度:588   发布时间:2012-02-11 09:51:35.0
连接数据库的fcgi程序直接运行可以,用apache当fcgi调用却老报500错误
apache 错误日志:
[Mon Apr 19 09:34:05 2010] [warn] [client 127.0.0.1] mod_fcgid: read timeout from pipe
[Mon Apr 19 09:34:05 2010] [error] [client 127.0.0.1] Premature end of script headers: dest.tfs
[Mon Apr 19 09:34:16 2010] [warn] mod_fcgid: process 4892 graceful kill fail, sending SIGKILL

错误语句:
if(FAILED(m_pConnection->Open( strConnect, "", "", adModeUnknown)))


连接字符串:
C/C++ code

bool ADOConn::OnInitADOConn()
{
#ifdef _LOG_DESTDOWNLOAD_
    vos_util_demo_print( "ADOConn::OnInitADOConn() IN \n" );
#endif

    // 初始化OLE/COM库环境 
    if(FAILED(::CoInitialize(NULL)))
        return false;

#ifdef _LOG_DESTDOWNLOAD_
    vos_util_demo_print( "ADOConn::CoInitialize() SUCCESS \n" );
#endif    
    try
    {
        if(FAILED(m_pConnection.CreateInstance( __uuidof( Connection ) )))
            return false;

#ifdef _LOG_DESTDOWNLOAD_
        vos_util_demo_print( "m_pConnection.CreateInstance SUCCESS \n" );
#endif    

        if(FAILED(m_pCommandPer.CreateInstance( __uuidof( Command ) )))
            return false;
        
#ifdef _LOG_DESTDOWNLOAD_
        vos_util_demo_print( "m_pCommandPer.CreateInstance SUCCESS \n" );
#endif    

        m_pRecordset = NULL;
        // 设置连接字符串,必须是BSTR型或者_bstr_t类型
        _bstr_t strConnect = "Provider=OraOLEDB.Oracle.1; Data Source=tspora1;User ID=tsp;Password=tsp;Persist Security Info=True;";
        if(FAILED(m_pConnection->Open( strConnect, "", "", adModeUnknown)))
            return false;

#ifdef _LOG_DESTDOWNLOAD_
        vos_util_demo_print( "m_pConnection->Open SUCCESS \n" );
#endif    
    }
    // 捕捉异常
    catch( _com_error e )
    {
        return false;
    }

    return true;
}


fcgi程序直接运行exe时可以连接数据库,访问读取都没有问题
当发布到apache时,再访问这个fcgi程序就出问题
另:apache的fcgi配置已经配好,只要不访问数据库,就能正常执行
求高手解!

------解决方案--------------------
还没碰到过这个问题?
  相关解决方案