找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 4118|回复: 0

suse到debian平台切换后出现的ace_reactor问题

[复制链接]
发表于 2009-8-4 13:41:13 | 显示全部楼层 |阅读模式
主函数
void t_c_fun(){
//
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
#if defined (USE_EPOLL)
  #if defined (ACE_HAS_EVENT_POLL)
   ACE_DEBUG((LM_INFO, "%T \t%s\n", "Use event poll instead of select"));
  #endif
  #if defined (ACE_HAS_DEV_POLL)
   ACE_DEBUG((LM_INFO, "%T \t%s\n", "Use dev poll instead of select"));
  #endif
  ACE_Dev_Poll_Reactor dev;
  ACE_Reactor new_reactor (&dev);
  ACE_Reactor::instance(&new_reactor);
#endif
#endif
  /************************************************************************/
  /* as TCP server */
  /************************************************************************/
  tcp_client_ins::instance()->run_tcp_client();
  /************************************************************************/
  /* as TCP client */
  /************************************************************************/
  ACE_DEBUG((LM_INFO, "%T \t100\n"));
  handler_begin_rtp();
  ACE_DEBUG((LM_INFO, "%T \t200\n"));
  handler_fpga_read();
  ACE_DEBUG((LM_INFO, "%T \t300\n"));
  handler_fpga_write();
  ACE_DEBUG((LM_INFO, "%T \tRunning Event Loop\n"));
  ACE_Reactor::instance ()->run_reactor_event_loop ();
}

辅助类与函数
/************************************************************************/
/* FPGA-write timer*/
/************************************************************************/
class timer_write: public ACE_Event_Handler
{
public:
int handle_timeout (const ACE_Time_Value &, const void *arg);
};
/************************************************************************/
/* FPGA-read timer*/
/************************************************************************/
class timer_read: public ACE_Event_Handler
{
public:
int handle_timeout (const ACE_Time_Value &, const void *arg);
};

int run_test (u_short localport,
    const ACE_TCHAR *remotehost,
    u_short remoteport,
    const ACE_TCHAR *peer)
{
ACE_INET_Addr remote_addr (remoteport, remotehost);
ACE_INET_Addr local_addr (localport);
ACE_DEBUG((LM_INFO, "%T \t1\n"));
auto_ptr<Dgram_Endpoint> endpoint(new Dgram_Endpoint (remote_addr, local_addr));
if(!endpoint.get()){
  ACE_ERROR_RETURN ((LM_ERROR, "%T \t%p with port(%d)\n", "new", localport), -1);
}
ACE_DEBUG((LM_INFO, "%T \t2\n"));
// Read data from other side.
if (ACE_Reactor::instance ()->register_handler(endpoint.get(), ACE_Event_Handler::READ_MASK) == -1)
  ACE_ERROR_RETURN ((LM_ERROR, "%T \t%p with port(%d)\n", "ACE_Reactor::register_handler", localport), -1);
ACE_DEBUG((LM_INFO, "%T \t3\n"));
Dgram_Endpoint::map_dgram.insert(Map_Dgram::value_type(localport, endpoint.release()));
return 0;
}

/************************************************************************/
/* Begin timer to read from memory then write FPGA*/
/************************************************************************/
inline void handler_fpga_write(){
  ACE_Time_Value initial (1), repeat (0, RTP_PACK_INTERVAL);
  long timerId = ACE_Reactor::instance ()->schedule_timer (timer_write_.get(), 0, initial, repeat);
}
/************************************************************************/
/* Begin timer to read from FPGA then write net*/
/************************************************************************/
inline void handler_fpga_read(){
  ACE_Time_Value initial (2), repeat (0, RTP_PACK_INTERVAL);
  long timerId = ACE_Reactor::instance ()->schedule_timer (timer_read_.release(), 0, initial, repeat);
}


其中
1、timer_write,timer_reader,Dgram_Endpoint分别实现ACE_Event_Handler接口
2、handler_begin_rtp()调用run_test启动udp客户端
3、第一次测试没有定义USE_POLL,第二次定义了USE_POLL


运行环境1
gcc version 4.1.2 20070115 (prerelease) (SUSE Linux)
ace-5.6.7

运行环境2
gcc version 4.3.2 (Debian 4.3.2-1.1)
ace-5.6.7

环境1结果
正常

环境2结果
1、没有定义USE_POLL的情况下
执行
输出了ACE_DEBUG((LM_INFO, "%T \t2\n"));
没有输出ACE_DEBUG((LM_INFO, "%T \t3\n"));
输出了ACE_DEBUG((LM_INFO, "%T \t100\n"));
没有输出 ACE_DEBUG((LM_INFO, "%T \t200\n"));

2、
类似

3、帮忙分析下吧,多谢
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2024-12-23 18:03 , Processed in 0.014789 second(s), 5 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表