void Receiver::handle_read_stream (const TRB_Asynch_Read_Stream::Result &result) { this->trace_read_completion (result); // emulate long callback do_delay (cfg.delay()); // delay milliseconds { ACE_GUARD (ACE_SYNCH_MUTEX, monitor, this->mutex () ); this->ref_cnt_r_--; ACE_Message_Block & mb = result.message_block (); if (result.error () == 0 && result.bytes_transferred () > 0) { this->initiate_write_stream (&mb); this->initiate_read_stream (0); } else { mb.release (); } if (result.error () != 0) this->stream_.cancel_and_close (); if (!is_safe_to_delete()) return; } this->manager()->destroy_session(this); }
void AIO_SSL_Client_Session::handle_read_stream(const TRB_Asynch_Read_Stream::Result& result) { if ( ssl_ ) { { ACE_GUARD(ACE_SYNCH_MUTEX, monitor, this->lock_); --n_op_r_; ACE_Message_Block& mb = result.message_block(); // on read done if ( result.error() == 0 ) { update_last_time(); if ( result.bytes_transferred() == 0 ) { mb.release(); ssl_stream_.close(); } else { int rc = this->on_read_complete(mb, result); if ( rc < 1 ) { mb.release(); if ( rc < 0 && !is_cancelling_ ) { is_cancelling_ = 1; ssl_stream_.cancel(); } } } } // on read error, close session else { mb.release(); if ( !is_cancelling_ ) { is_cancelling_ = 1; ssl_stream_.cancel(); } } if ( this->has_pending_io() ) return; if ( this->is_safe_to_delete_ == 0 ) { ssl_stream_.close(); return; } this->on_close(); } manager_->destroy_session(this); } else { AIO_Session::handle_read_stream(result); } }
void PSession::trace_read_completion (const TRB_Asynch_Read_Stream::Result &result) { { ACE_GUARD (ACE_SYNCH_MUTEX, monitor, this->mutex ()); this->update_last_time(); if (result.success()) this->total_rcv_ += result.bytes_transferred (); } int loglevel = this->config().loglevel (); ACE_Message_Block & mb = result.message_block (); size_t xfer_bytes = result.bytes_transferred(); char * last = mb.wr_ptr(); char * first = last - xfer_bytes; if (loglevel == 0) { LogLocker log_lock; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) **** %s=%d handle_read_stream() ****\n"), this->get_name(), this->index())); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("bytes_to_read = %d\n"), result.bytes_to_read ())); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("handle = %d\n"), result.handle ())); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("bytes_transfered = %d\n"), xfer_bytes)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error = %d\n"), result.error ())); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("message_block:\n"))); ACE_HEX_DUMP ((LM_DEBUG, first, xfer_bytes)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("**** end of message ****************\n"))); } else if (result.error () != 0 ) { LogLocker log_lock; //ACE_Log_Msg::instance ()->errnum (result.error ()); ACE_OS::last_error (result.error ()); ACE_Log_Msg::instance ()->log (LM_ERROR, ACE_TEXT ("(%t) %s=%d READ %p\n"), this->get_name (), this->index (), ACE_TEXT ("ERROR")); } else if (loglevel == 1) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) %s=%d read_bytes=%d OK\n"), this->get_name (), this->index (), xfer_bytes)); } return; }