void JAWS_Asynch_IO::read (ACE_Message_Block& mb, int size) { ACE_Asynch_Read_Stream ar; if (ar.open (*this, this->handle_) == -1 || ar.read (mb, size) == -1) this->handler_->read_error (); }
void JAWS_Asynch_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { JAWS_TRACE ("JAWS_Asynch_Handler::handle_read_stream"); this->dispatch_handler (); if (result.act () != 0) { // This callback is for io->receive_file() JAWS_TRACE ("JAWS_Asynch_Handler::handle_read_stream (recv_file)"); int code = 0; if (result.success () && result.bytes_transferred () != 0) { if (result.message_block ().length () == result.message_block ().size ()) code = ACE_Filecache_Handle::ACE_SUCCESS; else { ACE_Asynch_Read_Stream ar; if (ar.open (*this, this->handler ()->handle ()) == -1 || ar.read (result.message_block (), result.message_block ().size () - result.message_block ().length (), result.act ()) == -1) code = -1; else return; } } else code = -1; if (code == ACE_Filecache_Handle::ACE_SUCCESS) this->handler ()->receive_file_complete (); else this->handler ()->receive_file_error (code); result.message_block ().release (); delete (ACE_Filecache_Handle *) result.act (); } else { // This callback is for this->read() JAWS_TRACE ("JAWS_Asynch_Handler::handle_read_stream (read)"); if (result.success () && result.bytes_transferred () != 0) this->handler ()->read_complete (&result.message_block ()); else this->handler ()->read_error (); } }
void JAWS_Asynch_IO::receive_file (JAWS_IO_Handler *ioh, const char *filename, void *initial_data, unsigned int initial_data_length, unsigned int entire_length) { JAWS_TRACE ("JAWS_Asynch_IO::receive_file"); ioh->idle (); JAWS_Asynch_IO_Handler *aioh = dynamic_cast<JAWS_Asynch_IO_Handler *> (ioh); ACE_Message_Block *mb = 0; ACE_Filecache_Handle *handle; ACE_NEW (handle, ACE_Filecache_Handle (filename, entire_length, ACE_NOMAP)); int result = handle->error (); if (result == ACE_Filecache_Handle::ACE_SUCCESS) { ACE_OS::memcpy (handle->address (), initial_data, initial_data_length); int bytes_to_read = entire_length - initial_data_length; ACE_NEW (mb, ACE_Message_Block ((char *)handle->address () + initial_data_length, bytes_to_read)); if (mb == 0) { errno = ENOMEM; result = -1; } else { ACE_Asynch_Read_Stream ar; if (ar.open (*(aioh->handler ()), aioh->handle ()) == -1 || ar.read (*mb, mb->size () - mb->length (), handle) == -1) result = -1; } } if (result != ACE_Filecache_Handle::ACE_SUCCESS) { this->handler_->receive_file_error (result); delete mb; delete handle; } }
void JAWS_Asynch_IO::read (JAWS_IO_Handler *ioh, ACE_Message_Block* mb, unsigned int size) { JAWS_TRACE ("JAWS_Asynch_IO::read"); ioh->idle (); JAWS_Asynch_IO_Handler *aioh = dynamic_cast<JAWS_Asynch_IO_Handler *> (ioh); ACE_Asynch_Read_Stream ar; if (ar.open (*(aioh->handler ()), aioh->handle ()) == -1 || ar.read (*mb, size) == -1) aioh->read_error (); }