diff options
author | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-10-05 23:37:26 +0000 |
---|---|---|
committer | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-10-05 23:37:26 +0000 |
commit | 6ead053a82bc686d6f56cb0bb619613211798b2b (patch) | |
tree | 9f1ae0648e6fc071cbbbbcae431e311184d329c6 | |
parent | 5d4e8aca4d115181aa8a32ff82d45234a02b7754 (diff) | |
download | ATCD-6ead053a82bc686d6f56cb0bb619613211798b2b.tar.gz |
Removed tabs and trailing whitespace.
-rw-r--r-- | ace/Asynch_IO.cpp | 312 | ||||
-rw-r--r-- | ace/Asynch_IO.h | 222 | ||||
-rw-r--r-- | ace/Proactor.cpp | 316 |
3 files changed, 425 insertions, 425 deletions
diff --git a/ace/Asynch_IO.cpp b/ace/Asynch_IO.cpp index ed247ae1656..3491658089d 100644 --- a/ace/Asynch_IO.cpp +++ b/ace/Asynch_IO.cpp @@ -198,7 +198,7 @@ ACE_Asynch_Operation::register_aio_with_proactor (aiocb *aiocb_ptr) else return 0; } - + // Non-zero ptr. Find a free slot and store. // Make sure again. @@ -215,7 +215,7 @@ ACE_Asynch_Operation::register_aio_with_proactor (aiocb *aiocb_ptr) ai++) if (this->proactor_->aiocb_list_[ai] == 0) break; - + // Sanity check. if (ai == this->proactor_->aiocb_list_max_size_) ACE_ERROR_RETURN ((LM_ERROR, @@ -249,13 +249,13 @@ ACE_Asynch_Read_Stream::read (ACE_Message_Block &message_block, // Create the Asynch_Result. Result *result = 0; ACE_NEW_RETURN (result, - Result (*this->handler_, - this->handle_, - message_block, - bytes_to_read, - act, - this->proactor_->get_handle ()), - -1); + Result (*this->handler_, + this->handle_, + message_block, + bytes_to_read, + act, + this->proactor_->get_handle ()), + -1); ssize_t return_val = this->shared_read (result); if (return_val == -1) @@ -267,9 +267,9 @@ int ACE_Asynch_Read_Stream::shared_read (ACE_Asynch_Read_Stream::Result *result) { #if defined (ACE_HAS_AIO_CALLS) - // Act according to the completion strategy that is set in the + // Act according to the completion strategy that is set in the // proactor. - + // Using RT Signals to notify the completion. if (this->proactor ()->posix_completion_strategy () == ACE_Proactor::RT_SIGNALS) @@ -296,11 +296,11 @@ ACE_Asynch_Read_Stream::shared_read (ACE_Asynch_Read_Stream::Result *result) else { // AIO_CONTROL_BLOCKS strategy. - + // Make a new AIOCB and issue aio_read, if queueing is possible // store this with the Proactor, so that that can be used for // <aio_return> and <aio_error>. - + // Allocate aiocb block. aiocb *aiocb_ptr = 0; ACE_NEW_RETURN (aiocb_ptr, @@ -312,11 +312,11 @@ ACE_Asynch_Read_Stream::shared_read (ACE_Asynch_Read_Stream::Result *result) { // Clean up the memory allocated. delete aiocb_ptr; - + // @@ Set errno to EAGAIN so that applications will know this as // a queueing failure and try again this aio_read it they want. errno = EAGAIN; - + return -1; } @@ -457,13 +457,13 @@ ACE_Asynch_Write_Stream::write (ACE_Message_Block &message_block, { Result *result = 0; ACE_NEW_RETURN (result, - Result (*this->handler_, - this->handle_, - message_block, - bytes_to_write, - act, - this->proactor_->get_handle ()), - -1); + Result (*this->handler_, + this->handle_, + message_block, + bytes_to_write, + act, + this->proactor_->get_handle ()), + -1); ssize_t return_val = this->shared_write (result); if (return_val == -1) @@ -475,9 +475,9 @@ int ACE_Asynch_Write_Stream::shared_write (ACE_Asynch_Write_Stream::Result *result) { #if defined (ACE_HAS_AIO_CALLS) - // Act according to the completion strategy that is set in the + // Act according to the completion strategy that is set in the // proactor. - if (this->proactor ()->posix_completion_strategy () == + if (this->proactor ()->posix_completion_strategy () == ACE_Proactor::RT_SIGNALS) { // Setup AIOCB. @@ -491,7 +491,7 @@ ACE_Asynch_Write_Stream::shared_write (ACE_Asynch_Write_Stream::Result *result) result->aiocb_ptr ()->aio_sigevent.sigev_signo = ACE_SIG_AIO; result->aiocb_ptr ()->aio_sigevent.sigev_value.sival_ptr = (void *) result; - + // Fire off the aio write. if (aio_write (result->aiocb_ptr ()) == -1) // Queueing failed. @@ -499,14 +499,14 @@ ACE_Asynch_Write_Stream::shared_write (ACE_Asynch_Write_Stream::Result *result) "%p:Asynch_Write_Stream: aio_write queueing failed\n"), -1); } - else + else { // AIO_CONTROL_BLOCKS strategy. - + // Make a new AIOCB and issue aio_write, if queueing is possible // store this with the Proactor, so that that can be used for // <aio_return> and <aio_error>. - + // Allocate aiocb block. aiocb *aiocb_ptr = 0; ACE_NEW_RETURN (aiocb_ptr, @@ -548,23 +548,23 @@ ACE_Asynch_Write_Stream::shared_write (ACE_Asynch_Write_Stream::Result *result) // Clean up the memory allocated. delete aiocb_ptr; - + return -1; } - + // Success. Store the aiocb_ptr with Proactor. if (this->register_aio_with_proactor (aiocb_ptr) == -1) { // Clean up the memory allocated. delete aiocb_ptr; - + return -1; } } - + // Aio successfully issued. return 0; - + #else /* ACE_HAS_AIO_CALLS */ u_long bytes_written; @@ -776,10 +776,10 @@ class ACE_Export ACE_Asynch_Accept_Handler : public ACE_Event_Handler { // = TITLE // For the POSIX implementation, this class takes care of doing - // Asynch_Accept. - // + // Asynch_Accept. + // // = DESCRIPTION - // + // public: ACE_Asynch_Accept_Handler (ACE_Reactor* reactor = 0, ACE_Proactor* proactor = 0); @@ -787,39 +787,39 @@ public: // the handlers. Give also the proactor used here, so that the // handler can send information through the notification pipe of the // proactor, in case AIO_CONTROL_BLOCKS strategy is used. - + ~ACE_Asynch_Accept_Handler (void); // Destructor. - + int register_accept_call (ACE_Asynch_Accept::Result* result); - // Register this <accept> call with the local handler. - - virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE); + // Register this <accept> call with the local handler. + + virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE); // Called when accept event comes up on the <listen_handle>. private: ACE_Asynch_Accept::Result* deregister_accept_call (void); // Undo the things done when registering. - + ACE_Unbounded_Queue<ACE_Asynch_Accept::Result*> result_queue_; // Queue of Result pointers that correspond to all the <accept>'s - // pending. - + // pending. + ACE_Reactor* reactor_; // Reactor used by the Asynch_Accept. We need this here to enable // and disable the <handle> now and then, depending on whether any - // <accept> is pending or no. + // <accept> is pending or no. ACE_Thread_Mutex lock_; // The lock to protect the result queue which is shared. The queue // is updated by main thread in the register function call and // through the auxillary thread in the deregister fun. So let us - // mutex it. + // mutex it. ACE_Asynch_Accept_Handler (void); // Default constructor shouldn't be called. Without a reactor, this - // class wont make sense. - + // class wont make sense. + ACE_Proactor* proactor_; // Proactor used by the Asynch_Accept class. }; @@ -833,7 +833,7 @@ ACE_Asynch_Accept_Handler::ACE_Asynch_Accept_Handler (ACE_Reactor* reactor, this->reactor_ = ACE_Reactor::instance (); if (this->proactor_ == 0) this->proactor_ = ACE_Proactor::instance (); -} +} ACE_Asynch_Accept_Handler::~ACE_Asynch_Accept_Handler (void) { @@ -848,30 +848,30 @@ ACE_Asynch_Accept_Handler::register_accept_call (ACE_Asynch_Accept::Result* resu // thru the auxillary thread in the deregister fun. So let us mutex // it. ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); - + // Insert this result to the queue. int insert_result = this->result_queue_.enqueue_tail (result); if (insert_result == -1) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:ACE_Asynch_Accept_Handler::register_accept_call failed\n"), - -1); - + -1); + // If this is the only item, then it means there the set was empty // before. So enable the <handle> in the reactor. if (this->result_queue_.size () == 1) this->reactor_->resume_handlers (); - + return 0; } -ACE_Asynch_Accept::Result* +ACE_Asynch_Accept::Result* ACE_Asynch_Accept_Handler::deregister_accept_call (void) { // The queue is updated by main thread in the register function call and // thru the auxillary thread in the deregister fun. So let us mutex // it. ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0); - + // Get the first item (result ptr) from the Queue. ACE_Asynch_Accept::Result* result = 0; int return_dequeue = this->result_queue_.dequeue_head (result); @@ -880,9 +880,9 @@ ACE_Asynch_Accept_Handler::deregister_accept_call (void) // Sanity check. if (result == 0) return 0; - + // Disable the <handle> in the reactor if no <accept>'s are - // pending. + // pending. if (this->result_queue_.size () == 0) this->reactor_->suspend_handlers (); @@ -895,14 +895,14 @@ ACE_Asynch_Accept_Handler::handle_input (ACE_HANDLE fd) { // An <accept> has been sensed on the <listen_handle>. We should be // able to just go ahead and do the <accept> now on this <fd>. This - // should be the same as the <listen_handle>. + // should be the same as the <listen_handle>. // @@ Debugging. ACE_DEBUG ((LM_DEBUG, "ACE_Asynch_Accept_Handler::handle_input called\n")); - - // Deregister this info pertaining to this <accept> call. + + // Deregister this info pertaining to this <accept> call. ACE_Asynch_Accept::Result* result = this->deregister_accept_call (); - + // @@ Debugging. ACE_DEBUG ((LM_DEBUG, "(%t):ACE_Asynch_Accept_Handler::handle_input : fd = [%d], Result->listen_handle = [%d]\n", @@ -912,17 +912,17 @@ ACE_Asynch_Accept_Handler::handle_input (ACE_HANDLE fd) // There is not going to be any data read. So we can use the // <message_block> itself to take the <remote_address> as well as // the size of that address. - + // We will have atleast 2 * (sizeof (sockaddr_in) + sizeof (sockaddr)). size_t buffer_size = sizeof (sockaddr_in) + sizeof (sockaddr); - + // Parameters for the <accept> call. int *address_size = (int *)result->message_block ().wr_ptr (); *address_size = buffer_size; - + // Increment the wr_ptr. result->message_block ().wr_ptr (sizeof (int)); - + // Issue <accept> now. // @@ We shouldnt block here since we have already done poll/select // thru reactor. But are we sure? @@ -934,20 +934,20 @@ ACE_Asynch_Accept_Handler::handle_input (ACE_HANDLE fd) "Error:(%P | %t):%p:\n", "<accept> system call failed"), -1); - + // Accept has completed. // Update the <wr_ptr> for the <message block>. result->message_block ().wr_ptr (*address_size); - + // @@ Just debugging. ACE_DEBUG ((LM_DEBUG, "%N:%l:Address_size = [%d], New_handle = [%d]\n", - *address_size, new_handle)); - + *address_size, new_handle)); + // Store the new handle. result->accept_handle_ = new_handle; - + // Notify the mail process about this completion // Signal the main process about this completion or send the result // pointer thru the notify pipe depending on what is Completion @@ -960,50 +960,50 @@ ACE_Asynch_Accept_Handler::handle_input (ACE_HANDLE fd) // @@ Debugging. ACE_DEBUG ((LM_DEBUG, "ACE_Asynch_Accept_Handler::handle_input: RT_SIGNALS\n")); - + // Get this process id. pid_t pid = ACE_OS::getpid (); if (pid == (pid_t) -1) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "Error:(%P | %t):%p:", "<getpid> failed\n"), -1); - + // Set the signal information. sigval value; value.sival_ptr = (void *) result; - + // Queue the signal. if (sigqueue (pid, ACE_SIG_AIO, value) == -1) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "Error:(%P | %t):%p:", "<sigqueue> failed\n"), -1); } break; - + case ACE_Proactor::AIO_CONTROL_BLOCKS: // @@ Debugging. ACE_DEBUG ((LM_DEBUG, "ACE_Asynch_Accept_Handler::handle_input: AIO_CONTROL_BLOCKS\n")); - + // Send the Result through the notification pipe. if (this->proactor_->notify_asynch_accept (result) == -1) return -1; break; - + default: ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:Unknow POSIX_COMPLETION_STRATEGY\n"), -1); } - + return 0; -} +} #endif /* ACE_HAS_AIO_CALLS */ #if defined (ACE_HAS_AIO_CALLS) -// We need accept handlers here. +// We need accept handlers here. ACE_Asynch_Accept::ACE_Asynch_Accept (void) : accept_handler_ (0) { @@ -1023,37 +1023,37 @@ ACE_Asynch_Accept::open(ACE_Handler &handler, ACE_Proactor *proactor) { ACE_DEBUG ((LM_DEBUG, "ACE_Asynch_Accept::open called\n")); - - // Common things to register for any Asynch Operation. We need to + + // Common things to register for any Asynch Operation. We need to // call the base class' <open> method. - int result_open = this->ACE_Asynch_Operation::open (handler, + int result_open = this->ACE_Asynch_Operation::open (handler, handle, completion_key, proactor); if (result_open < 0) return result_open; - + // Init the Asynch_Accept_Handler now. Only now it can be inited, - // because it needs to keep Proactor also with it. + // because it needs to keep Proactor also with it. ACE_NEW_RETURN (this->accept_handler_, ACE_Asynch_Accept_Handler (&this->reactor_, this->proactor_), -1); - + // Register the handle with the reactor. this->reactor_.register_handler (this->handle_, this->accept_handler_, ACE_Event_Handler::ACCEPT_MASK); - + // Suspend the <handle> now. Enable only when the <accept> is issued // by the application. this->reactor_.suspend_handlers (); - + // Spawn the thread. It is the only thread we are going to have. It // will do the <handle_events> on the reactor. ACE_Thread_Manager::instance ()->spawn (ACE_Asynch_Accept::thread_function, (void *)&this->reactor_); - + return 0; } #endif /* ACE_HAS_AIO_CALLS */ @@ -1065,14 +1065,14 @@ ACE_Asynch_Accept::accept (ACE_Message_Block &message_block, const void *act) { #if (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) || (defined (ACE_HAS_AIO_CALLS)) - - // @@ Debugging. + + // @@ Debugging. ACE_DEBUG ((LM_DEBUG, "ACE_Asynch_Accept::accept called\n")); - + // Common code for both WIN and POSIX. - + // Sanity check: make sure that enough space has been allocated by - // the caller. + // the caller. size_t address_size = sizeof (sockaddr_in) + sizeof (sockaddr); size_t space_in_use = message_block.wr_ptr () - message_block.base (); size_t total_size = message_block.size (); @@ -1083,7 +1083,7 @@ ACE_Asynch_Accept::accept (ACE_Message_Block &message_block, #if !defined (ACE_HAS_AIO_CALLS) // WIN Specific. - + int close_accept_handle = 0; // If the <accept_handle> is invalid, we will create a new socket. if (accept_handle == ACE_INVALID_HANDLE) @@ -1115,16 +1115,16 @@ ACE_Asynch_Accept::accept (ACE_Message_Block &message_block, #if defined (ACE_HAS_AIO_CALLS) // Code specific to the POSIX Implementation. - - // Register this <accept> call with the local handler. + + // Register this <accept> call with the local handler. this->accept_handler_->register_accept_call (result); - + return 0; #else /* Not ACE_HAS_AIO_CALLS */ // Code specific to WIN platforms. - + u_long bytes_read; - + // Initiate the accept. int initiate_result = ::AcceptEx ((SOCKET) result->listen_handle (), (SOCKET) result->accept_handle (), @@ -1171,16 +1171,16 @@ ACE_Asynch_Accept::accept (ACE_Message_Block &message_block, void* ACE_Asynch_Accept::thread_function (void* arg_reactor) { - ACE_DEBUG ((LM_DEBUG, "ACE_Asynch_Accept::thread_function called\n")); - + ACE_DEBUG ((LM_DEBUG, "ACE_Asynch_Accept::thread_function called\n")); + // Retrieve the reactor pointer from the argument. ACE_Reactor* reactor = (ACE_Reactor *) arg_reactor; if (reactor == 0) reactor = ACE_Reactor::instance (); - - // For this reactor, this thread is the owner. + + // For this reactor, this thread is the owner. reactor->owner (ACE_OS::thr_self ()); - + // Handle events. int result = 0; while (result != -1) @@ -1190,7 +1190,7 @@ ACE_Asynch_Accept::thread_function (void* arg_reactor) "ACE_Asynch_Accept::Thread_Function : handle_events : result = [%d]\n", result)); } - + ACE_DEBUG ((LM_DEBUG, "Exiting ACE_Asynch_Accept::thread_function \n")); return 0; } @@ -1276,7 +1276,7 @@ public: // to write....) and the the <proactor> pointer tells this class // the <proactor> that is being used by the // Asynch_Transmit_Operation and the application. - + virtual ~ACE_Asynch_Transmit_Handler (void); // Destructor. @@ -1301,7 +1301,7 @@ private: ACE_Proactor *proactor_; // The Proactor that is being used by the application handler and // so the Asynch_Transmit_File. - + ACE_Asynch_Read_File rf_; // To read from the file to be transmitted. @@ -1331,7 +1331,7 @@ private: size_t bytes_transferred_; // Number of bytes transferred on the stream. - + size_t transmit_file_done_; // Flag to indicate that the transmitting is over. }; @@ -1384,7 +1384,7 @@ ACE_Asynch_Transmit_Handler::transmit (void) ACE_ERROR_RETURN ((LM_ERROR, "ACE_Asynch_Transmit_Handler:write_stream open failed\n"), -1); - + // Transmit the header. if (this->ws_.write (*this->result_->header_and_trailer ()->header (), this->result_->header_and_trailer ()->header_bytes (), @@ -1392,19 +1392,19 @@ ACE_Asynch_Transmit_Handler::transmit (void) ACE_ERROR_RETURN ((LM_ERROR, "Asynch_Transmit_Handler:transmitting header:write_stream failed\n"), -1); - + // @@ We need to finish the transmitting, before returning to the // user code. Otherwise <transmit> may not be atmoic. User's other // <read> or <write> on the same socket might damage the order of - // the current file transmission. + // the current file transmission. int error = 0; while (!error && !this->transmit_file_done_) error = this->proactor_->handle_events (); - + if (!error && this->transmit_file_done_) - // No error, transmission done. + // No error, transmission done. return 0; - else + else return -1; } @@ -1419,7 +1419,7 @@ ACE_Asynch_Transmit_Handler::handle_write_stream (const ACE_Asynch_Write_Stream: { ACE_ERROR ((LM_ERROR, "Asynch_Transmit_File failed.\n")); - + ACE_SEH_TRY { this->result_->complete (this->bytes_transferred_, @@ -1433,16 +1433,16 @@ ACE_Asynch_Transmit_Handler::handle_write_stream (const ACE_Asynch_Write_Stream: delete this; } } - + // Write stream successful. - + // Partial write to socket. int unsent_data = result.bytes_to_write () - result.bytes_transferred (); if (unsent_data != 0) { // Reset pointers. result.message_block ().rd_ptr (result.bytes_transferred ()); - + // Duplicate the message block and retry remaining data if (this->ws_.write (*result.message_block ().duplicate (), unsent_data, @@ -1485,7 +1485,7 @@ ACE_Asynch_Transmit_Handler::handle_write_stream (const ACE_Asynch_Write_Stream: delete this; } break; - + case HEADER_ACT: case DATA_ACT: // If header/data was sent, initiate the file data transmission. @@ -1494,7 +1494,7 @@ ACE_Asynch_Transmit_Handler::handle_write_stream (const ACE_Asynch_Write_Stream: ACE_ERROR ((LM_ERROR, "Error:Asynch_Transmit_Handler:read_file couldnt be initiated\n")); break; - + default: // @@ Handle this error. ACE_ERROR ((LM_ERROR, @@ -1508,7 +1508,7 @@ ACE_Asynch_Transmit_Handler::handle_read_file (const ACE_Asynch_Read_File::Resul // Failure. if (result.success () == 0) { - // + // ACE_SEH_TRY { this->result_->complete (this->bytes_transferred_, @@ -1526,7 +1526,7 @@ ACE_Asynch_Transmit_Handler::handle_read_file (const ACE_Asynch_Read_File::Resul // Read successful. if (result.bytes_transferred () == 0) return; - + // Increment offset and write data to network. this->file_offset_ += result.bytes_transferred (); if (this->ws_.write (result.message_block (), @@ -1612,35 +1612,35 @@ ACE_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, Result *result = 0; ACE_NEW_RETURN (result, - Result (*this->handler_, - this->handle_, - file, - header_and_trailer, - bytes_to_write, - offset, - offset_high, - bytes_per_send, - flags, - act, - this->proactor_->get_handle ()), - -1); + Result (*this->handler_, + this->handle_, + file, + header_and_trailer, + bytes_to_write, + offset, + offset_high, + bytes_per_send, + flags, + act, + this->proactor_->get_handle ()), + -1); // Make the auxillary handler and initiate transmit. ACE_Asynch_Transmit_Handler *transmit_handler = 0; ACE_NEW_RETURN (transmit_handler, ::ACE_Asynch_Transmit_Handler (result, - this->proactor_), + this->proactor_), -1); ssize_t return_val = transmit_handler->transmit (); - + if (return_val == -1) // This deletes the <result> in it too. delete transmit_handler; - + return 0; - + #elif (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) Result *result = 0; ACE_NEW_RETURN (result, @@ -1872,27 +1872,27 @@ ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void) // If header is valid, set the fields if (this->header_ != 0) - { - this->transmit_buffers_.Head = this->header_->rd_ptr (); - this->transmit_buffers_.HeadLength = this->header_bytes_; - } + { + this->transmit_buffers_.Head = this->header_->rd_ptr (); + this->transmit_buffers_.HeadLength = this->header_bytes_; + } else - { - this->transmit_buffers_.Head = 0; - this->transmit_buffers_.HeadLength = 0; - } + { + this->transmit_buffers_.Head = 0; + this->transmit_buffers_.HeadLength = 0; + } // If trailer is valid, set the fields if (this->trailer_ != 0) - { - this->transmit_buffers_.Tail = this->trailer_->rd_ptr (); - this->transmit_buffers_.TailLength = this->trailer_bytes_; - } + { + this->transmit_buffers_.Tail = this->trailer_->rd_ptr (); + this->transmit_buffers_.TailLength = this->trailer_bytes_; + } else - { - this->transmit_buffers_.Tail = 0; - this->transmit_buffers_.TailLength = 0; - } + { + this->transmit_buffers_.Tail = 0; + this->transmit_buffers_.TailLength = 0; + } // Return the transmit buffers return &this->transmit_buffers_; diff --git a/ace/Asynch_IO.h b/ace/Asynch_IO.h index 75d5ac9c1dc..0e2c513ec0e 100644 --- a/ace/Asynch_IO.h +++ b/ace/Asynch_IO.h @@ -20,7 +20,7 @@ // = AUTHOR // Irfan Pyarali (irfan@cs.wustl.edu), // Tim Harrison (harrison@cs.wustl.edu) and -// Alexander Babu Arulanthu <alex@cs.wustl.edu> +// Alexander Babu Arulanthu <alex@cs.wustl.edu> // // ============================================================================ @@ -85,16 +85,16 @@ public: // make sense only when doing file I/O. ACE_Asynch_Result (ACE_Handler &handler, - const void* act, - ACE_HANDLE event, - u_long offset = 0, - u_long offset_high = 0); + const void* act, + ACE_HANDLE event, + u_long offset = 0, + u_long offset_high = 0); // Constructor. #if defined (ACE_HAS_AIO_CALLS) aiocb* aiocb_ptr (void); - // Returns the underlying <aio control block> used to issue the aio - // call. + // Returns the underlying <aio control block> used to issue the aio + // call. #endif /* ACE_HAS_AIO_CALLS */ virtual ~ACE_Asynch_Result (void); @@ -102,9 +102,9 @@ public: protected: virtual void complete (u_long bytes_transferred, - int success, - const void *completion_key, - u_long error = 0) = 0; + int success, + const void *completion_key, + u_long error = 0) = 0; // This is the key method. Subclasses will override this method to // call the correct callback on the handler. @@ -125,13 +125,13 @@ protected: u_long error_; // Error if operation failed. - + #if defined (ACE_HAS_AIO_CALLS) aiocb *aiocb_ptr_; // This is the <aio control block> used to issue the <aio_> // call. Let us give this to the OS along with the result, so that // on completion we can take this and use it for <aio_error> and - // <aio_return>. + // <aio_return>. #endif /* ACE_HAS_AIO_CALLS */ }; @@ -146,9 +146,9 @@ class ACE_Export ACE_Asynch_Operation // factor out this code. public: int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); // Initializes the factory with information which will be used with // each asynchronous call. If (<handle> == ACE_INVALID_HANDLE), // <ACE_Handler::handle> will be called on the <handler> to get the @@ -207,11 +207,11 @@ public: // A do nothing constructor. int read (ACE_Message_Block &message_block, - u_long bytes_to_read, - const void *act = 0); + u_long bytes_to_read, + const void *act = 0); // This starts off an asynchronous read. Upto <bytes_to_read> will // be read and stored in the <message_block>. - + protected: int shared_read (Result *result); // This is the method which does the real work and is there so that @@ -247,18 +247,18 @@ public: // These two should really be protected. But sometimes it // simplifies code to be able to "fake" a result. Use carefully. Result (ACE_Handler &handler, - ACE_HANDLE handle, - ACE_Message_Block &message_block, - u_long bytes_to_read, - const void* act, - ACE_HANDLE event); + ACE_HANDLE handle, + ACE_Message_Block &message_block, + u_long bytes_to_read, + const void* act, + ACE_HANDLE event); // Constructor is protected since creation is limited to // ACE_Asynch_Read_Stream factory. virtual void complete (u_long bytes_transferred, - int success, - const void *completion_key, - u_long error = 0); + int success, + const void *completion_key, + u_long error = 0); // ACE_Proactor will call this method when the read completes. protected: @@ -293,11 +293,11 @@ public: // A do nothing constructor. int write (ACE_Message_Block &message_block, - u_long bytes_to_write, - const void *act = 0); + u_long bytes_to_write, + const void *act = 0); // This starts off an asynchronous write. Upto <bytes_to_write> // will be written from the <message_block>. - + protected: int shared_write (Result *result); // This is the method which does the real work and is there so that @@ -333,18 +333,18 @@ public: // These two should really be protected. But sometimes it // simplifies code to be able to "fake" a result. Use carefully. Result (ACE_Handler &handler, - ACE_HANDLE handle, - ACE_Message_Block &message_block, - u_long bytes_to_write, - const void* act, - ACE_HANDLE event); + ACE_HANDLE handle, + ACE_Message_Block &message_block, + u_long bytes_to_write, + const void* act, + ACE_HANDLE event); // Constructor is protected since creation is limited to // ACE_Asynch_Write_Stream factory. virtual void complete (u_long bytes_transferred, - int success, - const void *completion_key, - u_long error = 0); + int success, + const void *completion_key, + u_long error = 0); // ACE_Proactor will call this method when the write completes. protected: @@ -377,10 +377,10 @@ class ACE_Export ACE_Asynch_Read_File : public ACE_Asynch_Read_Stream // allows the user to specify an offset for the read. public: int read (ACE_Message_Block &message_block, - u_long bytes_to_read, - u_long offset = 0, - u_long offset_high = 0, - const void *act = 0); + u_long bytes_to_read, + u_long offset = 0, + u_long offset_high = 0, + const void *act = 0); // This starts off an asynchronous read. Upto <bytes_to_read> will // be read and stored in the <message_block>. The read will start // at <offset> from the beginning of the file. @@ -411,20 +411,20 @@ public: // These two should really be protected. But sometimes it // simplifies code to be able to "fake" a result. Use carefully. Result (ACE_Handler &handler, - ACE_HANDLE handle, - ACE_Message_Block &message_block, - u_long bytes_to_read, - const void* act, - u_long offset, - u_long offset_high, - ACE_HANDLE event); + ACE_HANDLE handle, + ACE_Message_Block &message_block, + u_long bytes_to_read, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event); // Constructor is protected since creation is limited to // ACE_Asynch_Read_File factory. virtual void complete (u_long bytes_transferred, - int success, - const void *completion_key, - u_long error = 0); + int success, + const void *completion_key, + u_long error = 0); // ACE_Proactor will call this method when the read completes. }; }; @@ -446,10 +446,10 @@ public: // This class differs slightly from ACE_Asynch_Write_Stream as // it allows the user to specify an offset for the write. int write (ACE_Message_Block &message_block, - u_long bytes_to_write, - u_long offset = 0, - u_long offset_high = 0, - const void *act = 0); + u_long bytes_to_write, + u_long offset = 0, + u_long offset_high = 0, + const void *act = 0); // This starts off an asynchronous write. Upto <bytes_to_write> // will be write and stored in the <message_block>. The write will // start at <offset> from the beginning of the file. @@ -481,20 +481,20 @@ public: // These two should really be protected. But sometimes it // simplifies code to be able to "fake" a result. Use carefully. Result (ACE_Handler &handler, - ACE_HANDLE handle, - ACE_Message_Block &message_block, - u_long bytes_to_write, - const void* act, - u_long offset, - u_long offset_high, - ACE_HANDLE event); + ACE_HANDLE handle, + ACE_Message_Block &message_block, + u_long bytes_to_write, + const void* act, + u_long offset, + u_long offset_high, + ACE_HANDLE event); // Constructor is protected since creation is limited to // ACE_Asynch_Write_File factory. virtual void complete (u_long bytes_transferred, - int success, - const void *completion_key, - u_long error = 0); + int success, + const void *completion_key, + u_long error = 0); // ACE_Proactor will call this method when the write completes. }; }; @@ -517,16 +517,16 @@ public: #if defined (ACE_HAS_AIO_CALLS) int open (ACE_Handler &handler, - ACE_HANDLE handle = ACE_INVALID_HANDLE, - const void *completion_key = 0, - ACE_Proactor *proactor = 0); + ACE_HANDLE handle = ACE_INVALID_HANDLE, + const void *completion_key = 0, + ACE_Proactor *proactor = 0); // (We will also call base class's <open> from here). #endif /* ACE_HAS_AIO_CALLS */ int accept (ACE_Message_Block &message_block, - u_long bytes_to_read, - ACE_HANDLE accept_handle = ACE_INVALID_HANDLE, - const void *act = 0); + u_long bytes_to_read, + ACE_HANDLE accept_handle = ACE_INVALID_HANDLE, + const void *act = 0); // This starts off an asynchronous accept. The asynchronous accept // call also allows any initial data to be returned to the // <handler>. Upto <bytes_to_read> will be read and stored in the @@ -554,7 +554,7 @@ public: #if defined (ACE_HAS_AIO_CALLS) friend class ACE_Asynch_Accept_Handler; - // This factory does it all, so it needs spl privileges. + // This factory does it all, so it needs spl privileges. #endif /* ACE_HAS_AIO_CALLS */ u_long bytes_to_read (void) const; @@ -575,19 +575,19 @@ public: // These two should really be protected. But sometimes it // simplifies code to be able to "fake" a result. Use carefully. Result (ACE_Handler &handler, - ACE_HANDLE listen_handle, - ACE_HANDLE accept_handle, - ACE_Message_Block &message_block, - u_long bytes_to_read, - const void* act, - ACE_HANDLE event); + ACE_HANDLE listen_handle, + ACE_HANDLE accept_handle, + ACE_Message_Block &message_block, + u_long bytes_to_read, + const void* act, + ACE_HANDLE event); // Constructor is protected since creation is limited to // ACE_Asynch_Accept factory. virtual void complete (u_long bytes_transferred, - int success, - const void *completion_key, - u_long error = 0); + int success, + const void *completion_key, + u_long error = 0); // ACE_Proactor will call this method when the accept completes. protected: @@ -607,7 +607,7 @@ public: private: #if defined (ACE_HAS_AIO_CALLS) static void* thread_function (void* reactor); - // The thread function that does handle events + // The thread function that does handle events ACE_Reactor reactor_; // Reactor to wait on the <listen_handle>. @@ -644,13 +644,13 @@ public: // A "do-nothing" constructor. int transmit_file (ACE_HANDLE file, - Header_And_Trailer *header_and_trailer = 0, - u_long bytes_to_write = 0, - u_long offset = 0, - u_long offset_high = 0, - u_long bytes_per_send = 0, - u_long flags = 0, - const void *act = 0); + Header_And_Trailer *header_and_trailer = 0, + u_long bytes_to_write = 0, + u_long offset = 0, + u_long offset_high = 0, + u_long bytes_per_send = 0, + u_long flags = 0, + const void *act = 0); // This starts off an asynchronous transmit file. The <file> is a // handle to an open file. <header_and_trailer> is a pointer to a // data structure that contains pointers to data to send before and @@ -701,23 +701,23 @@ public: // These two should really be protected. But sometimes it // simplifies code to be able to "fake" a result. Use carefully. Result (ACE_Handler &handler, - ACE_HANDLE socket, - ACE_HANDLE file, - Header_And_Trailer *header_and_trailer, - u_long bytes_to_write, - u_long offset, - u_long offset_high, - u_long bytes_per_send, - u_long flags, - const void *act, - ACE_HANDLE event); + ACE_HANDLE socket, + ACE_HANDLE file, + Header_And_Trailer *header_and_trailer, + u_long bytes_to_write, + u_long offset, + u_long offset_high, + u_long bytes_per_send, + u_long flags, + const void *act, + ACE_HANDLE event); // Constructor is protected since creation is limited to // ACE_Asynch_Transmit_File factory. virtual void complete (u_long bytes_transferred, - int success, - const void *completion_key, - u_long error = 0); + int success, + const void *completion_key, + u_long error = 0); // ACE_Proactor will call this method when the write completes. protected: @@ -753,15 +753,15 @@ public: // and provided a consistent use of ACE_Message_Blocks. public: Header_And_Trailer (ACE_Message_Block *header = 0, - u_long header_bytes = 0, - ACE_Message_Block *trailer = 0, - u_long trailer_bytes = 0); + u_long header_bytes = 0, + ACE_Message_Block *trailer = 0, + u_long trailer_bytes = 0); // Constructor. void header_and_trailer (ACE_Message_Block *header = 0, - u_long header_bytes = 0, - ACE_Message_Block *trailer = 0, - u_long trailer_bytes = 0); + u_long header_bytes = 0, + ACE_Message_Block *trailer = 0, + u_long trailer_bytes = 0); // This method allows all the member to be set in one fell swoop. ACE_Message_Block *header (void) const; @@ -789,7 +789,7 @@ public: u_long header_bytes_; // Size of header data. - + ACE_Message_Block *trailer_; // Trailer data. @@ -843,7 +843,7 @@ public: // completes. virtual void handle_time_out (const ACE_Time_Value &tv, - const void *act = 0); + const void *act = 0); // Called when timer expires. <tv> was the requested time value and // <act> is the ACT passed when scheduling the timer @@ -899,7 +899,7 @@ public: // friend has been figured out. virtual void addresses (const ACE_INET_Addr &remote_address, - const ACE_INET_Addr &local_address); + const ACE_INET_Addr &local_address); // Called by ACE_Asynch_Acceptor to pass the addresses of the new // connections. diff --git a/ace/Proactor.cpp b/ace/Proactor.cpp index 591f346d951..9ce47bd03de 100644 --- a/ace/Proactor.cpp +++ b/ace/Proactor.cpp @@ -51,13 +51,13 @@ class ACE_Export ACE_Proactor_Timer_Handler : public ACE_Task <ACE_NULL_SYNCH> ~ACE_Proactor_Timer_Handler (void); // Destructor. - + protected: virtual int svc (void); // Run by a daemon thread to handle deferred processing. In other // words, this method will do the waiting on the earliest timer and // event. - + ACE_Auto_Event timer_event_; // Event to wait on. @@ -103,35 +103,35 @@ ACE_Proactor_Timer_Handler::svc (void) // If the timer queue is not empty if (!this->proactor_.timer_queue ()->is_empty ()) - { - // Get the earliest absolute time. - absolute_time - = this->proactor_.timer_queue ()->earliest_time () - - this->proactor_.timer_queue ()->gettimeofday (); + { + // Get the earliest absolute time. + absolute_time + = this->proactor_.timer_queue ()->earliest_time () + - this->proactor_.timer_queue ()->gettimeofday (); - // Time to wait. - time = absolute_time.msec (); + // Time to wait. + time = absolute_time.msec (); - // Make sure the time is positive. - if (time < 0) - time = 0; - } + // Make sure the time is positive. + if (time < 0) + time = 0; + } // Wait for event upto <time> milli seconds. int result = ::WaitForSingleObject (this->timer_event_.handle (), - time); + time); switch (result) - { - case ACE_WAIT_TIMEOUT: - // timeout: expire timers - this->proactor_.timer_queue ()->expire (); - break; - case ACE_WAIT_FAILED: - // error - ACE_ERROR_RETURN ((LM_ERROR, + { + case ACE_WAIT_TIMEOUT: + // timeout: expire timers + this->proactor_.timer_queue ()->expire (); + break; + case ACE_WAIT_FAILED: + // error + ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("WaitForSingleObject")), -1); - } + } } return 0; @@ -143,7 +143,7 @@ class ACE_Export ACE_AIO_Accept_Handler : public ACE_Handler { // = TITLE // Helper class for doing Asynch_Accept in POSIX4 systems, in - // the case of doing AIO_CONTROL_BLOCKS strategy. + // the case of doing AIO_CONTROL_BLOCKS strategy. // // = DESCRIPTION // Doing Asynch_Accept in POSIX4 implementation is tricky. In @@ -152,11 +152,11 @@ class ACE_Export ACE_AIO_Accept_Handler : public ACE_Handler // use a notifyn pipe here to implement Asynch_Accpet. This class // will issue a <Asynch_Read> on the pipe. <Asynch_Accept> will // send a result pointer containg all the information through - // this pipe. + // this pipe. public: ACE_AIO_Accept_Handler (ACE_Proactor* proactor); - // Constructor. - + // Constructor. + ~ACE_AIO_Accept_Handler (void); // Destructor. @@ -165,31 +165,31 @@ public: // <Asynch_Accept> calls this when an <accept> call has been issued // by the application. We issue an <Asynch_Read> here on the <pipe>, // so that <Asynch_Accept> can notify us by sending us Result - // pointer. + // pointer. #endif /* 0 */ int notify (ACE_Asynch_Accept::Result* result); - // Send this Result to Proactor through the notification pipe. + // Send this Result to Proactor through the notification pipe. virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); // Read from the pipe is complete. We get the <Result> from // Asynch_Handler. We have to do the notification here. - + private: ACE_Proactor* proactor_; - // The proactor in use. - + // The proactor in use. + ACE_Message_Block message_block_; // Message block to get ACE_Asynch_Accept::Result from - // ACE_Asych_Accept. + // ACE_Asych_Accept. ACE_Pipe pipe_; // Pipe for the communication between Proactor and the // Asynch_Accept. ACE_Asynch_Read_Stream read_stream_; - // To do asynch_read on the pipe. - + // To do asynch_read on the pipe. + ACE_AIO_Accept_Handler (void); // Default constructor. Shouldnt be called. }; @@ -200,7 +200,7 @@ ACE_AIO_Accept_Handler::ACE_AIO_Accept_Handler (ACE_Proactor* proactor) { // Open the pipe. this->pipe_.open (); - + // Open the read stream. if (this->read_stream_.open (*this, this->pipe_.read_handle (), @@ -209,7 +209,7 @@ ACE_AIO_Accept_Handler::ACE_AIO_Accept_Handler (ACE_Proactor* proactor) ACE_ERROR ((LM_ERROR, "%N:%l:%p\n", "Open on Read Stream failed")); - + // Issue an asynch_read on the read_stream. if (this->read_stream_.read (this->message_block_, sizeof (ACE_Asynch_Accept::Result)) == -1) @@ -229,17 +229,17 @@ ACE_AIO_Accept_Handler::accept (void) "%N:%l:%p\n", "Read from stream failed"), -1); -} -#endif /* 0 */ - +} +#endif /* 0 */ + ACE_AIO_Accept_Handler::~ACE_AIO_Accept_Handler (void) { } -int +int ACE_AIO_Accept_Handler::notify (ACE_Asynch_Accept::Result* result) { - // Send the result through the pipe. + // Send the result through the pipe. if (ACE_OS::write (this->pipe_.write_handle (), (void *) result, sizeof (*result)) < (signed) sizeof (*result)) @@ -247,20 +247,20 @@ ACE_AIO_Accept_Handler::notify (ACE_Asynch_Accept::Result* result) "(%P %t):%p\n", "Error:Writing on to pipe failed"), -1); - + return 0; } void ACE_AIO_Accept_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) { - // @@ + // @@ ACE_DEBUG ((LM_DEBUG, "ACE_AIO_Accept_Handler::handle_read_stream called\n")); - + // The message block actually contains the ACE_Asynch_Accept::Result. ACE_Asynch_Accept::Result* accept_result = (ACE_Asynch_Accept::Result*) result.message_block ().rd_ptr (); - + // Do the upcall. this->proactor_->application_specific_code (accept_result, 0, // Bytes transferred. @@ -277,17 +277,17 @@ ACE_Proactor_Handle_Timeout_Upcall::ACE_Proactor_Handle_Timeout_Upcall (void) int ACE_Proactor_Handle_Timeout_Upcall::timeout (TIMER_QUEUE &timer_queue, - ACE_Handler *handler, - const void *act, - const ACE_Time_Value &time) + ACE_Handler *handler, + const void *act, + const ACE_Time_Value &time) { ACE_UNUSED_ARG (timer_queue); if (this->proactor_ == 0) ACE_ERROR_RETURN ((LM_ERROR, - ASYS_TEXT ("(%t) No Proactor set in ACE_Proactor_Handle_Timeout_Upcall,") + ASYS_TEXT ("(%t) No Proactor set in ACE_Proactor_Handle_Timeout_Upcall,") ASYS_TEXT (" no completion port to post timeout to?!@\n")), - -1); + -1); // Create the Asynch_Timer. ACE_Proactor::Asynch_Timer *asynch_timer; @@ -296,7 +296,7 @@ ACE_Proactor_Handle_Timeout_Upcall::timeout (TIMER_QUEUE &timer_queue, act, time), -1); - + // Post a completion. if (this->proactor_->post_completion (asynch_timer) == -1) ACE_ERROR_RETURN ((LM_ERROR, @@ -308,7 +308,7 @@ ACE_Proactor_Handle_Timeout_Upcall::timeout (TIMER_QUEUE &timer_queue, int ACE_Proactor_Handle_Timeout_Upcall::cancellation (TIMER_QUEUE &timer_queue, - ACE_Handler *handler) + ACE_Handler *handler) { ACE_UNUSED_ARG (timer_queue); ACE_UNUSED_ARG (handler); @@ -340,9 +340,9 @@ ACE_Proactor_Handle_Timeout_Upcall::proactor (ACE_Proactor &proactor) } else ACE_ERROR_RETURN ((LM_ERROR, - ASYS_TEXT ("ACE_Proactor_Handle_Timeout_Upcall is only suppose") + ASYS_TEXT ("ACE_Proactor_Handle_Timeout_Upcall is only suppose") ASYS_TEXT (" to be used with ONE (and only one) Proactor\n")), - -1); + -1); } ACE_Proactor::ACE_Proactor (size_t number_of_threads, @@ -368,7 +368,7 @@ ACE_Proactor::ACE_Proactor (size_t number_of_threads, #if defined (ACE_HAS_AIO_CALLS) ACE_UNUSED_ARG (number_of_threads); ACE_UNUSED_ARG (tq); - + // The following things are necessary only for the // AIO_CONTROL_BLOCKS strategy. if (this->posix_completion_strategy_ == AIO_CONTROL_BLOCKS) @@ -384,8 +384,8 @@ ACE_Proactor::ACE_Proactor (size_t number_of_threads, ACE_NEW (aio_accept_handler_, ACE_AIO_Accept_Handler (this)); } - - + + // Mask the RT_compeltion signals if we are using the RT_SIGNALS // STRATEGY for completion querying. if (completion_strategy == RT_SIGNALS) @@ -401,13 +401,13 @@ ACE_Proactor::ACE_Proactor (size_t number_of_threads, ACE_ERROR ((LM_ERROR, "Error:%p\n", "Couldnt init the RT completion signal set")); - + // Mask them. if (sigprocmask (SIG_BLOCK, &RT_completion_signals_, 0) < 0) ACE_ERROR ((LM_ERROR, "Error:%p\n", "Couldnt mask the RT completion signals")); - + // Setting up the handler(!) for these signals. struct sigaction reaction; sigemptyset (&reaction.sa_mask); // Nothing else to mask. @@ -415,7 +415,7 @@ ACE_Proactor::ACE_Proactor (size_t number_of_threads, #if defined (SA_SIGACTION) // Lynx says, it is better to set this bit to be portable. reaction.sa_flags &= SA_SIGACTION; -#endif /* SA_SIGACTION */ +#endif /* SA_SIGACTION */ reaction.sa_sigaction = 0; // No handler. int sigaction_return = sigaction (ACE_SIG_AIO, &reaction, @@ -425,16 +425,16 @@ ACE_Proactor::ACE_Proactor (size_t number_of_threads, "Error:%p\n", "Proactor couldnt do sigaction for the RT SIGNAL")); } - + #else /* ACE_HAS_AIO_CALLS */ ACE_UNUSED_ARG (completion_strategy); // Create the completion port. this->completion_port_ = ::CreateIoCompletionPort (INVALID_HANDLE_VALUE, - this->completion_port_, - 0, - this->number_of_threads_); + this->completion_port_, + 0, + this->number_of_threads_); if (this->completion_port_ == 0) ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), @@ -464,16 +464,16 @@ ACE_Proactor::instance (size_t threads) { // Perform Double-Checked Locking Optimization. ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Static_Object_Lock::instance (), + *ACE_Static_Object_Lock::instance (), 0)); if (ACE_Proactor::proactor_ == 0) - { - ACE_NEW_RETURN (ACE_Proactor::proactor_, + { + ACE_NEW_RETURN (ACE_Proactor::proactor_, ACE_Proactor (threads), 0); - ACE_Proactor::delete_proactor_ = 1; - } + ACE_Proactor::delete_proactor_ = 1; + } } return ACE_Proactor::proactor_; } @@ -484,7 +484,7 @@ ACE_Proactor::instance (ACE_Proactor *r) ACE_TRACE ("ACE_Proactor::instance"); ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Static_Object_Lock::instance (), 0)); + *ACE_Static_Object_Lock::instance (), 0)); ACE_Proactor *t = ACE_Proactor::proactor_; @@ -501,7 +501,7 @@ ACE_Proactor::close_singleton (void) ACE_TRACE ("ACE_Proactor::close_singleton"); ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, - *ACE_Static_Object_Lock::instance ())); + *ACE_Static_Object_Lock::instance ())); if (ACE_Proactor::delete_proactor_) { @@ -521,10 +521,10 @@ ACE_Proactor::run_event_loop (void) int result = ACE_Proactor::instance ()->handle_events (); if (ACE_Service_Config::reconfig_occurred ()) - ACE_Service_Config::reconfigure (); + ACE_Service_Config::reconfigure (); else if (result == -1) - return -1; + return -1; } /* NOTREACHED */ @@ -544,11 +544,11 @@ ACE_Proactor::run_event_loop (ACE_Time_Value &tv) int result = ACE_Proactor::instance ()->handle_events (tv); if (ACE_Service_Config::reconfig_occurred ()) - ACE_Service_Config::reconfigure (); + ACE_Service_Config::reconfigure (); // An error has occurred. else if (result == -1) - return result; + return result; } /* NOTREACHED */ @@ -608,7 +608,7 @@ ACE_Proactor::close (void) int ACE_Proactor::register_handle (ACE_HANDLE handle, - const void *completion_key) + const void *completion_key) { #if defined (ACE_HAS_AIO_CALLS) ACE_UNUSED_ARG (handle); @@ -617,16 +617,16 @@ ACE_Proactor::register_handle (ACE_HANDLE handle, #else /* ACE_HAS_AIO_CALLS */ // No locking is needed here as no state changes. ACE_HANDLE cp = ::CreateIoCompletionPort (handle, - this->completion_port_, - (u_long) completion_key, - this->number_of_threads_); + this->completion_port_, + (u_long) completion_key, + this->number_of_threads_); if (cp == 0) { errno = ::GetLastError (); // If errno == ERROR_INVALID_PARAMETER, then this handle was // already registered. if (errno != ERROR_INVALID_PARAMETER) - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("CreateIoCompletionPort")), -1); } @@ -636,8 +636,8 @@ ACE_Proactor::register_handle (ACE_HANDLE handle, long ACE_Proactor::schedule_timer (ACE_Handler &handler, - const void *act, - const ACE_Time_Value &time) + const void *act, + const ACE_Time_Value &time) { return this->schedule_timer (handler, act, @@ -647,8 +647,8 @@ ACE_Proactor::schedule_timer (ACE_Handler &handler, long ACE_Proactor::schedule_repeating_timer (ACE_Handler &handler, - const void *act, - const ACE_Time_Value &interval) + const void *act, + const ACE_Time_Value &interval) { return this->schedule_timer (handler, act, @@ -658,9 +658,9 @@ ACE_Proactor::schedule_repeating_timer (ACE_Handler &handler, long ACE_Proactor::schedule_timer (ACE_Handler &handler, - const void *act, - const ACE_Time_Value &time, - const ACE_Time_Value &interval) + const void *act, + const ACE_Time_Value &time, + const ACE_Time_Value &interval) { // absolute time. ACE_Time_Value absolute_time = @@ -671,29 +671,29 @@ ACE_Proactor::schedule_timer (ACE_Handler &handler, // Schedule the timer long result = this->timer_queue_->schedule (&handler, - act, - absolute_time, - interval); + act, + absolute_time, + interval); if (result != -1) { // no failures: check to see if we are the earliest time if (this->timer_queue_->earliest_time () == absolute_time) - // wake up the timer thread - if (this->timer_handler_->timer_event_.signal () == -1) - { - // Cancel timer - this->timer_queue_->cancel (result); - result = -1; - } + // wake up the timer thread + if (this->timer_handler_->timer_event_.signal () == -1) + { + // Cancel timer + this->timer_queue_->cancel (result); + result = -1; + } } return result; } int ACE_Proactor::cancel_timer (long timer_id, - const void **arg, - int dont_call_handle_close) + const void **arg, + int dont_call_handle_close) { // No need to singal timer event here. Even if the cancel timer was // the earliest, we will have an extra wakeup. @@ -704,7 +704,7 @@ ACE_Proactor::cancel_timer (long timer_id, int ACE_Proactor::cancel_timer (ACE_Handler &handler, - int dont_call_handle_close) + int dont_call_handle_close) { // No need to signal timer event here. Even if the cancel timer was // the earliest, we will have an extra wakeup. @@ -725,7 +725,7 @@ ACE_Proactor::handle_signal (int, siginfo_t *, ucontext_t *) { result = this->handle_events (timeout); if (result != 0 || errno == ETIME) - break; + break; } // If our handle_events failed, we'll report a failure to the @@ -735,7 +735,7 @@ ACE_Proactor::handle_signal (int, siginfo_t *, ucontext_t *) int ACE_Proactor::handle_close (ACE_HANDLE handle, - ACE_Reactor_Mask close_mask) + ACE_Reactor_Mask close_mask) { ACE_UNUSED_ARG (close_mask); ACE_UNUSED_ARG (handle); @@ -776,7 +776,7 @@ int ACE_Proactor::notify_asynch_accept (ACE_Asynch_Accept::Result* result) { this->aio_accept_handler_->notify (result); - + return 0; } #endif /* ACE_HAS_AIO_CALLS */ @@ -801,22 +801,22 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) #if defined (ACE_HAS_AIO_CALLS) if (posix_completion_strategy () == ACE_Proactor::RT_SIGNALS) { - // Using RT Signals. - + // Using RT Signals. + // Wait for <milli_seconds> amount of time. // @@ Assigning <milli_seconds> to tv_sec. timespec timeout; timeout.tv_sec = milli_seconds; timeout.tv_nsec = 0; - + // To get back the signal info. siginfo_t sig_info; - + // Await the RT completion signal. int sig_return = sigtimedwait (&this->RT_completion_signals_, &sig_info, &timeout); - + // Error case. // If failure is coz of timeout, then return *0* but set // errno appropriately. This is what the WinNT proactor @@ -826,35 +826,35 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) "Error:%p\n", "Error waiting for RT completion signals"), 0); - + // RT completion signals returned. if (sig_return != ACE_SIG_AIO) ACE_ERROR_RETURN ((LM_ERROR, "Unexpected signal (%d) has been received while waiting for RT Completion Signals\n", sig_return), -1); - + // @@ Debugging. ACE_DEBUG ((LM_DEBUG, "Sig number found in the sig_info block : %d\n", sig_info.si_signo)); - + // Is the signo returned consistent? if (sig_info.si_signo != sig_return) ACE_ERROR_RETURN ((LM_ERROR, "Inconsistent signal number (%d) in the signal info block\n", sig_info.si_signo), -1); - + // @@ Debugging. ACE_DEBUG ((LM_DEBUG, "Signal code for this signal delivery : %d\n", sig_info.si_code)); - + // Retrive the result pointer. ACE_Asynch_Result *asynch_result = (ACE_Asynch_Result *) sig_info.si_value.sival_ptr; - + // Check the <signal code> and act according to that. if (sig_info.si_code == SI_ASYNCIO) { @@ -863,7 +863,7 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) // is valid. Otherwise <aio_error> will bomb. aiocb* aiocb_ptr = (aiocb *)asynch_result->aiocb_ptr (); - + // Analyze error and return values. Return values are // actually <errno>'s associated with the <aio_> call // corresponding to aiocb_ptr. @@ -877,11 +877,11 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) if (error_code != 0) // Error occurred in the <aio_>call. Return the errno // corresponding to that <aio_> call. - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, "Error:%p\n", "An AIO call has failed"), error_code); - + // No error occured in the AIO operation. int nbytes = aio_return (aiocb_ptr); if (nbytes == -1) @@ -889,10 +889,10 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) "Error:%p\n", "Invalid control block was send to <aio_return>"), -1); - + // <nbytes> have been successfully transmitted. size_t bytes_transferred = nbytes; - + // Call the application code. this->application_specific_code (asynch_result, bytes_transferred, @@ -904,14 +904,14 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) { // @@ Just debugging. ACE_DEBUG ((LM_DEBUG, "<sigqueue>'d signal received\n")); - + // Should be from the <Asynch_Accept> call. this->application_specific_code (asynch_result, 0, // No bytes transferred. 1, // Result : True. 0, // No completion key. - 0); // No error. - + 0); // No error. + } else // Unknown signal code. @@ -920,10 +920,10 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) sig_info.si_code), -1); } - else + else { // Not RT_SIGNALS approach. Using <aiocb> control blocks. - + // Is there any entries in the list. if (this->aiocb_list_cur_size_ == 0) // No aio is pending. @@ -933,7 +933,7 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) timespec timeout; timeout.tv_sec = milli_seconds; timeout.tv_nsec = 0; - + if (aio_suspend (this->aiocb_list_, this->aiocb_list_max_size_, &timeout) == -1) @@ -996,7 +996,7 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) // Call the application code. // @@ Pass <errno> instead of 0. Check out on LynxOS. It is set - // to 77 somewhere. + // to 77 somewhere. this->application_specific_code (asynch_result, bytes_transferred, 1, @@ -1011,21 +1011,21 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) // Get the next asynchronous operation that completes BOOL result = ::GetQueuedCompletionStatus (this->completion_port_, - &bytes_transferred, - &completion_key, - &overlapped, - milli_seconds); + &bytes_transferred, + &completion_key, + &overlapped, + milli_seconds); if (result == FALSE && overlapped == 0) { errno = ::GetLastError (); if (errno == WAIT_TIMEOUT) - { - errno = ETIME; - return 0; - } + { + errno = ETIME; + return 0; + } else - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("GetQueuedCompletionStatus")), -1); @@ -1037,13 +1037,13 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) // If errors happen, grab the error. if (result == FALSE) - errno = ::GetLastError (); + errno = ::GetLastError (); this->application_specific_code (asynch_result, - bytes_transferred, - result, - (void *) completion_key, - errno); + bytes_transferred, + result, + (void *) completion_key, + errno); } return 0; #endif /* ACE_HAS_AIO_CALLS */ @@ -1051,18 +1051,18 @@ ACE_Proactor::handle_events (unsigned long milli_seconds) void ACE_Proactor::application_specific_code (ACE_Asynch_Result *asynch_result, - u_long bytes_transferred, - int success, - const void *completion_key, - u_long error) + u_long bytes_transferred, + int success, + const void *completion_key, + u_long error) { ACE_SEH_TRY { // Call completion hook asynch_result->complete (bytes_transferred, - success, - (void *) completion_key, - error); + success, + (void *) completion_key, + error); } ACE_SEH_FINALLY { @@ -1088,10 +1088,10 @@ ACE_Proactor::post_completion (ACE_Asynch_Result *result) // Post a completion if (::PostQueuedCompletionStatus (this->completion_port_, // completion port - 0, // number of bytes tranferred - 0, // completion key - result // overlapped - ) == FALSE) + 0, // number of bytes tranferred + 0,// completion key + result // overlapped + ) == FALSE) { delete result; ACE_ERROR_RETURN ((LM_ERROR, "Failure in dealing with timers: PostQueuedCompletionStatus failed\n"), -1); @@ -1160,9 +1160,9 @@ ACE_Proactor::timer_queue (Timer_Queue *tq) } ACE_Proactor::Asynch_Timer::Asynch_Timer (ACE_Handler &handler, - const void *act, - const ACE_Time_Value &tv, - ACE_HANDLE event) + const void *act, + const ACE_Time_Value &tv, + ACE_HANDLE event) : ACE_Asynch_Result (handler, act, event), time_ (tv) { @@ -1170,9 +1170,9 @@ ACE_Proactor::Asynch_Timer::Asynch_Timer (ACE_Handler &handler, void ACE_Proactor::Asynch_Timer::complete (u_long bytes_transferred, - int success, - const void *completion_key, - u_long error) + int success, + const void *completion_key, + u_long error) { ACE_UNUSED_ARG (error); ACE_UNUSED_ARG (completion_key); |