diff options
Diffstat (limited to 'ace')
-rw-r--r-- | ace/ACE.cpp | 15 | ||||
-rw-r--r-- | ace/Log_Record.h | 2 | ||||
-rw-r--r-- | ace/Message_Block.cpp | 23 | ||||
-rw-r--r-- | ace/Message_Block.h | 10 | ||||
-rw-r--r-- | ace/Message_Block.i | 38 | ||||
-rw-r--r-- | ace/Naming_Context.cpp | 1 | ||||
-rw-r--r-- | ace/OS.h | 6 | ||||
-rw-r--r-- | ace/Reactor.cpp | 38 | ||||
-rw-r--r-- | ace/ReactorEx.cpp | 154 | ||||
-rw-r--r-- | ace/ReactorEx.h | 34 | ||||
-rw-r--r-- | ace/ReactorEx.i | 24 | ||||
-rw-r--r-- | ace/Service_Config.cpp | 3 | ||||
-rw-r--r-- | ace/Service_Manager.cpp | 8 | ||||
-rw-r--r-- | ace/Service_Object.h | 2 | ||||
-rw-r--r-- | ace/Service_Record.cpp | 3 | ||||
-rw-r--r-- | ace/Synch.h | 1 | ||||
-rw-r--r-- | ace/Synch.i | 8 | ||||
-rw-r--r-- | ace/Task.h | 2 | ||||
-rw-r--r-- | ace/Task.i | 6 | ||||
-rw-r--r-- | ace/Thread_Manager.cpp | 11 | ||||
-rw-r--r-- | ace/Thread_Manager.h | 10 | ||||
-rw-r--r-- | ace/XtReactor.cpp | 151 | ||||
-rw-r--r-- | ace/XtReactor.h | 10 |
23 files changed, 302 insertions, 258 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp index 464a26ab5cf..d2527bee293 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -150,7 +150,6 @@ ACE::ldfind (const char filename[], char tempcopy[MAXPATHLEN]; char searchpathname[MAXPATHLEN]; - char tempfilename[MAXPATHLEN]; char searchfilename[MAXPATHLEN]; // Create a copy of filename to work with. @@ -177,11 +176,11 @@ ACE::ldfind (const char filename[], if (separator_ptr == 0) { searchpathname[0] = '\0'; - ACE_OS::strcpy (tempfilename, tempcopy); + ACE_OS::strcpy (searchfilename, tempcopy); } else // This is an absolute path. { - ACE_OS::strcpy (tempfilename, separator_ptr + 1); + ACE_OS::strcpy (searchfilename, separator_ptr + 1); separator_ptr[1] = '\0'; ACE_OS::strcpy (searchpathname, tempcopy); } @@ -190,7 +189,7 @@ ACE::ldfind (const char filename[], // Check to see if this has an appropriate DLL suffix for the OS // platform. - char *s = ACE_OS::strrchr (tempfilename, '.'); + char *s = ACE_OS::strrchr (searchfilename, '.'); if (s != 0) { @@ -203,8 +202,8 @@ ACE::ldfind (const char filename[], s)); } - // Make sure we've got enough space in tempfilename. - if (ACE_OS::strlen (tempfilename) + + // Make sure we've got enough space in searchfilename. + if (ACE_OS::strlen (searchfilename) + ACE_OS::strlen (ACE_DLL_PREFIX) + got_suffix ? 0 : ACE_OS::strlen (ACE_DLL_SUFFIX) >= sizeof searchfilename) { @@ -231,7 +230,7 @@ ACE::ldfind (const char filename[], // prefix. ::sprintf (pathname, "%s%s%s", searchpathname, - tempfilename, + searchfilename, got_suffix ? "" : ACE_DLL_SUFFIX); if (ACE_OS::access (pathname, F_OK) == 0) return 0; @@ -240,7 +239,7 @@ ACE::ldfind (const char filename[], ::sprintf (pathname, "%s%s%s%s", searchpathname, ACE_DLL_PREFIX, - tempfilename, + searchfilename, got_suffix ? "" : ACE_DLL_SUFFIX); if (ACE_OS::access (pathname, F_OK) == 0) return 0; diff --git a/ace/Log_Record.h b/ace/Log_Record.h index 5a19ddc2d03..81311ccaa71 100644 --- a/ace/Log_Record.h +++ b/ace/Log_Record.h @@ -29,7 +29,7 @@ class ACE_Export ACE_Log_Record public: enum { - MAXLOGMSGLEN = BUFSIZ * 4, + MAXLOGMSGLEN = ACE_MAXLOGMSGLEN, // Maximum size of a logging message. ALIGN_WORDB = 8, diff --git a/ace/Message_Block.cpp b/ace/Message_Block.cpp index ba79ad21559..547d19e57f2 100644 --- a/ace/Message_Block.cpp +++ b/ace/Message_Block.cpp @@ -12,6 +12,22 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Message_Block) typedef ACE_Allocator_Adapter <ACE_Malloc <ACE_LOCAL_MEMORY_POOL, ACE_Null_Mutex> > ACE_NEW_MALLOC; +void +ACE_Message_Block::data_block (ACE_Data_Block *db) +{ + ACE_TRACE ("ACE_Data_Block::data_block"); + if (this->data_block_ != 0) + this->data_block_->release (); + + this->data_block_ = db; + // Should we increment the reference count of <db>? + + // Set the read and write pointers in the <Message_Block> to point + // to the buffer in the <ACE_Data_Block>. + this->rd_ptr (this->data_block ()->base ()); + this->wr_ptr (this->data_block ()->base ()); +} + int ACE_Message_Block::copy (const char *buf, size_t n) { @@ -147,6 +163,7 @@ ACE_Message_Block::size (size_t length) // ... and use them to initialize the new deltas. this->rd_ptr_ = this->data_block ()->base () + r_delta; this->wr_ptr_ = this->data_block ()->base () + w_delta; + return 0; } } @@ -362,10 +379,10 @@ ACE_Message_Block::init_i (size_t size, flags), -1); - // Set the read and write pointers in the new <Message_Block>. + // Set the read and write pointers in the new <Message_Block> to + // point to the buffer in the <ACE_Data_Block>. this->rd_ptr (this->data_block ()->base ()); this->wr_ptr (this->data_block ()->base ()); - return 0; } @@ -436,7 +453,7 @@ ACE_Message_Block::release (ACE_Message_Block *mb) { ACE_TRACE ("ACE_Message_Block::release"); - if (mb) + if (mb != 0) return mb->release (); else return 0; diff --git a/ace/Message_Block.h b/ace/Message_Block.h index ac1fbda97cc..1de4f7eb8d0 100644 --- a/ace/Message_Block.h +++ b/ace/Message_Block.h @@ -174,7 +174,7 @@ public: // = Deep copy and shallow copy methods. - ACE_Message_Block *clone (Message_Flags mask = 0) const; + virtual ACE_Message_Block *clone (Message_Flags mask = 0) const; // Return an exact "deep copy" of the message, i.e., create fresh // new copies of all the Data_Blocks and continuations. @@ -253,7 +253,9 @@ public: // = <ACE_Data_Block> methods. ACE_Data_Block *data_block (void) const; - // Get the data block; + // Get the data block. + void data_block (ACE_Data_Block *); + // Set the data block (releasing the original one). // = The continuation field chains together composite messages. ACE_Message_Block *cont (void) const; @@ -286,10 +288,6 @@ public: // Declare the dynamic allocation hooks. private: - // = Keep this private for now... - void data_block (ACE_Data_Block *); - // Set the data block; - // = Internal initialization methods. ACE_Message_Block (size_t size, ACE_Message_Type type, diff --git a/ace/Message_Block.i b/ace/Message_Block.i index 00ce6f447d0..92a9056f2d3 100644 --- a/ace/Message_Block.i +++ b/ace/Message_Block.i @@ -10,13 +10,6 @@ ACE_Message_Block::data_block (void) const return this->data_block_; } -ACE_INLINE void -ACE_Message_Block::data_block (ACE_Data_Block *db) -{ - ACE_TRACE ("ACE_Data_Block::data_block"); - this->data_block_ = db; -} - ACE_INLINE char * ACE_Data_Block::base (void) const { @@ -306,35 +299,36 @@ ACE_Message_Block::prev (void) const } ACE_INLINE ACE_Lock * -ACE_Message_Block::locking_strategy (void) +ACE_Data_Block::locking_strategy (void) { - ACE_TRACE ("ACE_Message_Block::locking_strategy"); - return this->data_block ()->locking_strategy (); + ACE_TRACE ("ACE_Data_Block::locking_strategy"); + return this->locking_strategy_; } ACE_INLINE ACE_Lock * -ACE_Message_Block::locking_strategy (ACE_Lock *nls) +ACE_Data_Block::locking_strategy (ACE_Lock *nls) { - ACE_TRACE ("ACE_Message_Block::locking_strategy"); - ACE_Lock *ols = this->data_block ()->locking_strategy (); - this->data_block ()->locking_strategy (nls); + ACE_TRACE ("ACE_Data_Block::locking_strategy"); + ACE_Lock *ols = this->locking_strategy_; + + this->locking_strategy_ = nls; return ols; } ACE_INLINE ACE_Lock * -ACE_Data_Block::locking_strategy (void) +ACE_Message_Block::locking_strategy (void) { - ACE_TRACE ("ACE_Data_Block::locking_strategy"); - return this->locking_strategy_; + ACE_TRACE ("ACE_Message_Block::locking_strategy"); + return this->data_block ()->locking_strategy (); } ACE_INLINE ACE_Lock * -ACE_Data_Block::locking_strategy (ACE_Lock *nls) +ACE_Message_Block::locking_strategy (ACE_Lock *nls) { - ACE_TRACE ("ACE_Data_Block::locking_strategy"); - ACE_Lock *ols = this->locking_strategy_; - - this->locking_strategy_ = nls; + ACE_TRACE ("ACE_Message_Block::locking_strategy"); + ACE_Lock *ols = this->data_block ()->locking_strategy (); + this->data_block ()->locking_strategy (nls); return ols; } + diff --git a/ace/Naming_Context.cpp b/ace/Naming_Context.cpp index 12779536a7d..b318dc3896a 100644 --- a/ace/Naming_Context.cpp +++ b/ace/Naming_Context.cpp @@ -24,6 +24,7 @@ ACE_STATIC_SVC_DEFINE (ACE_Naming_Context, "ACE_Naming_Context", ACE_SVC_OBJ_T, &ACE_SVC_NAME (ACE_Naming_Context), ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, 0) +// Add this to the list of statically configured services. ACE_STATIC_SVC_REQUIRE (ACE_Naming_Context) int @@ -1758,6 +1758,12 @@ union semun }; #endif /* !ACE_HAS_SEMUN */ +// Max size of an ACE Log Record data buffer. This can be reset in +// the config.h file if you'd like to increase or decrease the size. +#if !defined (ACE_MAXLOGMSGLEN) +#define ACE_MAXLOGMSGLEN 4 * 1024 +#endif /* ACE_MAXLOGMSGLEN */ + // Max size of an ACE Token. #define ACE_MAXTOKENNAMELEN 40 diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp index 90e0faf3a75..332df38f492 100644 --- a/ace/Reactor.cpp +++ b/ace/Reactor.cpp @@ -151,19 +151,26 @@ ACE_Reactor_Handler_Repository::find (ACE_HANDLE handle, ACE_TRACE ("ACE_Reactor_Handler_Repository::find"); ACE_Event_Handler *eh = 0; -#if defined (ACE_WIN32) - ssize_t i = 0; - for (; i < this->max_handlep1_; i++) - if (ACE_REACTOR_HANDLE (i) == handle) - eh = ACE_REACTOR_EVENT_HANDLER (this, i); + // Only bother to search for the <handle> if it's in range. + if (this->handle_in_range (handle)) + { +#if defined (ACE_WIN32) + ssize_t i = 0; + + for (; i < this->max_handlep1_; i++) + if (ACE_REACTOR_HANDLE (i) == handle) + { + eh = ACE_REACTOR_EVENT_HANDLER (this, i); + break; + } #else - ssize_t i = handle; + ssize_t i = handle; - if (this->handle_in_range (handle)) - eh = ACE_REACTOR_EVENT_HANDLER (this, handle); + eh = ACE_REACTOR_EVENT_HANDLER (this, handle); #endif /* ACE_WIN32 */ - + } + if (eh && index_p != 0) *index_p = i; else @@ -190,7 +197,7 @@ ACE_Reactor_Handler_Repository::bind (ACE_HANDLE handle, #if defined (ACE_WIN32) int assigned_slot = -1; - for (ssize_t i = 0; i < this->cur_size_; i++) + for (ssize_t i = 0; i < this->max_handlep1_; i++) { // Found it, so let's just reuse this location. if (ACE_REACTOR_HANDLE (i) == handle) @@ -210,12 +217,12 @@ ACE_Reactor_Handler_Repository::bind (ACE_HANDLE handle, ACE_REACTOR_HANDLE (assigned_slot) = handle; ACE_REACTOR_EVENT_HANDLER (this, assigned_slot) = event_handler; } - else if (this->cur_size_ < this->max_size_) + else if (this->max_handlep1_ < this->max_size_) { // Insert at the end of the active portion. - ACE_REACTOR_HANDLE (this->cur_size_) = handle; - ACE_REACTOR_EVENT_HANDLER (this, this->cur_size_) = event_handler; - this->cur_size_++; + ACE_REACTOR_HANDLE (this->max_handlep1_) = handle; + ACE_REACTOR_EVENT_HANDLER (this, this->max_handlep1_) = event_handler; + this->max_handlep1_++; } else { @@ -273,8 +280,6 @@ ACE_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, && this->reactor_.wait_set_.ex_mask_.is_set (handle) == 0) #if defined (ACE_WIN32) { - ACE_ASSERT (ACE_REACTOR_HANDLE (index) == handle); - ACE_REACTOR_HANDLE (index) = ACE_INVALID_HANDLE; ACE_REACTOR_EVENT_HANDLER (this, index) = 0; @@ -316,6 +321,7 @@ ACE_Reactor_Handler_Repository::unbind (ACE_HANDLE handle, } } #endif /* ACE_WIN32 */ + return 0; } diff --git a/ace/ReactorEx.cpp b/ace/ReactorEx.cpp index 65b6eab8314..0af89f2f745 100644 --- a/ace/ReactorEx.cpp +++ b/ace/ReactorEx.cpp @@ -31,12 +31,11 @@ ACE_ReactorEx_Handler_Repository::invalid_handle (ACE_HANDLE handle) } int -ACE_ReactorEx_Handler_Repository::handle_in_range (ACE_HANDLE handle) +ACE_ReactorEx_Handler_Repository::handle_in_range (size_t handle_index) { ACE_TRACE ("ACE_Reactor_Handler_Repository::handle_in_range"); - // It's too expensive to perform more exhaustive validity checks on - // Win32 due to the way that they implement SOCKET HANDLEs. - if (handle != ACE_INVALID_HANDLE) + if (handle_index >= 0 + && handle_index < this->max_size_) return 1; else { @@ -51,7 +50,7 @@ ACE_ReactorEx_Handler_Repository::open (size_t size) this->max_size_ = size; this->max_handlep1_ = 0; ACE_NEW_RETURN (this->handles_, ACE_HANDLE[size], -1); - ACE_NEW_RETURN (this->event_handlers_, ACE_Event_Handler[size], -1); + ACE_NEW_RETURN (this->event_handlers_, ACE_Event_Handler *[size], -1); for (size_t i = 0; i < size; i++) { @@ -62,31 +61,58 @@ ACE_ReactorEx_Handler_Repository::open (size_t size) return 0; } -int -ACE_ReactorEx_Handler_Repository::close (void) +int +ACE_ReactorEx_Handler_Repository::remove_handler (size_t index, + ACE_Reactor_Mask mask) { - this->unbind_all (); - delete [] this->handles_; - delete [] this->event_handlers_; + if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::DONT_CALL) == 0) + this->event_handlers_[index]->handle_close + (this->event_handlers_[index]->get_handle (), + mask); + + // If there was only one handle, reset the pointer to 0. + if (this->max_handlep1_ == 1) + { + // This is logically correct, but probably should never happen. + // This means that ACE_ReactorEx_Notify is being removed! We'll + // do it anyway and print out a warning. + this->max_handlep1_ = 0; + ACE_ERROR ((LM_ERROR, "ReactorEx: ReactorEx_Notify was" + "just removed!\n")); + } + // Otherwise, take the handle and handler from the back and + // overwrite the ones being removed. + else + { + this->handles_[index] = this->handles_[--this->max_handlep1_]; + this->event_handlers_[index] = this->event_handlers_[this->max_handlep1_]; + } + return 0; } -int -ACE_ReactorEx_Handler_Repository::max_handlep1 (void) +void +ACE_ReactorEx_Handler_Repository::unbind_all (void) { - return this->max_handlep1_; + // Remove all the handlers except the 0th one (i.e., the "notify + // hook"). + + while (this->max_handlep1_ > 1) + // Every time this method is called it removes the 2nd handler (in + // the 1st slot, starting from 0) and decrements <max_handlep1_> + // by 1. We don't want to remove the first handler, however, + // since it's used as the "notify hook." Therefore, we stop when + // <max_handlep1_> == 1. + this->remove_handler (1, ACE_Event_Handler::NULL_MASK); } -ACE_Event_Handler * -ACE_ReactorEx_Handler_Repository::find (size_t index) +int +ACE_ReactorEx_Handler_Repository::close (void) { - if (this->handle_in_range (index)) - return this->event_handlers_[i]; - else - { - errno = ENOENT; - return 0; - } + this->unbind_all (); + delete [] this->handles_; + delete [] this->event_handlers_; + return 0; } int @@ -101,51 +127,20 @@ ACE_ReactorEx_Handler_Repository::bind (ACE_HANDLE handle, // Make sure that the <handle> is valid and that there's room in the // table. if (this->invalid_handle (handle) == 0 - && this->handle_in_range (this->max_handlep1_)) + && this->max_handlep1_ < this->max_size_) { - this->handles_[this->max_handle_] = handle; - this->event_handlers_[this->max_handle_] = event_handler; + this->handles_[this->max_handlep1_] = handle; + this->event_handlers_[this->max_handlep1_] = event_handler; this->max_handlep1_++; + // Assign *this* <ReactorEx> to the <Event_Handler>. + event_handler->reactorEx (&this->reactorEx_); } else result = -1; - // Assign *this* <ReactorEx> to the <Event_Handler>. - event_handler->reactorEx (&this->reactor_); - return result; } -int -ACE_ReactorEx_Handler_Repository::remove_handler (int index, - ACE_Reactor_Mask mask) -{ - if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::DONT_CALL) == 0) - this->event_handlers_[index]->handle_close - (this->event_handlers_[index]->get_handle (), - ACE_Event_Handler::NULL_MASK); - - // If there was only one handle, reset the pointer to 0. - if (this->max_handlep1_ == 1) - { - // This is logically correct, but probably should never happen. - // This means that ACE_ReactorEx_Notify is being removed! We'll - // do it anyway and print out a warning. - this->max_handlep1_ = 0; - ACE_ERROR ((LM_ERROR, "ReactorEx: ReactorEx_Notify was" - "just removed!\n")); - } - // Otherwise, take the handle and handler from the back and - // overwrite the ones being removed. - else - { - this->handles_[index] = this->handles_[--this->max_handlep1_]; - this->event_handlers_[index] = this->event_handlers_[this->max_handlep1_]; - } - - return 0; -} - int ACE_ReactorEx_Handler_Repository::unbind (ACE_HANDLE handle, ACE_Reactor_Mask mask) @@ -165,6 +160,8 @@ ACE_ReactorEx_Handler_Repository::unbind (ACE_HANDLE handle, else i++; } + + return 0; } ACE_ReactorEx::ACE_ReactorEx (ACE_Sig_Handler *sh, @@ -315,7 +312,7 @@ ACE_ReactorEx::handle_events (ACE_Time_Value *max_wait_time, wait_all, alertable); - return this->dispatch (wait_status, dispatch_set); + return this->dispatch (wait_status, wait_all, wait_all_callback, dispatch_set); } int @@ -331,14 +328,12 @@ ACE_ReactorEx::wait_for_multiple_events (ACE_ReactorEx_Handle_Set &wait_set, // Translate into Win32 time value. int timeout = wait_time == 0 ? INFINITE : wait_time->msec (); - DWORD wait_status; // Wait for any of handles_ to be active, or until timeout expires. - // If wait_all is true, then wait for all handles_ to be active. - - // If <alertable> is enabled allow asynchronous completion of + // If wait_all is true, then wait for all handles_ to be active. If + // <alertable> is enabled allow asynchronous completion of // ReadFileEx and WriteFileEx operations. - return ::WaitForMultipleObjectsEx (this->active_handles_, - this->handles_, + return ::WaitForMultipleObjectsEx (this->handler_rep_.max_handlep1 (), + this->handler_rep_.handles (), wait_all, timeout, alertable); @@ -346,6 +341,7 @@ ACE_ReactorEx::wait_for_multiple_events (ACE_ReactorEx_Handle_Set &wait_set, int ACE_ReactorEx::dispatch (int wait_status, + int wait_all, ACE_ReactorEx_Handle_Set &dispatch_set) { // Expire all pending timers. @@ -374,7 +370,7 @@ ACE_ReactorEx::dispatch_callbacks (ACE_Event_Handler *wait_all_callback) { if (wait_all_callback != 0) { - siginfo_t handles (this->handles_); + siginfo_t handles (this->handler_rep.handles ()); if (wait_all_callback->handle_signal (0, &handles) == -1) { @@ -387,7 +383,7 @@ ACE_ReactorEx::dispatch_callbacks (ACE_Event_Handler *wait_all_callback) { int result = 0; - for (int i = 0; i < this->active_handles_; i++) + for (int i = 0; i < this->max_handlep1_; i++) if (this->dispatch_handler (i) == -1) result--; @@ -400,12 +396,13 @@ ACE_ReactorEx::dispatch_callbacks (ACE_Event_Handler *wait_all_callback) } // Dispatches any active handles from handles_[-index-] to -// handles_[active_handles_] using WaitForMultipleObjects to poll +// handles_[max_handlep1_] using WaitForMultipleObjects to poll // through our handle set looking for active handles. int ACE_ReactorEx::dispatch_handles (size_t index) { + for (;;) { // If dispatch_handler returns -1 then a handler was removed and @@ -414,14 +411,13 @@ ACE_ReactorEx::dispatch_handles (size_t index) index++; // We're done. - if (index >= this->active_handles_) + if (index >= this->handler_rep_.max_handlep1 ()) return 0; DWORD wait_status = - ::WaitForMultipleObjects (active_handles_ - index, - &handles_[index], + ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 () - index, + this->handler_rep_.handles () + index, FALSE, 0); // We're polling. - switch (wait_status) { case WAIT_FAILED: // Failure. @@ -432,8 +428,9 @@ ACE_ReactorEx::dispatch_handles (size_t index) return 0; default: // Dispatch. // Check if a handle successfully became signaled. - if (wait_status >= WAIT_OBJECT_0 && - wait_status < WAIT_OBJECT_0 + active_handles_) + if (wait_status >= WAIT_OBJECT_0 + && wait_status < WAIT_OBJECT_0 + + this->handler_rep_.max_handlep1 ()) index += wait_status - WAIT_OBJECT_0; else // Otherwise, a handle was abandoned. @@ -450,12 +447,13 @@ ACE_ReactorEx::dispatch_handler (int index) { // Assign the ``signaled'' HANDLE so that callers can get // it. - siginfo_t sig (handles_[index]); + ACE_HANDLE handle = *(this->handler_rep_.handles () + index); + siginfo_t sig (handle); // Dispatch the handler. - if (event_handlers_[index]->handle_signal (0, &sig) == -1) + if (this->handler_rep_.find (index)->handle_signal (0, &sig) == -1) { - this->remove_handler (event_handlers_[index]); + this->handler_rep_.unbind (handle); return -1; } else @@ -589,7 +587,7 @@ ACE_ReactorEx_Notify::notify (ACE_Event_Handler *eh, // current time of day. This is what <ACE_Message_Queue> // expects. if (timeout != 0) - timeout += ACE_OS::gettimeofday (); + *timeout += ACE_OS::gettimeofday (); if (this->message_queue_.enqueue_tail (mb, timeout) == -1) diff --git a/ace/ReactorEx.h b/ace/ReactorEx.h index cb12f4e9eac..300cc643e62 100644 --- a/ace/ReactorEx.h +++ b/ace/ReactorEx.h @@ -71,7 +71,7 @@ public: int unbind (ACE_HANDLE, ACE_Reactor_Mask mask); // Remove the binding of <ACE_HANDLE> in accordance with the <mask>. - int unbind_all (void); + void unbind_all (void); // Remove all bindings of <ACE_HANDLE, ACE_Event_Handler> tuples. // = Sanity checking. @@ -80,15 +80,26 @@ public: // within the range of legal handles (i.e., >= 0 && < max_size_). int invalid_handle (ACE_HANDLE handle); - // Check the <handle> to make sure it's a valid ACE_HANDLE that - // within the range of currently registered handles (i.e., >= 0 && < - // max_handlep1_). - int handle_in_range (ACE_HANDLE handle); + // Check the <index> to make sure it's within the range of currently + // registered HANDLEs (i.e., >= 0 && < max_handlep1_). + int handle_in_range (size_t handle); // = Accessors. - size_t max_handlep1 (void); + size_t max_handlep1 (void) const; // Maximum ACE_HANDLE value, plus 1. + ACE_HANDLE *handles (void) const; + // Pointer to the beginning of the current array of <ACE_HANDLE> + // *'s. + + int remove_handler (size_t index, + ACE_Reactor_Mask mask = 0); + // Removes the <ACE_Event_Handler> at <index> from the ReactorEx. + // Note that the ReactorEx will call the <get_handle> method of <eh> + // to extract the underlying I/O handle. If <mask> == + // ACE_Event_Handler::DONT_CALL then the <handle_close> method of + // the <eh> is not invoked. + void dump (void) const; // Dump the state of an object. @@ -208,13 +219,13 @@ public: // = Initialization and termination methods. - ACE_ReactorEx (ACE_Sig_Handler * = 0 + ACE_ReactorEx (ACE_Sig_Handler * = 0, ACE_Timer_Queue * = 0); // Initialize <ACE_ReactorEx> with the default size. ACE_ReactorEx (size_t size, int unused = 0, - ACE_Sig_Handler * = 0 + ACE_Sig_Handler * = 0, ACE_Timer_Queue * = 0); // Initialize <ACE_ReactorEx> with size <size>. @@ -224,7 +235,6 @@ public: ACE_Timer_Queue * = 0); // Initialize <ACE_ReactorEx> with size <size>. - virtual int close (void); // Close down the ReactorEx and release all of its resources. @@ -322,7 +332,7 @@ public: int notify (ACE_Event_Handler * = 0, ACE_Reactor_Mask = ACE_Event_Handler::EXCEPT_MASK, - ACE_Time_Value *); + ACE_Time_Value * = 0); // Wakeup <ACE_ReactorEx> if it is currently blocked in // <WaitForMultipleObjects>. The <ACE_Time_Value> indicates how // long to blocking trying to notify the <Reactor>. If <timeout> == @@ -342,7 +352,9 @@ protected: int alertable); // Wait for timer and I/O events to occur. - virtual dispatch (int number_of_active_handles, + virtual dispatch (int wait_status, + int wait_all, + ACE_Event_Handler *wait_all_callback, ACE_ReactorEx_Handle_Set &dispatch_set); // Dispatches the timers and I/O handlers. diff --git a/ace/ReactorEx.i b/ace/ReactorEx.i index a5cd53034a2..7985a10dad5 100644 --- a/ace/ReactorEx.i +++ b/ace/ReactorEx.i @@ -28,4 +28,28 @@ ACE_ReactorEx::handle_events (ACE_Time_Value &how_long, wait_all_callback, alertable); } +ACE_INLINE ACE_HANDLE * +ACE_ReactorEx::handles (void) const +{ + return this->handles_; +} + +ACE_INLINE size_t +ACE_ReactorEx_Handler_Repository::max_handlep1 (void) +{ + return this->max_handlep1_; +} + +ACE_INLINE ACE_Event_Handler * +ACE_ReactorEx_Handler_Repository::find (size_t index) +{ + if (this->handle_in_range (index)) + return this->event_handlers_[i]; + else + { + errno = ENOENT; + return 0; + } +} + #endif /* ACE_WIN32 */ diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index 4fa2a25cec1..442ae796a0d 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -109,6 +109,7 @@ ACE_STATIC_SVC_DEFINE (ACE_Service_Manager, "ACE_Service_Manager", ACE_SVC_OBJ_T, &ACE_SVC_NAME (ACE_Service_Manager), ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, 0) +// Add this to the list of statically configured services. ACE_STATIC_SVC_REQUIRE (ACE_Service_Manager) // List of statically configured services. @@ -118,8 +119,6 @@ ACE_Service_Config::static_svcs (void) { static ACE_STATIC_SVCS *instance_ = 0; - // Add other default services here if you'd like. - if (instance_ == 0) ACE_NEW_RETURN (instance_, ACE_STATIC_SVCS, 0); diff --git a/ace/Service_Manager.cpp b/ace/Service_Manager.cpp index 49564b0e30a..02f6e81bd91 100644 --- a/ace/Service_Manager.cpp +++ b/ace/Service_Manager.cpp @@ -1,7 +1,6 @@ // Service_Manager.cpp // $Id$ - #define ACE_BUILD_DLL #include "ace/Get_Opt.h" #include "ace/Service_Repository.h" @@ -118,8 +117,11 @@ int ACE_Service_Manager::fini (void) { ACE_TRACE ("ACE_Service_Manager::fini"); - return ACE_Service_Config::reactor ()->remove_handler - (this, ACE_Event_Handler::ACCEPT_MASK); + + if (this->get_handle () != ACE_INVALID_HANDLE) + return ACE_Service_Config::reactor ()->remove_handler + (this, ACE_Event_Handler::ACCEPT_MASK); + return 0; } ACE_HANDLE diff --git a/ace/Service_Object.h b/ace/Service_Object.h index 27949aa6737..7954ea3b8c6 100644 --- a/ace/Service_Object.h +++ b/ace/Service_Object.h @@ -51,7 +51,7 @@ public: ACE_Service_Type (const void *object, const char *s_name, u_int flags = 0); - ~ACE_Service_Type (void); + virtual ~ACE_Service_Type (void); // = Pure virtual interface (must be defined by the subclass). virtual int suspend (void) const = 0; diff --git a/ace/Service_Record.cpp b/ace/Service_Record.cpp index 10feb4105ae..af0812f9b80 100644 --- a/ace/Service_Record.cpp +++ b/ace/Service_Record.cpp @@ -346,7 +346,8 @@ int ACE_Service_Object_Type::fini (void) const { ACE_TRACE ("ACE_Service_Object_Type::fini"); - ACE_Service_Object *so = (ACE_Service_Object *) this->object (); + const void *obj = this->object (); + ACE_Service_Object *so = (ACE_Service_Object *) obj; so->fini (); return ACE_Service_Type::fini (); } diff --git a/ace/Synch.h b/ace/Synch.h index 3a88bee5a32..eb65c76b570 100644 --- a/ace/Synch.h +++ b/ace/Synch.h @@ -976,7 +976,6 @@ public: private: // These methods should *not* be public (they hold no locks...) - void set_nesting_level (int d); void set_thread_id (ACE_thread_t t); ACE_Thread_Mutex nesting_mutex_; diff --git a/ace/Synch.i b/ace/Synch.i index 12b4260c4ef..0a0dadd4831 100644 --- a/ace/Synch.i +++ b/ace/Synch.i @@ -494,13 +494,5 @@ ACE_Recursive_Thread_Mutex::set_thread_id (ACE_thread_t t) // ACE_TRACE ("ACE_Recursive_Thread_Mutex::set_thread_id"); this->owner_id_ = t; } - -ACE_INLINE void -ACE_Recursive_Thread_Mutex::set_nesting_level (int d) -{ -// ACE_TRACE ("ACE_Recursive_Thread_Mutex::set_nesting_level"); - this->nesting_level_ = d; -} - #endif /* ACE_HAS_THREADS */ diff --git a/ace/Task.h b/ace/Task.h index 9975f765220..2a06e92f986 100644 --- a/ace/Task.h +++ b/ace/Task.h @@ -148,7 +148,7 @@ public: // ACE_Task flags. int grp_id_; - // This maintains the group id of the + // This maintains the group id of the Task. #if defined (ACE_MT_SAFE) ACE_Thread_Mutex lock_; diff --git a/ace/Task.i b/ace/Task.i index 798606a68ae..fd9f992579b 100644 --- a/ace/Task.i +++ b/ace/Task.i @@ -98,11 +98,17 @@ ACE_Task_Base::grp_id (void) const } // Set the current group id. + ACE_INLINE void ACE_Task_Base::grp_id (int id) { ACE_TRACE ("ACE_Task_Base::grp_id"); ACE_MT (ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->lock_)); + + // Cache the group id in the task and then set it in the + // Thread_Manager, if there is one. this->grp_id_ = id; + if (this->thr_mgr ()) + this->thr_mgr ()->set_grp (this, id); } diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index ef1370dfb92..ae27fd049c6 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -1011,19 +1011,22 @@ ACE_Thread_Control::ACE_Thread_Control (ACE_Thread_Manager *t, ACE_Thread_Control::~ACE_Thread_Control (void) { ACE_TRACE ("ACE_Thread_Control::~ACE_Thread_Control"); -#if !defined (ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS) - this->exit (this->status_); +#if defined (ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS) + this->exit (this->status_, 0); +#else + this->exit (this->status_, 1); #endif /* ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS */ } // Exit from thread (but clean up first). void * -ACE_Thread_Control::exit (void *exit_status) +ACE_Thread_Control::exit (void *exit_status, int do_thr_exit) { ACE_TRACE ("ACE_Thread_Control::exit"); + if (this->tm_ != 0) - return this->tm_->exit (exit_status); + return this->tm_->exit (exit_status, do_thr_exit); else { ACE_Thread::exit (exit_status); diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h index 74595235013..bf459052e2d 100644 --- a/ace/Thread_Manager.h +++ b/ace/Thread_Manager.h @@ -373,12 +373,12 @@ public: // register the thread with the Thread_Manager. ~ACE_Thread_Control (void); - // Implicitly kill the thread on exit and remove it from its - // associated ThreadManager. + // Remove the thread from its associated <Thread_Manager> and exit + // the thread if <do_thr_exit> is enabled. - void *exit (void *status); - // Explicitly kill the thread on exit and remove it from its - // associated <Thread_Manager>. + void *exit (void *status, int do_thr_exit); + // Remove this thread from its associated <Thread_Manager> and exit + // the thread if <do_thr_exit> is enabled. int insert (ACE_Thread_Manager *tm); // Store the <Thread_Manager> and use it to register ourselves for diff --git a/ace/XtReactor.cpp b/ace/XtReactor.cpp index c5335d7091b..33d9273ab8e 100644 --- a/ace/XtReactor.cpp +++ b/ace/XtReactor.cpp @@ -19,9 +19,9 @@ ACE_ALLOC_HOOK_DEFINE (ACE_XtReactor) // Must be called with lock held ACE_XtReactor::ACE_XtReactor (XtAppContext context, - size_t size, - int restart, - ACE_Sig_Handler *h) + size_t size, + int restart, + ACE_Sig_Handler *h) : ACE_Reactor (size, restart, h), context_ (context), id_len_ (0), @@ -29,17 +29,18 @@ ACE_XtReactor::ACE_XtReactor (XtAppContext context, timeout_ (0) { // When the ACE_Reactor is constructed it creates the notify pipe - // and registers it with the attach() method. The XtReactor - // overloads this method BUT because the attach occurs when - // constructing the base class ACE_Reactor, the ACE_Reactor attach() - // is called not the XtReactor attach(). This means that the notify + // and registers it with the register_handler_i() method. The + // XtReactor overloads this method BUT because the + // register_handler_i occurs when constructing the base class + // ACE_Reactor, the ACE_Reactor register_handler_i() is called not + // the XtReactor register_handler_i(). This means that the notify // pipe is registered with the ACE_Reactor event handling code not // the XtReactor and so notfications don't work. To get around this // we simply close and re-opened the notification handler in the // constructor of the XtReactor. - this->notification_handler_.close (); - this->notification_handler_.open (this); + this->notify_handler_.close (); + this->notify_handler_.open (this); } ACE_XtReactor::~ACE_XtReactor (void) @@ -49,51 +50,34 @@ ACE_XtReactor::~ACE_XtReactor (void) // This is just the wait_for_multiple_events from ace/Reactor.cpp but // we use the Xt functions to wait for an event, not select () -// -// FIXME - someday re-write this to use poll as well. int -ACE_XtReactor::wait_for_multiple_events (ACE_Handle_Set &rmask, - ACE_Handle_Set &wmask, - ACE_Handle_Set &emask, - ACE_Time_Value *max_wait_time) +ACE_XtReactor::wait_for_multiple_events (ACE_Reactor_Handle_Set &handle_set, + ACE_Time_Value *max_wait_time) { ACE_TRACE ("ACE_Reactor::wait_for_multiple_events"); -#if defined (ACE_USE_POLL) - u_long width = 0; -#endif /* ACE_USE_POLL */ int nfound; do { max_wait_time = this->timer_queue_->calculate_timeout (max_wait_time); -#if defined (ACE_USE_POLL) - pollfd *phandles = this->handle_sets_to_poll_fds (width); - nfound = ACE_OS::poll (phandles, width, max_wait_time); -#else /* USE SELECT */ size_t width = this->handler_rep_.max_handlep1 (); - rmask = this->rd_handle_mask_; - wmask = this->wr_handle_mask_; - emask = this->ex_handle_mask_; -#if 0 - nfound = ACE_OS::select (int (width), rmask, wmask, emask, max_wait_time); -#else - nfound = XtWaitForMultipleEvents (width, rmask, wmask, emask, max_wait_time); -#endif -#endif /* ACE_USE_POLL */ - } while (nfound == -1 && this->handle_error () > 0); + handle_set.rd_mask_ = this->wait_set_.rd_mask_; + handle_set.wr_mask_ = this->wait_set_.wr_mask_; + handle_set.ex_mask_ = this->wait_set_.ex_mask_; + nfound = XtWaitForMultipleEvents (width, + handle_set, + max_wait_time); -#if defined (ACE_USE_POLL) - this->poll_fds_to_handle_sets (width, rmask, wmask, emask, nfound); -#endif /* ACE_USE_POLL */ + } while (nfound == -1 && this->handle_error () > 0); if (nfound > 0) { #if !defined (ACE_WIN32) - rmask.sync (this->handler_rep_.max_handlep1 ()); - wmask.sync (this->handler_rep_.max_handlep1 ()); - emask.sync (this->handler_rep_.max_handlep1 ()); + handle_set.rd_mask_.sync (this->handler_rep_.max_handlep1 ()); + handle_set.wr_mask_.sync (this->handler_rep_.max_handlep1 ()); + handle_set.ex_mask_.sync (this->handler_rep_.max_handlep1 ()); #endif /* ACE_REACTOR_ALTERANTIVE_IMPL */ } return nfound; // Timed out or input available @@ -110,8 +94,8 @@ ACE_XtReactor::TimerCallbackProc (XtPointer closure, XtIntervalId *id) ACE_Time_Value zero = ACE_Time_Value::zero; // my copy isn't const // Deal with any timer events - ACE_Handle_Set r, w, e; - self->dispatch (0, r, w, e); + ACE_Reactor_Handle_Set handle_set; + self->dispatch (0, handle_set); self->reset_timeout (); } @@ -129,49 +113,53 @@ void ACE_XtReactor::InputCallbackProc (XtPointer closure, ACE_Time_Value zero = ACE_Time_Value::zero; // my copy isn't const - ACE_Handle_Set r, w, e; - ACE_Handle_Set r2, w2, e2; + ACE_Reactor_Handle_Set wait_set; // Deal with one file event // - read which kind of event - if (self->rd_handle_mask_.is_set (*source)) - r.set_bit (*source); - if (self->wr_handle_mask_.is_set (*source)) - w.set_bit (*source); - if (self->ex_handle_mask_.is_set (*source)) - e.set_bit (*source); + if (self->wait_set_.rd_mask_.is_set (*source)) + wait_set.rd_mask_.set_bit (*source); + if (self->wait_set_.wr_mask_.is_set (*source)) + wait_set.rd_mask_.set_bit (*source); + if (self->wait_set_.ex_mask_.is_set (*source)) + wait_set.ex_mask_.set_bit (*source); + + int result = ACE_OS::select (*source + 1, + wait_set.rd_mask_, + wait_set.wr_mask_, + wait_set.ex_mask_, &zero); - int result = ACE_OS::select (*source+1, r, w, e, &zero); + ACE_Reactor_Handle_Set dispatch_set; // - Use only that one file event (removes events for other files) if (result > 0) { - if (r.is_set (*source)) - r2.set_bit (*source); - if (w.is_set (*source)) - w2.set_bit (*source); - if (e.is_set (*source)) - e2.set_bit (*source); - - self->dispatch (1, r2, w2, e2); + if (wait_set.rd_mask_.is_set (*source)) + dispatch_set.rd_mask_.set_bit (*source); + if (wait_set.wr_mask_.is_set (*source)) + dispatch_set.wr_mask_.set_bit (*source); + if (wait_set.ex_mask_.is_set (*source)) + dispatch_set.ex_mask_.set_bit (*source); + + self->dispatch (1, dispatch_set); } } int ACE_XtReactor::XtWaitForMultipleEvents (int width, - ACE_Handle_Set &rmask, - ACE_Handle_Set &wmask, - ACE_Handle_Set &emask, + ACE_Reactor_Handle_Set &wait_set, ACE_Time_Value *max_wait_time) { - // Check to make sure our fd's are all usable + // Check to make sure our handle's are all usable. - ACE_Handle_Set r (rmask), w (wmask), e (emask); - ACE_Time_Value zero = ACE_Time_Value::zero; // my copy isn't const - int result = ACE_OS::select (width, r, w, e, &zero); + ACE_Reactor_Handle_Set temp_set = wait_set; - if (result < 0) // Bad file arguments... - return result; + if (ACE_OS::select (width, + temp_set.rd_mask_, + temp_set.wr_mask_, + temp_set.ex_mask_, + (ACE_Time_Value *) &ACE_TimeValue::zero) == -1) + return -1; // Bad file arguments... // Instead of waiting using select, just use the Xt mechanism to wait // for a single event. @@ -180,8 +168,11 @@ int ACE_XtReactor::XtWaitForMultipleEvents (int width, XtAppProcessEvent (context_, XtIMAll); // Now actually read the result needed by the Reactor using select. - result = ACE_OS::select (int (width), rmask, wmask, emask, &zero); - return result; + return ACE_OS::select (width, + wait_set.rd_mask_, + wait_set.wr_mask_, + wait_set.ex_mask_, + (ACE_Time_Value *) &ACE_Time_Value::zero); } XtAppContext ACE_XtReactor::context (void) @@ -190,15 +181,15 @@ XtAppContext ACE_XtReactor::context (void) } int -ACE_XtReactor::attach (ACE_HANDLE handle, - ACE_Event_Handler *handler, - ACE_Reactor_Mask mask) +ACE_XtReactor::register_handler_i (ACE_HANDLE handle, + ACE_Event_Handler *handler, + ACE_Reactor_Mask mask) { - ACE_TRACE ("ACE_XtReactor::attach"); + ACE_TRACE ("ACE_XtReactor::register_handler_i"); ACE_DEBUG ((LM_DEBUG, "+++%d\n", handle)); - int result = ACE_Reactor::attach (handle, handler, mask); + int result = ACE_Reactor::register_handler_i (handle, handler, mask); if (result < 0) return -1; @@ -238,9 +229,9 @@ ACE_XtReactor::attach (ACE_HANDLE handle, ids_[handle].id = XtAppAddInput (context_, handle, - (XtPointer)condition, + (XtPointer) condition, InputCallbackProc, - (XtPointer)this); + (XtPointer) this); ids_[handle].good_id = 1; } return 0; @@ -248,13 +239,13 @@ ACE_XtReactor::attach (ACE_HANDLE handle, int -ACE_XtReactor::detach (ACE_HANDLE handle, - ACE_Reactor_Mask mask) +ACE_XtReactor::remove_handler_i (ACE_HANDLE handle, + ACE_Reactor_Mask mask) { - ACE_TRACE ("ACE_XtReactor::detach"); + ACE_TRACE ("ACE_XtReactor::remove_handler_i"); ACE_DEBUG ((LM_DEBUG, "---%d\n", handle)); - int result = ACE_Reactor::detach (handle, mask); + int result = ACE_Reactor::remove_handler_i (handle, mask); if (handle <= id_len_) { @@ -302,7 +293,7 @@ ACE_XtReactor::schedule_timer (ACE_Event_Handler *handler, const ACE_Time_Value &interval) { ACE_TRACE ("ACE_XtReactor::schedule_timer"); - ACE_GUARD_RETURN (ACE_REACTOR_MUTEX, ace_mon, this->token_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_REACTOR_MUTEX, ace_mon, this->token_, -1)); int result = ACE_Reactor::schedule_timer (handler, arg, delta_time, interval); diff --git a/ace/XtReactor.h b/ace/XtReactor.h index a942757c48f..8feb29cbb5f 100644 --- a/ace/XtReactor.h +++ b/ace/XtReactor.h @@ -66,16 +66,12 @@ public: protected: - virtual int wait_for_multiple_events (ACE_Handle_Set &, - ACE_Handle_Set &, - ACE_Handle_Set &, + virtual int wait_for_multiple_events (ACE_Reactor_Handle_Set &, ACE_Time_Value *); virtual int XtWaitForMultipleEvents (int, - ACE_Handle_Set &, - ACE_Handle_Set &, - ACE_Handle_Set &, - ACE_Time_Value *); + ACE_Reactor_Handle_Set &, + ACE_Time_Value *); ACE_XtReactor (const ACE_Reactor &); ACE_XtReactor &operator = (const ACE_Reactor &); |