找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 8311|回复: 2

ACE_OS::last_error()的问题

[复制链接]
发表于 2010-9-27 08:55:17 | 显示全部楼层 |阅读模式
  1. if(m_stream.recv(buf,sizeof(buf),&timeout) <= 0 )
  2.     {                        
  3.         if(ACE_OS::last_error() != ETIME)
  4.         {
  5.             for(;;)
  6.             {
  7.                 ACE_Thread_Manager* mgr = this->thr_mgr();
  8.                 if (mgr->testcancel(mgr->thr_self()))
  9.                 {               
  10.                     return 0;
  11.                 }
  12.                 else if(Connect() == -1)
  13.                     Sleep(3*1000);
  14.                 else
  15.                     break;
  16.             }               
  17.         }            
  18.     }
复制代码
debug模式下如果没有收到数据但是连接正常ACE_OS::last_error()会返回ETIME
但是release模式下不会返回ETIME,想要在release模式下也返回超时,该怎么做?谢谢诸位
发表于 2010-9-27 09:56:53 | 显示全部楼层
你可以换一种判断方法,比如这样。
if(nDataLen <= 0)
        {
                m_u4CurrSize = 0;
                uint32 u4Error = (uint32)errno;
        }
发表于 2010-9-27 16:38:09 | 显示全部楼层
不要用(mgr->testcancel(mgr->thr_self()))这种方式检查线程是否退出,
他会遍历ACE_Thread_Manager管理的所有task指针,代价非常重。
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

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

GMT+8, 2024-5-19 10:01 , Processed in 0.014848 second(s), 5 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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