|
楼主 |
发表于 2008-2-26 13:36:25
|
显示全部楼层
考虑到系统会运行2年以上,我才做这样的压力测试的,代码片断如下:
virtual int svc (void)
{
m_StartEvent.signal();
for (ACE_Message_Block *message = 0; ; )
{
if (this->getq (message) == -1)
ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
ACE_TEXT ("getq")),
-1);
if (message->msg_type () == ACE_Message_Block::MB_HANGUP)
{
message->release ();
break;
}
void *recordedMessage =
(void *)message->rd_ptr ();
int msg_len = (int)(message->length());
if (this->process (recordedMessage, msg_len) == -1)
{
message->release ();
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("process")),
-1);
}
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Basic_Task::svc() - ")
ACE_TEXT ("Continue to next stage \n" )));
if (this->next_step (message) < 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("put_next failed")));
message->release ();
break;
}
}
return 0;
}
virtual int close (u_long flags)
{
int rval = 0;
if (flags == 1)
{
m_StartEvent.wait();
ACE_Message_Block *hangup = new ACE_Message_Block ();
hangup->msg_type (ACE_Message_Block::MB_HANGUP);
if (this->putq (hangup) == -1)
{
hangup->release ();
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("Task::close() putq")),
-1);
}
rval = this->wait ();
}
return rval;
}
我用windbg htrace 查了,发现是ACE_Thread_Mananger::exit() 中会申请句柄,但没有释放,我不知道程序怎么会调用这个?? |
|