找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 5459|回复: 2

ace中遇到的两个棘手问题

[复制链接]
发表于 2008-11-19 11:10:30 | 显示全部楼层 |阅读模式
1 windows平台:

class install_agent_srv_handle_s : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_MT_SYNCH>
{
        ACE_Reactor_Notification_Strategy notifier_;

        virtual int open(void * = 0);

virtual int handle_input(ACE_HANDLE fd = ACE_INVALID_HANDLE);
virtual int handle_output(ACE_HANDLE fd = ACE_INVALID_HANDLE);
virtual int handle_close(ACE_HANDLE h, ACE_Reactor_Mask mask);
virtual int put(ACE_Message_Block *msg, ACE_Time_Value * = 0);
}

install_agent_srv_handle_s::install_agent_srv_handle_s(void)
       :notifier_ (0, this, ACE_Event_Handler::WRITE_MASK)
{
}

int install_agent_srv_handle_s::open(void * param)
{
int ret = -1;
ACE_NEW_RETURN(this->task_ ,install_task_s, ret);
if(this->task_->open() == 0)
{
  if(super::open(param) == 0)
  {
   int bufsize = NET_BUFFER_MAX_LENGTH;
   peer ().set_option (SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof bufsize);
   
   this->reactor()->register_handler(this, ACE_Event_Handler::WRITE_MASK);

   this->notifier_.reactor (this->reactor ());
   this->msg_queue()->notification_strategy (&this->notifier_);

   ret = 0;
      }
  }
  else
  {
   this->task_->close();
   this->task_ = NULL;
  }
}
return ret;
}

int install_agent_srv_handle_s::put(ACE_Message_Block *msg, ACE_Time_Value * )
{
return ((this->putq(msg) > 0) ? 0 : -1);
}

int install_agent_srv_handle_s::require_down_install_file(void)
{
int ret = -1;
ACE_Message_Block *msg = new ACE_Message_Block(sizeof(INSTALL_DATA_S));
if(msg)
{
  INSTALL_DATA_S *data = (INSTALL_DATA_S*)msg->wr_ptr();
  data->type = INSTALL_DATA_REQUIRE;
  data->cmd = INSTALL_REQUIRE_INSTALL;
  data->plate_form = module_platform_version();
  msg->wr_ptr(sizeof(INSTALL_DATA_S));
if((ret = put(msg) ) == -1) /* 此处每次调用并没有通知到hand_output ?????*/
  {
   msg->release();
  }
}
return ret;
}

每次调用put接口都没有触发hand_output接口,这是为什么呢?谁知道msg notify 与reactor的调度机制?是否与waitformultipulateEvent这个接口的触发条件有关系?

此模式在linux下可以使用。


2 ace的proactor如何与ssl配合使用,就是在write和recv时也能使用?
发表于 2008-11-19 13:40:31 | 显示全部楼层
这个问题,C++网络编程卷2和ACE程序员指南都有说明。
简单的说,就是触发机制的差异。windows上面有独特的地方。这里不详细叙述了,楼主要看书去。

位置:
4.2 The ACE_Select_Reactor Class
4.4 The ACE_WFMO_Reactor Class
WRITE_MASK semantics different from select(). When a socket can send more data, select() detects a WRITE condition. It will continue to detect this condition as long as the socket remains writeable, that is, until it becomes flow controlled. In contrast, the Windows WSAEventSelect() function only sets the WRITE event when the socket is first connected, whether passively or actively, and when the socket transitions from flow-controlled to writeable. When relying on WRITE events using the ACE_WFMO_Reactor, you must therefore continue to write until the connection closes or the socket becomes flow controlled and a send() fails with EWOULDBLOCK. If this behavior is undesirable, you might consider choosing the ACE_Select_Reactor as the ACE_Reactor implementation on Windows since it has the same WRITE_MASK semantics as on UNIX platforms.
 楼主| 发表于 2008-11-21 23:40:22 | 显示全部楼层
嗯,学习了。

第二个问题怎么解答呢?  就是分别在proactor和reactor模式下如何使用ssl,只有例子也是可以的阿,大家看看把这个问题能否解决掉呢?
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

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

GMT+8, 2024-12-22 17:30 , Processed in 0.022006 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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