diff options
-rw-r--r-- | ace/POSIX_Asynch_IO.cpp | 22 | ||||
-rw-r--r-- | ace/POSIX_Proactor.cpp | 31 | ||||
-rw-r--r-- | ace/POSIX_Proactor.h | 5 |
3 files changed, 33 insertions, 25 deletions
diff --git a/ace/POSIX_Asynch_IO.cpp b/ace/POSIX_Asynch_IO.cpp index b3375aa5187..573fd72ac3c 100644 --- a/ace/POSIX_Asynch_IO.cpp +++ b/ace/POSIX_Asynch_IO.cpp @@ -533,8 +533,12 @@ ACE_POSIX_SIG_Asynch_Read_Stream::shared_read (ACE_POSIX_Asynch_Read_Stream_Resu // We want queuing of RT signal to notify completion. result->aio_sigevent.sigev_notify = SIGEV_SIGNAL; result->aio_sigevent.sigev_signo = result->signal_number (); + + // Keep ACE_POSIX_Asynch_Result, the base class pointer in the + // signal value. + ACE_POSIX_Asynch_Result *base_result = result; result->aio_sigevent.sigev_value.sival_ptr = ACE_reinterpret_cast (void *, - (ACE_POSIX_Asynch_Result *) result); + base_result); // Fire off the aio read. if (aio_read (result) == -1) @@ -862,8 +866,12 @@ ACE_POSIX_SIG_Asynch_Write_Stream::shared_write (ACE_POSIX_Asynch_Write_Stream_R // We want queuing of RT signal to notify completion. result->aio_sigevent.sigev_notify = SIGEV_SIGNAL; result->aio_sigevent.sigev_signo = result->signal_number (); + + // Keep ACE_POSIX_Asynch_Result, the base class pointer in the + // signal value. + ACE_POSIX_Asynch_Result *base_result = result; result->aio_sigevent.sigev_value.sival_ptr = ACE_reinterpret_cast (void *, - (ACE_POSIX_Asynch_Result *) result); + base_result); // Fire off the aio write. if (aio_write (result) == -1) @@ -1716,12 +1724,12 @@ protected: ACE_POSIX_Proactor *posix_proactor_; // POSIX_Proactor. - + ACE_Unbounded_Queue<ACE_POSIX_Asynch_Accept_Result*> result_queue_; // Queue of Result pointers that correspond to all the <accept>'s // pending. - ACE_Thread_Mutex lock_; + ACE_SYNCH_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 @@ -1827,7 +1835,7 @@ ACE_POSIX_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); + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, 0); // Get the first item (result ptr) from the Queue. ACE_POSIX_Asynch_Accept_Result* result = 0; @@ -1873,7 +1881,7 @@ ACE_POSIX_AIOCB_Asynch_Accept_Handler::register_accept_call (ACE_POSIX_Asynch_Ac // 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_, -1); + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1); return register_accept_call_i (result); } @@ -1940,7 +1948,7 @@ ACE_POSIX_SIG_Asynch_Accept_Handler::register_accept_call (ACE_POSIX_Asynch_Acce // 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_, -1); + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1); // Do the work. if (this->register_accept_call_i (result) == -1) diff --git a/ace/POSIX_Proactor.cpp b/ace/POSIX_Proactor.cpp index 6c772f4d4db..bf84e9ebff2 100644 --- a/ace/POSIX_Proactor.cpp +++ b/ace/POSIX_Proactor.cpp @@ -464,7 +464,10 @@ ACE_POSIX_AIOCB_Proactor::ACE_POSIX_AIOCB_Proactor (void) { // Initialize the array. for (size_t ai = 0; ai < this->aiocb_list_max_size_; ai++) - aiocb_list_[ai] = 0; + { + aiocb_list_[ai] = 0; + result_list_ [ai] = 0; + } // Accept Handler for aio_accept. Remember! this issues a Asynch_Read // on the notify pipe for doing the Asynch_Accept. @@ -564,10 +567,6 @@ ACE_POSIX_AIOCB_Proactor::handle_events (unsigned long milli_seconds) int result_suspend = 0; if (milli_seconds == ACE_INFINITE) { - ACE_DEBUG ((LM_DEBUG, - "ACE_POSIX_AIOCB_Proactor::handle_events:" - "Indefinite blocking on aio_suspend\n")); - // Indefinite blocking. result_suspend = aio_suspend (this->aiocb_list_, this->aiocb_list_max_size_, @@ -575,10 +574,6 @@ ACE_POSIX_AIOCB_Proactor::handle_events (unsigned long milli_seconds) } else { - ACE_DEBUG ((LM_DEBUG, - "ACE_POSIX_AIOCB_Proactor::handle_events:" - "Finite blocking on aio_suspend\n")); - // Block on <aio_suspend> for <milli_seconds> timespec timeout; timeout.tv_sec = milli_seconds / 1000; @@ -588,10 +583,6 @@ ACE_POSIX_AIOCB_Proactor::handle_events (unsigned long milli_seconds) &timeout); } - ACE_DEBUG ((LM_DEBUG, - "ACE_POSIX_AIOCB_Proactor::handle_events: result_aiosuspend %d\n", - result_suspend)); - // Check for errors if (result_suspend == -1) { @@ -653,12 +644,16 @@ ACE_POSIX_AIOCB_Proactor::handle_events (unsigned long milli_seconds) ACE_ASSERT (ai != this->aiocb_list_max_size_); // Retrive the result pointer. - ACE_POSIX_Asynch_Result *asynch_result = - ACE_reinterpret_cast (ACE_POSIX_Asynch_Result *, - this->aiocb_list_[ai]); + ACE_POSIX_Asynch_Result *asynch_result = this->result_list_ [ai]; + + // ACE_reinterpret_cast (ACE_POSIX_Asynch_Result *, + // this->aiocb_list_[ai]); + // ACE_dynamic_cast (ACE_POSIX_Asynch_Result *, + // this->aiocb_list_[ai]); // Invalidate entry in the aiocb list. this->aiocb_list_[ai] = 0; + this->result_list_ [ai] = 0; this->aiocb_list_cur_size_--; // Call the application code. @@ -725,7 +720,9 @@ ACE_POSIX_AIOCB_Proactor::register_aio_with_proactor (ACE_POSIX_Asynch_Result *r -1); // Store the pointers. - this->aiocb_list_[ai] = result; + this->aiocb_list_[ai] = result; + this->result_list_ [ai] = result; + this->aiocb_list_cur_size_ ++; return 0; diff --git a/ace/POSIX_Proactor.h b/ace/POSIX_Proactor.h index 45305a241e1..5b84bfcaa44 100644 --- a/ace/POSIX_Proactor.h +++ b/ace/POSIX_Proactor.h @@ -261,13 +261,16 @@ protected: ACE_AIOCB_Notify_Pipe_Manager* aiocb_notify_pipe_manager_; // This class takes care of doing <accept> when we use // AIO_CONTROL_BLOCKS strategy. - + aiocb *aiocb_list_ [ACE_RTSIG_MAX]; // Use an array to keep track of all the aio's issued // currently. We'll limit the array size to Maximum RT signals that // can be queued in a process. This is the upper limit how many aio // operations can be pending at a time. + ACE_POSIX_Asynch_Result *result_list_ [ACE_RTSIG_MAX]; + // @@ I am keeing an extra copy of the <aiocb_ + size_t aiocb_list_max_size_; // To maintain the maximum size of the array (list). |