diff options
38 files changed, 550 insertions, 439 deletions
diff --git a/ChangeLog-97a b/ChangeLog-97a index e2acaf054a4..20b0c740146 100644 --- a/ChangeLog-97a +++ b/ChangeLog-97a @@ -1,3 +1,75 @@ +Tue Jan 7 13:03:25 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Thread_Manager.cpp (exit): Added a flag called "do_thr_exit" + to the ACE_Thread_Control::exit() method. This controls whether + we call ACE_OS::thr_exit() after removing the thread from the + Thread Manager's internal table. This is necessary to work + around pthread bugs on certain platforms (e.g., AIX and Linux). + + * ace/Synch.h: Removed the + ACE_Recursive_Thread_Mutex::set_nesting() method since this + isn't being used and is potentially dangerous. Thanks to Per + Andersson <Per.Andersson@hfera.ericsson.se> for suggesting this. + + * ace/XtReactor: Updated the XtReactor so that it uses the next + internal Reactor implementation. Thanks to Mark Rabotnikov + <mark@usp.elscintcorp.co.il> for reporting this. + + * ace/Task.i: Updated the grp_id(int) method to cache the group id + in the task and then set it in the Thread_Manager, if there is + one. Thanks to Hamutal Yanay <Hamutal_Yanay@mail.icomverse.com> + for suggesting this. + + * ace/Log_Record.h: Updated the ACE_Log_Record class to use the + new ACE_MAXLOGMSGLEN macro. + + * ace/OS.h: Added a new #define called ACE_MAXLOGMSGLEN. By + default this is 4k. However, you can reset it in the config.h + file if you'd like to increase or decrease the size. Thanks to + Anthony McConnell for suggesting this. + + * examples/Threads/tss[12].cpp: Tidied up the tss1.cpp and + tss2.cpp examples and improved the comments. Thanks to Luca for + suggesting this. + + * ace/Service_Object.cpp (fini): Added the "virtual" keyword to + the new destructor of ACE_Service_Type. Thanks to David for + reporting this. + + * ace/Message_Block.i: Rearranged the order of the ACE_Data_Block + and ACE_Message_Block locking_strategy() methods so that they'd + be defined as inline before being used. Thanks to David for + reporting this. + +Mon Jan 6 16:46:06 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Service_Manager.cpp (fini): Only try to remove the + ACE_Service_Manager from the Reactor if it's actually been + registered in the first place (i.e., if it's get_handle() method + does not return ACE_INVALID_HANDLE). + + * netsvcs/servers/svc.conf: Changed the name of the net services + .so file from libnet_svcs to netsvcs so that it will work + correctly with our new "cross-platform" svc.conf ACE::ldfind() + strategy. Thanks to Marius Kjeldahl <marius@funcom.com> for + reporting this. + + * ace/Reactor.cpp (find): Added a strategic break and a check for + handle_in_range(). Thanks to Tim for this help! + + * netsvcs/clients/Naming/Client/svc.conf: Removed the "lib" part + from the executable shared object file names in the svc.conf + file so that it will work with the new "cross-platform" svc.conf + ACE::ldfind() strategy. Thanks to Marius Kjeldahl + <marius@funcom.com> for reporting this. + + * ace/Service_Record.cpp (fini): Added an extra assignment to a + temporary const void *obj to avoid problems with MSVC++ and it's + cast mechanism. + + * ace/ReactorEx.h: Added a default parameter to + ACE_ReactorEx::notify(). Thanks to Tim for noticing this. + Sun Jan 5 10:48:23 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> * tests: Added a new test for ACE_Message_Block, which is called @@ -672,7 +672,9 @@ Wayne Vucenic <wvucenic@netgate.net> Harry Gunnarsson <hg@carmenta.se> James CE Johnson <jcej@lads.com> Samuel_Bercovici <Samuel_Bercovici_at_EFT__AD2@mail.icomverse.com> -Per.Andersson@hfera.ericsson.se (Per Andersson) +Per Andersson <Per.Andersson@hfera.ericsson.se> +Anthony McConnell <Tonym@datel.demon.co.uk> +Mark Rabotnikov <mark@usp.elscintcorp.co.il> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson and is now at ObjectSpace. Paul devised the recursive 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 &); diff --git a/examples/Reactor/Misc/notification.cpp b/examples/Reactor/Misc/notification.cpp index 3630a9651b7..28e457b084f 100644 --- a/examples/Reactor/Misc/notification.cpp +++ b/examples/Reactor/Misc/notification.cpp @@ -36,7 +36,7 @@ public: virtual int handle_input (ACE_HANDLE); // General notification messages to the Reactor. - virtual int notify (void); + virtual int notify (ACE_Time_Value *tv = 0); // Perform notifications. virtual int svc (void); @@ -49,6 +49,9 @@ private: size_t id_; // ID passed in by Thread_Handler constructor. + sig_atomic_t shutdown_; + // Shutting down. + // = Timing variables. // Delay factor for timer-driven I/O. static ACE_Time_Value delay_; @@ -66,6 +69,7 @@ ACE_Time_Value Thread_Handler::interval_; Thread_Handler::Thread_Handler (int delay, int interval, int n_threads) + : shutdown_ (0) { delay_.set (delay); interval_.set (interval); @@ -124,17 +128,17 @@ Thread_Handler::handle_input (ACE_HANDLE handle) } int -Thread_Handler::notify (void) +Thread_Handler::notify (ACE_Time_Value *timeout) { // Just do something to test the ACE_Reactor's multi-thread // capabilities... if (ACE_Service_Config::reactor ()->notify - (this, ACE_Event_Handler::EXCEPT_MASK) == -1) + (this, ACE_Event_Handler::EXCEPT_MASK, timeout) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); else if (ACE_Service_Config::reactor ()->notify - (this, ACE_Event_Handler::WRITE_MASK) == -1) + (this, ACE_Event_Handler::WRITE_MASK, timeout) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); return 0; @@ -146,7 +150,7 @@ Thread_Handler::notify (void) int Thread_Handler::svc (void) { - for (;;) + while (this->shutdown_ == 0) { if (Thread_Handler::delay_.sec () > 0) // Block for delay_.secs () / 2, then notify the Reactor. @@ -155,7 +159,7 @@ Thread_Handler::svc (void) // Only wait up to 10 milliseconds to notify the Reactor. ACE_Time_Value timeout (0, 10 * 1000); - if (this->notify (0, ACE_Event_Handler::EXCEPT_MASK, &timeout) == -1) + if (notify (&timeout) == -1) ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "notify()")); } return 0; @@ -175,6 +179,7 @@ Thread_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *) ACE_ERROR ((LM_ERROR, "(%t) ******************** shutting down %n on signal %S\n", signum)); + this->shutdown_ = 1; ACE_Service_Config::end_reactor_event_loop (); } return 0; diff --git a/examples/Reactor/Misc/test_reactors.cpp b/examples/Reactor/Misc/test_reactors.cpp index 8eb0c94e447..834d6f5bf98 100644 --- a/examples/Reactor/Misc/test_reactors.cpp +++ b/examples/Reactor/Misc/test_reactors.cpp @@ -116,7 +116,7 @@ Test_Task::handle_input (ACE_HANDLE) done_count--; ACE_DEBUG ((LM_DEBUG, "(%t) handle_input, handled_ = %d, done_count = %d\n", - this->handled_, (u_long) done_count)); + this->handled_, (int) done_count)); } ACE_OS::thr_yield (); diff --git a/examples/Reactor/Misc/test_signals_2.cpp b/examples/Reactor/Misc/test_signals_2.cpp index 86ab5057ea4..29d099c62ca 100644 --- a/examples/Reactor/Misc/test_signals_2.cpp +++ b/examples/Reactor/Misc/test_signals_2.cpp @@ -185,7 +185,7 @@ external_handler (int signum) #if !defined (HPUX) int -main (int argc, char *argv) +main (int argc, char *) { // If argc > 1 then allow multiple handlers per-signal, else just // allow 1 handler per-signal. diff --git a/examples/Reactor/Misc/test_time_value.cpp b/examples/Reactor/Misc/test_time_value.cpp index 4806b8e9c6c..6e4f6f494d2 100644 --- a/examples/Reactor/Misc/test_time_value.cpp +++ b/examples/Reactor/Misc/test_time_value.cpp @@ -17,7 +17,7 @@ operator<< (ostream &stream, const ACE_Time_Value &tv) } int -main (int argc, char *argv[]) +main (int, char *[]) { ACE_Time_Value tv1; ACE_Time_Value tv2 (2); diff --git a/examples/Reactor/Misc/test_timer_queue.cpp b/examples/Reactor/Misc/test_timer_queue.cpp index 641342b77cc..83c5745db03 100644 --- a/examples/Reactor/Misc/test_timer_queue.cpp +++ b/examples/Reactor/Misc/test_timer_queue.cpp @@ -23,7 +23,7 @@ private: }; int -main (int argc, char *argv[]) +main (int, char *[]) { ACE_Timer_Queue tq; Example_Handler eh; diff --git a/examples/Threads/future1.cpp b/examples/Threads/future1.cpp index a83e72eb97a..9f541f7f013 100644 --- a/examples/Threads/future1.cpp +++ b/examples/Threads/future1.cpp @@ -247,7 +247,7 @@ Scheduler::name_i (void) { char *the_name; - the_name = new char[ACE_OS::strlen (this->name_) + 1]; + ACE_NEW_RETURN (the_name, char[ACE_OS::strlen (this->name_) + 1], 0); ACE_OS::strcpy (the_name, this->name_); return the_name; @@ -302,15 +302,15 @@ main (int, char *[]) // Create active objects.. // @@ Should "open" be subsumed within the constructor of // Scheduler()? - andres = new Scheduler ("andres"); + ACE_NEW_RETURN (andres, Scheduler ("andres"), -1); andres->open (); - peter = new Scheduler ("peter"); + ACE_NEW_RETURN (peter, Scheduler ("peter"), -1); peter->open (); - helmut = new Scheduler ("helmut"); + ACE_NEW_RETURN (helmut, Scheduler ("helmut"), -1); helmut->open (); // Matias passes all asynchronous method calls on to Andres... - matias = new Scheduler ("matias", andres); + ACE_NEW_RETURN (matias, Scheduler ("matias", andres), -1); matias->open (); for (int i = 0; i < n_loops; i++) @@ -371,10 +371,10 @@ main (int, char *[]) ACE_DEBUG ((LM_DEBUG, "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", - (u_long) task_count, - (u_long) future_count, - (u_long) capsule_count, - (u_long) methodobject_count)); + (int) task_count, + (int) future_count, + (int) capsule_count, + (int) methodobject_count)); } // Close things down. @@ -387,10 +387,10 @@ main (int, char *[]) ACE_DEBUG ((LM_DEBUG, "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", - (u_long) task_count, - (u_long) future_count, - (u_long) capsule_count, - (u_long) methodobject_count)); + (int) task_count, + (int) future_count, + (int) capsule_count, + (int) methodobject_count)); ACE_DEBUG ((LM_DEBUG,"(%t) th' that's all folks!\n")); diff --git a/examples/Threads/future2.cpp b/examples/Threads/future2.cpp index de7e741108d..5e22721e97d 100644 --- a/examples/Threads/future2.cpp +++ b/examples/Threads/future2.cpp @@ -250,7 +250,7 @@ Scheduler::name_i (void) { char *the_name; - the_name = new char[ACE_OS::strlen (this->name_) + 1]; + ACE_NEW_RETURN (the_name, char[ACE_OS::strlen (this->name_) + 1], 0); ACE_OS::strcpy (the_name, this->name_); return the_name; @@ -315,7 +315,9 @@ determine_iterations (void) int n_iterations; ACE_DEBUG ((LM_DEBUG," (%t) determining the number of iterations...\n")); - Scheduler *worker_a = new Scheduler ("worker A"); + Scheduler *worker_a; + + ACE_NEW_RETURN (worker_a, Scheduler ("worker A"), -1); ACE_Time_Value tstart (ACE_OS::gettimeofday ()); ACE_Time_Value tend (ACE_OS::gettimeofday ()); @@ -335,7 +337,7 @@ determine_iterations (void) } ACE_DEBUG ((LM_DEBUG," (%t) n_iterations %d\n", - (u_long) n_iterations)); + (int) n_iterations)); worker_a->end (); // @@ Can we safely delete worker_a here? @@ -349,11 +351,14 @@ test_active_object (int n_iterations) // A simple example for the use of the active object pattern and // futures to return values from an active object. - Scheduler *worker_a = new Scheduler ("worker A"); - Scheduler *worker_b = new Scheduler ("worker B"); + Scheduler *worker_a; + Scheduler *worker_b; + Scheduler *worker_c; + ACE_NEW (worker_a, Scheduler ("worker A")); + ACE_NEW (worker_b, Scheduler ("worker B")); // Have worker_c delegate his work to worker_a. - Scheduler *worker_c = new Scheduler ("worker C", worker_a); + ACE_NEW (worker_c, Scheduler ("worker C", worker_a)); // loop 0: // test the Schedulers when they are not active. @@ -410,19 +415,19 @@ test_active_object (int n_iterations) } ACE_DEBUG ((LM_DEBUG, " (%t) scheduler_open_count %d before end ()\n", - (u_long) scheduler_open_count)); + (int) scheduler_open_count)); worker_a->end (); worker_b->end (); worker_c->end (); ACE_DEBUG ((LM_DEBUG, " (%t) scheduler_open_count %d immediately after end ()\n", - (u_long) scheduler_open_count)); + (int) scheduler_open_count)); ACE_OS::sleep (2); ACE_DEBUG ((LM_DEBUG, " (%t) scheduler_open_count %d after waiting\n", - (u_long) scheduler_open_count)); + (int) scheduler_open_count)); // @@ Can we safely delete worker_a, worker_b, and worker_c? } @@ -433,7 +438,8 @@ test_cancellation (int n_iterations) // Now test the cancelling a future. - Scheduler *worker_a = new Scheduler ("worker A"); + Scheduler *worker_a; + ACE_NEW (worker_a, Scheduler ("worker A")); worker_a->open (); ACE_Future<double> fresulta = worker_a->work (0.01, n_iterations); @@ -467,13 +473,15 @@ static void test_timeout (int n_iterations) { ACE_DEBUG ((LM_DEBUG," (%t) testing timeout on waiting for the result...\n")); - Scheduler *worker_a = new Scheduler ("worker A"); + Scheduler *worker_a; + ACE_NEW (worker_a, Scheduler ("worker A")); worker_a->open (); ACE_Future<double> fresulta = worker_a->work (0.01, 2 * n_iterations); // Should immediately return... and we should see an error... - ACE_Time_Value *delay = new ACE_Time_Value (1); + ACE_Time_Value *delay; + ACE_NEW (delay, ACE_Time_Value (1)); double resulta; fresulta.get (resulta, delay); diff --git a/examples/Threads/tss1.cpp b/examples/Threads/tss1.cpp index dd21023fa19..307ae9e1020 100644 --- a/examples/Threads/tss1.cpp +++ b/examples/Threads/tss1.cpp @@ -13,7 +13,8 @@ // wrapper transparently ensures that the objects of this class // will be placed in thread-specific storage. All calls on // ACE_TSS::operator->() are delegated to the appropriate method -// in the Errno class. +// in the Errno class. Note that each thread of control has its +// own unique TSS object. // // = AUTHOR // Detlef Becker @@ -94,25 +95,44 @@ public: Tester (void) {} ~Tester (void) {} - virtual int open (void *theArgs = 0); - virtual int close (u_long theArg = 0); + virtual int svc (void); + + virtual int open (void *args = 0); + // Activate the thread. + + virtual int close (u_long args = 0); }; template <ACE_SYNCH_1> int +Tester<ACE_SYNCH_2>::svc (void) +{ + ACE_DEBUG ((LM_DEBUG, "(%t) svc: setting error code to 1\n")); + TSS_Error->error (1); + + for (int i = 0; i < iterations; i++) + // Print out every tenth iteration. + if ((i % 10) == 1) + ACE_DEBUG ((LM_DEBUG, "(%t) error = %d\n", TSS_Error->error ())); + + return 0; +} + +template <ACE_SYNCH_1> int Tester<ACE_SYNCH_2>::open (void *) { + // Make this an Active Object. return this->activate (); } template <ACE_SYNCH_1> int Tester<ACE_SYNCH_2>::close (u_long) { - ACE_DEBUG ((LM_DEBUG, "close running\n!")); + ACE_DEBUG ((LM_DEBUG, "(%t) close running\n")); close_started = 1; - ACE_OS::sleep (2); - ACE_DEBUG ((LM_DEBUG, "close: trying to log error code 7!\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) close: setting error code to 7\n")); TSS_Error->error (7); - ACE_DEBUG ((LM_DEBUG, "close: logging succeeded!\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) close: error = %d\n", TSS_Error->error ())); + close_started = 0; return 0; } @@ -121,16 +141,25 @@ main (int, char *[]) { Tester<ACE_MT_SYNCH> tester; + ACE_DEBUG ((LM_DEBUG, "(%t) main: setting error code to 3\n")); + TSS_Error->error (3); + ACE_DEBUG ((LM_DEBUG, "(%t) main: error = %d\n", TSS_Error->error ())); + + // Spawn off a thread and make test an Active Object. tester.open (); + // Keep looping until <Tester::close> is called. while (!close_started) - continue; + ACE_DEBUG ((LM_DEBUG, "(%t) error = %d\n", TSS_Error->error ())); - ACE_DEBUG ((LM_DEBUG, "main: trying to log error code 7!\n")); + ACE_DEBUG ((LM_DEBUG, "(%t) main: setting error code to 4\n")); + TSS_Error->error (4); + ACE_DEBUG ((LM_DEBUG, "(%t) main: error = %d\n", TSS_Error->error ())); - TSS_Error->error (3); + // Keep looping until <Tester::close> finishes. + while (close_started != 0) + ACE_DEBUG ((LM_DEBUG, "(%t) error = %d\n", TSS_Error->error ())); - ACE_DEBUG ((LM_DEBUG, "main: logging succeeded!\n")); return 0; } diff --git a/examples/Threads/tss2.cpp b/examples/Threads/tss2.cpp index 24a8d958e91..706df1c54a3 100644 --- a/examples/Threads/tss2.cpp +++ b/examples/Threads/tss2.cpp @@ -9,11 +9,8 @@ // TSS_Test.cpp // // = DESCRIPTION -// This program tests thread specific storage of data. The ACE_TSS -// wrapper transparently ensures that the objects of this class -// will be placed in thread-specific storage. All calls on -// ACE_TSS::operator->() are delegated to the appropriate method -// in the Errno class. +// This program tests various features of ACE_Thread and thread +// specific storage of data. // // = AUTHOR // Prashant Jain and Doug Schmidt @@ -25,35 +22,33 @@ #if defined (ACE_HAS_THREADS) +const int MAX_TASKS = 4; +const int MAX_ITERATIONS = 10; + class TSS_Obj + // = TITLE + // This object is stored in thread-specific storage. { public: - TSS_Obj (void); ~TSS_Obj (void); private: - static int count_; - static ACE_Thread_Mutex lock_; + static ACE_Atomic_Op<ACE_Thread_Mutex, int> count_; }; -int TSS_Obj::count_ = 0; -ACE_Thread_Mutex TSS_Obj::lock_; +ACE_Atomic_Op<ACE_Thread_Mutex, int> TSS_Obj::count_ = 0; TSS_Obj::TSS_Obj (void) { - ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); - - count_++; - cout << "TO+ : " << count_ << endl; + TSS_Obj::count_++; + ACE_DEBUG ((LM_DEBUG, "(%t) TSS_Obj+: %d\n", (int) TSS_Obj::count_)); } TSS_Obj::~TSS_Obj (void) { - ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); - - count_--; - cout << "TO- : " << count_ << endl; + TSS_Obj::count_--; + ACE_DEBUG ((LM_DEBUG, "(%t) TSS_Obj-: %d\n", (int) TSS_Obj::count_)); } class Test_Task @@ -66,79 +61,60 @@ public: int open (void *arg); static void *svc (void *arg); - static int wait_count_; - static int max_count_; + + static ACE_Atomic_Op<ACE_Token, int> wait_count_; + static ACE_Atomic_Op<ACE_Token, int> max_count_; private: - static int count_; + static ACE_Atomic_Op<ACE_Token, int> count_; }; -int Test_Task::count_ = 0; -int Test_Task::wait_count_ = 0; -int Test_Task::max_count_ = 0; -int num_threads_ = 0; +ACE_Atomic_Op<ACE_Token, int> Test_Task::count_ (0); +ACE_Atomic_Op<ACE_Token, int> Test_Task::wait_count_ (0); +ACE_Atomic_Op<ACE_Token, int> Test_Task::max_count_ (0); +int num_tasks = 0; -ACE_Token token; +// ACE synchronization object. +static ACE_Token token; Test_Task::Test_Task (void) { - ACE_GUARD (ACE_Token, ace_mon, token); - - count_++; - cout << "Test_Task+ : " - << count_ << " (" - << ACE_OS::thr_self () - << ")" << endl; + Test_Task::count_++; + ACE_DEBUG ((LM_DEBUG, + "(%t) Test_Task+: %d\n", (int) Test_Task::count_)); } Test_Task::~Test_Task (void) { - ACE_GUARD (ACE_Token, ace_mon, token); - - count_--; - cout << "Test_Task- : " - << count_ << " (" - << ACE_OS::thr_self () - << ")" << endl; + Test_Task::count_--; - wait_count_--; + ACE_DEBUG ((LM_DEBUG, + "(%t) Test_Task-: %d\n", (int) Test_Task::count_)); + Test_Task::wait_count_--; } void * Test_Task::svc (void *arg) { + // When the thread exits this thread-specific object will be deleted + // automatically. ACE_TSS<TSS_Obj> tss (new TSS_Obj); - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); + Test_Task::wait_count_++; + Test_Task::max_count_++; - wait_count_++; - max_count_++; - cout << "svc: waiting (" << ACE_OS::thr_self () << ")" << endl; - } + ACE_DEBUG ((LM_DEBUG, "(%t) svc: waiting\n")); while (1) { - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); - - if (max_count_ >= num_threads_) - break; - else - { - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - } - } - - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); - - cout << "svc: waiting (" << ACE_OS::thr_self () << ") finished" << endl; - } + if (Test_Task::max_count_ >= num_tasks) + break; + else + ACE_Thread::yield (); } + ACE_DEBUG ((LM_DEBUG, "(%t) svc: waiting finished\n")); + delete (Test_Task *) arg; return 0; @@ -154,89 +130,59 @@ Test_Task::open (void *arg) } int -main (int argc, char **argv) +main (int argc, char *argv[]) { - if (argc != 2) - { - cout << "Missing parameters!" << endl; - return 1; - } - - int num_Tasks = atoi (argv[1]); - - num_threads_ = num_Tasks; + num_tasks = argc > 1 ? atoi (argv[1]) : MAX_TASKS; - Test_Task **task_arr = (Test_Task**) new char[sizeof (Test_Task*) * num_Tasks]; + Test_Task **task_arr; + + ACE_NEW_RETURN (task_arr, Test_Task *[num_tasks], -1); - while (1) + for (int i = 0; i < MAX_ITERATIONS; i++) { - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - cout << "ReseTest_Tasking Test_Task::max_count_ from: " - << Test_Task::max_count_ << endl; - - Test_Task::max_count_ = 0; - } - - for (int i = 0; i < num_Tasks; i++) + ACE_DEBUG ((LM_DEBUG, + "(%t) ********* iteration %d **********\n" + "Test_Task::max_count_ %d\n", + i, + (int) Test_Task::max_count_)); + Test_Task::max_count_ = 0; + + for (int j = 0; j < num_tasks; j++) { - task_arr[i] = new Test_Task; - task_arr[i]->open (task_arr[i]); + ACE_NEW_RETURN (task_arr[j], Test_Task, -1); + task_arr[j]->open (task_arr[j]); } - cout << "Waiting for first thread started..." << endl; + ACE_DEBUG ((LM_DEBUG, "(%t) waiting for first thread started\n")); for (;;) { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + ACE_Thread::yield (); if (Test_Task::max_count_ != 0 ) - { - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); - break; - } - ace_mon.release (); - ACE_Thread::yield (); - ace_mon.acquire (); + break; } - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - cout << "First thread started!" << endl - << "Waiting for all threads finished..." << endl; - } + ACE_DEBUG ((LM_DEBUG, "(%t) First thread started\n" + "Waiting for all threads finished\n")); for (;;) { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - - if (!(Test_Task::max_count_ == num_threads_ + if (!(Test_Task::max_count_ == num_tasks && Test_Task::wait_count_ == 0)) { - ace_mon.release (); ACE_Thread::yield (); - ace_mon.acquire (); continue; } - - cout << "Test_Task::max_count_ = " - << Test_Task::max_count_ - << " Test_Task::wait_count_ = " - << Test_Task::wait_count_ - << endl; + ACE_DEBUG ((LM_DEBUG, + "(%t) Test_Task::max_count_ = %d," + " Test_Task::wait_count_ = %d", + (int) Test_Task::max_count_, + (int) Test_Task::wait_count_)); break; } - { - ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); - cout << "All threads finished..." << endl; - } - - ACE_OS::sleep (2); + ACE_DEBUG ((LM_DEBUG, "(%t) all threads finished\n")); } return 0; @@ -250,3 +196,7 @@ main (int, char *[]) return 0; } #endif /* ACE_HAS_THREADS */ + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Atomic_Op<ACE_Token, int>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/netsvcs/clients/Naming/Client/svc.conf b/netsvcs/clients/Naming/Client/svc.conf index 45831c1aae6..151c996a238 100644 --- a/netsvcs/clients/Naming/Client/svc.conf +++ b/netsvcs/clients/Naming/Client/svc.conf @@ -1,6 +1,6 @@ # Note that $DB and $PORT are environment variables that are # automatically interpreted and substituted by ACE! static ACE_Naming_Context "main -s $DB -p $PORT -h tango" -dynamic Name_Server_test Service_Object * ./libClient_Test:_make_Client_Test () +dynamic Name_Server_test Service_Object * ./Client_Test:_make_Client_Test () # Note: Client_Test must come after ACE_Naming_Context since it relies # on the ACE_Naming_Context having been linked... diff --git a/netsvcs/servers/Makefile b/netsvcs/servers/Makefile index 31f354a4740..bbe432d11cd 100644 --- a/netsvcs/servers/Makefile +++ b/netsvcs/servers/Makefile @@ -16,7 +16,7 @@ LSRC = $(addsuffix .cpp,$(FILES)) LOBJ = $(LSRC:%.cpp=$(VDIR)%.o) SHOBJ = $(addsuffix .so,$(FILES)) -LDLIBS = -lnet_svcs +LDLIBS = -lnetsvcs VLDLIBS = $(LDLIBS:%=%$(VAR)) diff --git a/netsvcs/servers/main.cpp b/netsvcs/servers/main.cpp index 67c5c9f3b57..5cd9150f744 100644 --- a/netsvcs/servers/main.cpp +++ b/netsvcs/servers/main.cpp @@ -38,7 +38,8 @@ main (int argc, char *argv[]) // Register ourselves to receive SIGINT and SIGQUIT so we can shut // down gracefully via signals. - ACE_Service_Config::reactor ()->register_handler (sig_set, &sa); + if (ACE_Service_Config::reactor ()->register_handler (sig_set, &sa) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", -1)); // Try to link in the svc.conf entries dynamically. if (daemon.open (argc, argv) == -1) diff --git a/netsvcs/servers/svc.conf b/netsvcs/servers/svc.conf index 7d9e904e229..1da53470fa8 100644 --- a/netsvcs/servers/svc.conf +++ b/netsvcs/servers/svc.conf @@ -1,5 +1,5 @@ # These are the services that can be linked into ACE. -# Note that you can replace the hardcoded "../lib/net_svcs" with +# Note that you can replace the hardcoded "../lib/netsvcs" with # a relative path if you set your LD search path correctly -- ACE will # locate this for you automatically by reading your LD search path. # Moreover, ACE will automatically insert the correct suffix (e.g., @@ -7,11 +7,11 @@ # "-p 20xxx" with "-p $PORTxxx" if you set your environment variables # correctly. -dynamic Logger Service_Object * ../lib/net_svcs:_make_ACE_Logging_Strategy() "-s foobar -f STDERR|OSTREAM" -dynamic Time_Service Service_Object * ../lib/net_svcs:_make_ACE_TS_Server_Acceptor() "-p 10222" -dynamic Name_Server Service_Object * ../lib/net_svcs:_make_ACE_Name_Acceptor() "-p 10012" -dynamic Token_Service Service_Object * ../lib/net_svcs:_make_ACE_Token_Acceptor() "-p 10202" -dynamic Server_Logging_Service Service_Object * ../lib/net_svcs:_make_ACE_Server_Logging_Acceptor() active "-p 10009" -dynamic Thr_Server_Logging_Service Service_Object * ../lib/net_svcs:_make_ACE_Thr_Server_Logging_Acceptor() active "-p 10020" -dynamic Client_Logging_Service Service_Object * ../lib/net_svcs:_make_ACE_Client_Logging_Connector() active "-p 10009" +dynamic Logger Service_Object * ../lib/netsvcs:_make_ACE_Logging_Strategy() "-s foobar -f STDERR|OSTREAM" +dynamic Time_Service Service_Object * ../lib/netsvcs:_make_ACE_TS_Server_Acceptor() "-p 10222" +dynamic Name_Server Service_Object * ../lib/netsvcs:_make_ACE_Name_Acceptor() "-p 10012" +dynamic Token_Service Service_Object * ../lib/netsvcs:_make_ACE_Token_Acceptor() "-p 10202" +dynamic Server_Logging_Service Service_Object * ../lib/netsvcs:_make_ACE_Server_Logging_Acceptor() active "-p 10009" +dynamic Thr_Server_Logging_Service Service_Object * ../lib/netsvcs:_make_ACE_Thr_Server_Logging_Acceptor() active "-p 10020" +dynamic Client_Logging_Service Service_Object * ../lib/netsvcs:_make_ACE_Client_Logging_Connector() active "-p 10009" |