|
在服务器关闭后,客户端在delete this的时候发生错误,内存引用的错误,怎么解决呀?-
- int Client::open (void *p)
- {
- if (super::open (p) == -1)
- return -1;
- ACE_Time_Value iter_delay (10);
- ACE_Time_Value init_delay (10);
- this->notifier_.reactor (this->reactor ());
- this->msg_queue ()->notification_strategy (&this->notifier_);
- return this->reactor ()->schedule_timer(this, 0, init_delay, iter_delay);
- //this->reactor()->register_handler(this, ACE_Event_Handler::WRITE_MASK);
- //ACE_Reactor::instance()->register_handler(this, ACE_Event_Handler::WRITE_MASK);
- //this->msg_queue ()->notification_strategy (&this->notifier_);
- //return 0;
- }
- int Client::handle_input (ACE_HANDLE fd)
- {
- char recv_data[40960];
- memset(recv_data, 0, 40960);
- ssize_t recv_cnt = 0;
- int index = 0;
- int stamp = -1;
- BOOL bData = TRUE;
- recv_cnt = this->peer().recv (recv_data, 40960);
- count --;
- if (recv_cnt != -1)
- {
- ......
- }
- if (recv_cnt == 0 || ACE_OS::last_error () != EWOULDBLOCK)
- {
- this->reactor()->end_reactor_event_loop();
- return -1;
- }
- return 0;
- }
- int Client::handle_timeout(const ACE_Time_Value &, const void *)
- {
- /*int ilen = 0;
- BYTE *send_data = NULL;
- ACE_Message_Block *mb;
- ACE_NEW_RETURN (mb, ACE_Message_Block (128), -1);
- titan.MakeBeatingTest(&send_data, ilen);
- mb->copy((const char*)send_data, ilen);
- ACE_ASSERT (ilen > 0);
- this->putq (mb);*/
- if (++this->iterations_ >= ITERATIONS)
- {
- this->peer().close_writer();
- return 0;
- }
- ACE_Message_Block *mb;
- ACE_NEW_RETURN(mb, ACE_Message_Block(128), -1);
- char msg[128];
- ACE_OS::sprintf(msg, "Iteration %d\n", this->iterations_);
- this->putq(mb);
- return 0;
- }
- int Client::handle_output (ACE_HANDLE fd)
- {
- char *aa = "fafda";
- this->peer().send(aa, strlen(aa));
- count ++;
- ACE_Message_Block *mb;
- ACE_Time_Value nowait (ACE_OS::gettimeofday ());
- while (-1 != this->getq (mb, &nowait))
- {
- ssize_t send_cnt = this->peer ().send (mb->rd_ptr (), mb->length ());
- if (send_cnt != -1)
- mb->rd_ptr (static_cast<size_t> (send_cnt));
- if (mb->length () > 0)
- {
- this->ungetq (mb);
- break;
- }
- mb->release ();
- }
- if (this->msg_queue ()->is_empty ())
- this->reactor ()->cancel_wakeup(this, ACE_Event_Handler::WRITE_MASK);
- else
- this->reactor ()->schedule_wakeup(this, ACE_Event_Handler::DONT_CALL);
- return 0;
- }
复制代码 我实在是找不到在问题在那了 |
|