diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-01 08:40:32 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-01 08:40:32 +0000 |
commit | 76171efcb983b4f2ff55a4013fed794f7a9bb471 (patch) | |
tree | a817b83efdc199c8f292b9a5bfd4047ef900f6b0 | |
parent | bad6c3a7b49b64377c60931084a6ef68ae64877b (diff) | |
download | ATCD-76171efcb983b4f2ff55a4013fed794f7a9bb471.tar.gz |
foo
45 files changed, 532 insertions, 578 deletions
diff --git a/ChangeLog-96b b/ChangeLog-96b index 62fac75fc1e..8f5eb61d6fd 100644 --- a/ChangeLog-96b +++ b/ChangeLog-96b @@ -1,5 +1,35 @@ +Fri Nov 1 00:25:01 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Service_Repository.cpp (remove): Fixed a bug with + Service_Record::remove() that was failing if there were only two + records and we are removing the first one. Thanks to Alex + Villazon <villazon@cui.unige.ch> for reporting this. + + * ace: Recompiled everything on Solaris with G++ and CC and it + seems to work fine. + + * ace/Module: Replaced the use of char * with const char * for + assigning the Module a name. + + * ace: Split the Task.{cpp,i.h} file into Task_T.{cpp,i,h} in + order to factor out the new non-template ACE_Task_Base and + ACE_Task_Exit classes. This is required for GCC-based compilers + that include the *.cpp files... + Thu Oct 31 00:36:38 1996 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + * ace/Malloc_T.h: Made the destructor of ACE_Allocator_Adapter + virtual. + + * ace/Thread: Reorganized the ACE_Thread so that the + ACE_HAS_THREADS #ifdef is no longer required... + + * ace/Strategies.h: Changed all the destructors to be virtual so + that G++ will stop complaining... + + * ace/Thread_Manager: Reorganized the ACE_Thread_Manager so that + the ACE_HAS_THREADS #ifdef is no longer required... + * ace/config-win32-msvc4.0.h: Added Dieter Quehl's great hack to get ACE to compile correctly on Win32 with MFC! @@ -478,7 +478,6 @@ Irfan Pyarali <ip1@cs.wustl.edu> Prashant Jain <pjain@cs.wustl.edu> Brad Needham <bneedham@ix.netcom.com> Leslee Xu <lxu@ics.uci.edu> -Alex V. Maclinovsky <alexm@teltrunk1.tait.co.nz> Detlef Becker <beckerd@erlh.siemens.de> Bruce Worden <bruce@betsy.gps.caltech.edu> Chris Tarr <ctarr@objectspace.co> @@ -507,7 +506,7 @@ David Trumble <trumble@cvg.enet.dec.com> John Morey <jmorey@crl.com> George Reynolds <george@dvcorp.com> Hans Rohnert <Hans.Rohnert@zfe.siemens.de> -Alex V Maclinvosky <alexey@ace.elektra.ru> +Alex V. Maclinovsky <alexm@teltrunk1.tait.co.nz> Todd Blanchard <tblancha@evolving.com> Rob Clairmont <rclairmo@bnr.ca> Christian Millour <chris@etca.fr> @@ -605,6 +604,7 @@ Tilo Christ <christ@swl.fh-heilbronn.de> Ari Erev <Ari_Erev@comverse.com> Hamutal Yanay <Hamutal_Yanay@hub.comverse.com> Vital Aza <va3@cs.wustl.edu> +Alex Villazon <villazon@cui.unige.ch> 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/Acceptor.cpp b/ace/Acceptor.cpp index f67c77115fe..a54aa8d69fa 100644 --- a/ace/Acceptor.cpp +++ b/ace/Acceptor.cpp @@ -456,12 +456,12 @@ ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor (const char service_name[], const char service_description[]) : creation_strategy_ (0), - accept_strategy_ (0), - concurrency_strategy_ (0), - scheduling_strategy_ (0), delete_creation_strategy_ (0), + accept_strategy_ (0), delete_accept_strategy_ (0), + concurrency_strategy_ (0), delete_concurrency_strategy_ (0), + scheduling_strategy_ (0), delete_scheduling_strategy_ (0), service_name_ (0), service_description_ (0) @@ -674,8 +674,8 @@ ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor (void) - : delete_concurrency_strategy_ (0), - reactor_ (0) + : reactor_ (0), + delete_concurrency_strategy_ (0) { ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor"); } @@ -716,8 +716,8 @@ ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close (ACE_HANDLE // Note that if we aren't actually registered with the // ACE_Reactor then it's ok for this call to fail... - this->reactor_ && this->reactor_->remove_handler (this, - ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL); + this->reactor_ && this->reactor_->remove_handler + (this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL); this->reactor_ = 0; diff --git a/ace/Malloc.h b/ace/Malloc.h index fe67fca2150..d5c73e99bba 100644 --- a/ace/Malloc.h +++ b/ace/Malloc.h @@ -210,7 +210,7 @@ struct ACE_Export ACE_Malloc_Stats #include "ace/Malloc.i" #endif /* __ACE_INLINE__ */ -// Include the ACE_Malloc templates and ACE_Memory_Pool stuff at this point. +// Include the ACE_Malloc templates and ACE_Memory_Pool classes at this point. #include "ace/Malloc_T.h" #include "ace/Memory_Pool.h" diff --git a/ace/Malloc_T.h b/ace/Malloc_T.h index 56998bf80f7..b5463c0671d 100644 --- a/ace/Malloc_T.h +++ b/ace/Malloc_T.h @@ -53,8 +53,8 @@ public: } // Constructor (this has to be inline to avoid bugs with some C++ compilers. - ~ACE_Allocator_Adapter (void); - // Destructor + virtual ~ACE_Allocator_Adapter (void); + // Destructor. // = Memory Management diff --git a/ace/Module.cpp b/ace/Module.cpp index 46f6ae1ea76..9471de5cc8e 100644 --- a/ace/Module.cpp +++ b/ace/Module.cpp @@ -50,7 +50,7 @@ ACE_Module<ACE_SYNCH_2>::link (ACE_Module<ACE_SYNCH_2> *m) } template <ACE_SYNCH_1> int -ACE_Module<ACE_SYNCH_2>::open (char *mod_name, +ACE_Module<ACE_SYNCH_2>::open (const char *mod_name, ACE_Task<ACE_SYNCH_2> *writer_q, ACE_Task<ACE_SYNCH_2> *reader_q, void *arg) @@ -114,7 +114,7 @@ ACE_Module<ACE_SYNCH_2>::~ACE_Module (void) } template <ACE_SYNCH_1> ACE_INLINE -ACE_Module<ACE_SYNCH_2>::ACE_Module (char *mod_name, +ACE_Module<ACE_SYNCH_2>::ACE_Module (const char *mod_name, ACE_Task<ACE_SYNCH_2> *writer_q, ACE_Task<ACE_SYNCH_2> *reader_q, void *flags) diff --git a/ace/Module.h b/ace/Module.h index b9983852a37..3f505121166 100644 --- a/ace/Module.h +++ b/ace/Module.h @@ -47,15 +47,17 @@ public: ACE_Module (void); // Create an empty Module. - ACE_Module (char *module_name, + ACE_Module (const char *module_name, ACE_Task<ACE_SYNCH_2> *writer = 0, - ACE_Task<ACE_SYNCH_2> *reader = 0, void *a = 0); + ACE_Task<ACE_SYNCH_2> *reader = 0, + void *a = 0); // Create an initialized module with <module_name> as its identity // and <reader> and <writer> as its tasks. - int open (char *module_name, - ACE_Task<ACE_SYNCH_2> *writer = 0, - ACE_Task<ACE_SYNCH_2> *reader = 0, void *a = 0); + int open (const char *module_name, + ACE_Task<ACE_SYNCH_2> *writer = 0, + ACE_Task<ACE_SYNCH_2> *reader = 0, + void *a = 0); // Create an initialized module with <module_name> as its identity // and <reader> and <writer> as its tasks. @@ -80,7 +82,7 @@ public: // = Identify the module const char *name (void) const; // Get the module name. - void name (char *); + void name (const char *); // Set the module name. // = Argument to the Tasks. diff --git a/ace/Module.i b/ace/Module.i index affc11f568c..8a2feaa7cde 100644 --- a/ace/Module.i +++ b/ace/Module.i @@ -25,7 +25,7 @@ ACE_Module<ACE_SYNCH_2>::name (void) const } template <ACE_SYNCH_1> ACE_INLINE void -ACE_Module<ACE_SYNCH_2>::name (char *n) +ACE_Module<ACE_SYNCH_2>::name (const char *n) { ACE_TRACE ("ACE_Module<ACE_SYNCH_2>::name"); ACE_OS::strncpy (this->name_, n, MAXNAMLEN); @@ -503,12 +503,7 @@ typedef struct } ACE_sema_t; #endif /* ACE_HAS_POSIX_SEM */ -#if defined (ACE_HAS_THREADS) -#if defined (ACE_HAS_STHREADS) -#include <synch.h> -#include <thread.h> -#endif /* ACE_HAS_STHREADS */ - +#if !defined (PTHREAD_CANCEL_ENABLE) struct cancel_state { int cancelstate; @@ -518,6 +513,13 @@ struct cancel_state int canceltype; // e.g., PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS. }; +#endif /* PTHREAD_CANCEL_ENABLE */ + +#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_STHREADS) +#include <synch.h> +#include <thread.h> +#endif /* ACE_HAS_STHREADS */ #if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) // Definitions for mapping POSIX pthreads onto Solaris threads. diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp index 672caccc8f4..7dd6e141083 100644 --- a/ace/Reactor.cpp +++ b/ace/Reactor.cpp @@ -1552,7 +1552,10 @@ ACE_Reactor::handle_events (ACE_Time_Value *max_wait_time) // as a result of signals since they may be // time critical... - if (this->any_ready ()) + if (nfound == -1) + nfound = 0; + + if (this->any_ready ()) { nfound = this->fill_in_ready (rmask, wmask, emask); continue; diff --git a/ace/SString.cpp b/ace/SString.cpp index 77068413a12..ed9ca1da0a5 100644 --- a/ace/SString.cpp +++ b/ace/SString.cpp @@ -435,7 +435,8 @@ ACE_WString::ACE_WString (const char *s, // Constructor that actually copies memory. -ACE_WString::ACE_WString (const ACE_USHORT16 *s, ACE_Allocator *allocator) +ACE_WString::ACE_WString (const ACE_USHORT16 *s, + ACE_Allocator *allocator) : allocator_ (allocator) { ACE_TRACE ("ACE_WString::ACE_WString"); diff --git a/ace/Service_Record.cpp b/ace/Service_Record.cpp index b4b8dccbf65..63c7e5345c5 100644 --- a/ace/Service_Record.cpp +++ b/ace/Service_Record.cpp @@ -4,6 +4,9 @@ #define ACE_BUILD_DLL #include "ace/Service_Record.h" +#if !defined (ACE_SERVICE_RECORD_C) +#define ACE_SERVICE_RECORD_C + #if !defined (__ACE_INLINE__) #include "ace/Service_Record.i" #endif /* __ACE_INLINE__ */ @@ -332,9 +335,10 @@ template class ACE_Module<ACE_SYNCH>; template class ACE_Stream<ACE_SYNCH>; template class ACE_Task<ACE_SYNCH>; template class ACE_Message_Queue<ACE_SYNCH>; -template class ACE_Task_Exit<ACE_SYNCH>; -template class ACE_TSS<ACE_Task_Exit<ACE_SYNCH> >; +template class ACE_TSS<ACE_Task_Exit>; template class ACE_Thru_Task<ACE_SYNCH>; template class ACE_Stream_Head<ACE_SYNCH>; template class ACE_Stream_Tail<ACE_SYNCH>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ + +#endif /* ACE_SERVICE_RECORD_C */ diff --git a/ace/Service_Repository.cpp b/ace/Service_Repository.cpp index 8c5b91b40d7..9aece865ba2 100644 --- a/ace/Service_Repository.cpp +++ b/ace/Service_Repository.cpp @@ -218,7 +218,7 @@ ACE_Service_Repository::remove (const char name[]) if (handle != 0) ACE_OS::dlclose ((void *) handle); - if (--this->current_size_ > 1) + if (--this->current_size_ >= 1) this->service_vector_[i] = this->service_vector_[this->current_size_]; return 0; diff --git a/ace/Strategies.h b/ace/Strategies.h index 6506a0eb9c5..02129cca648 100644 --- a/ace/Strategies.h +++ b/ace/Strategies.h @@ -77,7 +77,7 @@ public: ACE_Thread_Manager * = 0); int open (SVC_HANDLER *, ACE_Thread_Manager * = 0); - ~ACE_Singleton_Strategy (void); + virtual ~ACE_Singleton_Strategy (void); // = Factory method. virtual SVC_HANDLER *make_svc_handler (void); @@ -206,7 +206,7 @@ public: int n_threads = 1); // Initialize the strategy. - ~ACE_Thread_Strategy (void); + virtual ~ACE_Thread_Strategy (void); // = Factory method. virtual int activate_svc_handler (SVC_HANDLER *svc_handler, @@ -259,7 +259,7 @@ public: virtual int open (int n_processes = 1); // Initialize the strategy. - ~ACE_Process_Strategy (void); + virtual ~ACE_Process_Strategy (void); // = Factory method. virtual int activate_svc_handler (SVC_HANDLER *svc_handler, @@ -311,7 +311,7 @@ public: virtual ACE_PEER_ACCEPTOR &acceptor (void) const; // Return a reference to the <peer_acceptor_>. - ~ACE_Accept_Strategy (void); + virtual ~ACE_Accept_Strategy (void); // = Factory method. virtual int accept_svc_handler (SVC_HANDLER *); @@ -346,7 +346,7 @@ public: ACE_Scheduling_Strategy (SVC_HANDLER * = 0); // Constructor - ~ACE_Scheduling_Strategy (void); + virtual ~ACE_Scheduling_Strategy (void); // Destructor // = Scheduling methods diff --git a/ace/Task.cpp b/ace/Task.cpp index 52fea1db94e..55be9be4754 100644 --- a/ace/Task.cpp +++ b/ace/Task.cpp @@ -1,9 +1,6 @@ // Task.cpp // $Id$ -#if !defined (ACE_TASK_C) -#define ACE_TASK_C - #define ACE_BUILD_DLL #include "ace/Task.h" #include "ace/Module.h" @@ -61,7 +58,7 @@ ACE_Task_Exit::ACE_Task_Exit (void) ACE_Task_Base * ACE_Task_Exit::get_task (void) { - ACE_TRACE ("ACE_Task_Exit<ACE_SYNCH_2>::get_task"); + ACE_TRACE ("ACE_Task_Exit::get_task"); return this->t_; } @@ -202,6 +199,9 @@ ACE_Task_Base::activate (long flags, // Keep the compiler from complaining. n_threads = n_threads; force_active = force_active; + priority = priority; + grp_id = grp_id; + task = task; flags = flags; errno = EINVAL; return -1; @@ -209,61 +209,6 @@ ACE_Task_Base::activate (long flags, #endif /* ACE_MT_SAFE */ } -template <ACE_SYNCH_1> ACE_INLINE void -ACE_Task<ACE_SYNCH_2>::dump (void) const -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, "\nthr_mgr_ = %x", this->thr_mgr_)); - this->msg_queue_->dump (); - ACE_DEBUG ((LM_DEBUG, "delete_msg_queue_ = %d\n", this->delete_msg_queue_)); - ACE_DEBUG ((LM_DEBUG, "\nflags = %x", this->flags_)); - ACE_DEBUG ((LM_DEBUG, "\nmod_ = %x", this->mod_)); - ACE_DEBUG ((LM_DEBUG, "\nnext_ = %x", this->next_)); - ACE_DEBUG ((LM_DEBUG, "\ngrp_id_ = %d", this->grp_id_)); - ACE_DEBUG ((LM_DEBUG, "\nthr_count_ = %d", this->thr_count_)); -#if defined (ACE_MT_SAFE) - this->lock_.dump (); -#endif /* ACE_MT_SAFE */ - - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -// If the user doesn't supply a ACE_Message_Queue pointer then we'll -// allocate one dynamically. Otherwise, we'll use the one they give. - -template<ACE_SYNCH_1> -ACE_Task<ACE_SYNCH_2>::ACE_Task (ACE_Thread_Manager *thr_man, - ACE_Message_Queue<ACE_SYNCH_2> *mq) - : ACE_Task_Base (thr_man), - msg_queue_ (0), - delete_msg_queue_ (0), - mod_ (0), - next_ (0) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::ACE_Task"); - - if (mq == 0) - { - ACE_NEW (mq, ACE_Message_Queue<ACE_SYNCH_2>); - this->delete_msg_queue_ = 1; - } - - this->msg_queue_ = mq; -} - -template<ACE_SYNCH_1> -ACE_Task<ACE_SYNCH_2>::~ACE_Task (void) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::~ACE_Task"); - if (this->delete_msg_queue_) - delete this->msg_queue_; - - // These assignments aren't strickly necessary but they help guard - // against odd race conditions... - this->delete_msg_queue_ = 0; -} - // Note that this routine often does not return since the thread that // is executing it will do an ACE_Thread::exit() first! @@ -285,31 +230,4 @@ ACE_Task_Base::svc_run (ACE_Task_Base *t) /* NOTREACHED */ } -template<ACE_SYNCH_1> ACE_Task<ACE_SYNCH_2> * -ACE_Task<ACE_SYNCH_2>::sibling (void) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::sibling"); - if (this->mod_ == 0) - return 0; - else - return this->mod_->sibling (this); -} - -template<ACE_SYNCH_1> const char * -ACE_Task<ACE_SYNCH_2>::name (void) const -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::name"); - if (this->mod_ == 0) - return 0; - else - return this->mod_->name (); -} - -template<ACE_SYNCH_1> ACE_Module<ACE_SYNCH_2> * -ACE_Task<ACE_SYNCH_2>::module (void) const -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::module"); - return this->mod_; -} -#endif /* ACE_TASK_C */ diff --git a/ace/Task.h b/ace/Task.h index e608ee4471b..bc254fa481f 100644 --- a/ace/Task.h +++ b/ace/Task.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -19,12 +18,7 @@ #define ACE_TASK_H #include "ace/Service_Object.h" -#include "ace/Message_Queue.h" #include "ace/Thread_Manager.h" -#include "ace/Synch_T.h" - -// Forward decls... -template <ACE_SYNCH_1> class ACE_Module; class ACE_Task_Flags // = TITLE @@ -111,10 +105,6 @@ public: void thr_mgr (ACE_Thread_Manager *); // Set the thread manager associated with this Task. - size_t thr_count (void); - // Returns the number of threads currently running within a task. - // If we're a passive object this value is 0, else it's > 0. - static void *svc_run (ACE_Task_Base *); // Routine that runs the service routine as a daemon thread. @@ -124,6 +114,10 @@ public: int is_writer (void); // True if queue is a writer, else false. + size_t thr_count (void); + // Returns the number of threads currently running within a task. + // If we're a passive object this value is 0, else it's > 0. + void thr_count_dec (void); // Atomically decrement the thread count by 1. This should only be // called by the <ACE_Task_Exit> class destructor. @@ -153,100 +147,6 @@ public: #endif /* ACE_MT_SAFE */ }; -template <ACE_SYNCH_1> -class ACE_Task : public ACE_Task_Base - // = TITLE - // Primary interface for application message processing, as well - // as input and output message queueing. - // - // = DESCRIPTION - // This class serves as the basis for passive and active objects - // in ACE. -{ -friend class ACE_Module<ACE_SYNCH_2>; -friend class ACE_Module_Type; -public: - // = Initialization/termination methods. - ACE_Task (ACE_Thread_Manager *thr_mgr = 0, - ACE_Message_Queue<ACE_SYNCH_2> *mq = 0); - // Initialize a Task, supplying a thread manager and a message - // queue. If the user doesn't supply a ACE_Message_Queue pointer - // then we'll allocate one dynamically. Otherwise, we'll use the - // one they give. - - virtual ~ACE_Task (void); - // Destructor. - - ACE_Message_Queue<ACE_SYNCH_2> *msg_queue (void); - // Gets the message queue associated with this task. - - void msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *); - // Sets the message queue associated with this task. - -public: // Should be protected: - // = Message queue manipulation methods. - - int putq (ACE_Message_Block *, ACE_Time_Value *tv = 0); - // Insert message into the message list. - - int getq (ACE_Message_Block *&mb, ACE_Time_Value *tv = 0); - // Extract the first message from the list (blocking). - - int ungetq (ACE_Message_Block *, ACE_Time_Value *tv = 0); - // Return a message to the queue. - - int can_put (ACE_Message_Block *); - // Tests whether we can enqueue a message without blocking. - - int reply (ACE_Message_Block *, ACE_Time_Value *tv = 0); - // Turn the message back around. - - int put_next (ACE_Message_Block *msg, ACE_Time_Value *tv = 0); - // Transfer message to the adjacent ACE_Task in a ACE_Stream. - - // = ACE_Task utility routines to identify names et al. - const char *name (void) const; - // Return the name of the enclosing Module if there's one associated - // with the Task, else returns 0. - - // = Pointers to next ACE_Task_Base (if ACE is part of an ACE_Stream). - ACE_Task<ACE_SYNCH_2> *next (void); - // Get next Task pointer. - void next (ACE_Task<ACE_SYNCH_2> *); - // Set next Task pointer. - - ACE_Task<ACE_SYNCH_2> *sibling (void); - // Return the Task's sibling if there's one associated with the - // Task's Module, else returns 0. - - ACE_Module<ACE_SYNCH_2> *module (void) const; - // Return the Task's Module if there is one, else returns 0. - - int flush (u_long flag = ACE_Task_Flags::ACE_FLUSHALL); /* Flush the queue */ - // Special routines corresponding to certain message types. - - void water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t); - // Manipulate watermarks. - - ACE_Message_Queue<ACE_SYNCH_2> *msg_queue_; - // List of messages on the ACE_Task.. - - int delete_msg_queue_; - // 1 if should delete Message_Queue, 0 otherwise. - - ACE_Module<ACE_SYNCH_2> *mod_; - // Back-pointer to the enclosing module. - - ACE_Task<ACE_SYNCH_2> *next_; - // Pointer to adjacent ACE_Task. - - void dump (void) const; - // Dump the state of an object. - - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. -}; - class ACE_Task_Exit // = TITLE // Keep exit information for a Task in thread specific storage so @@ -303,12 +203,7 @@ private: #include "ace/Task.i" #endif /* __ACE_INLINE__ */ -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Task.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Task.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ +// Include the ACE_Task templates classes at this point. +#include "ace/Task_T.h" #endif /* ACE_TASK_H */ diff --git a/ace/Task.i b/ace/Task.i index 51d223d85be..e5bf79b480a 100644 --- a/ace/Task.i +++ b/ace/Task.i @@ -56,104 +56,9 @@ ACE_Task_Base::is_writer (void) // Default ACE_Task service routine -int +ACE_INLINE int ACE_Task_Base::svc (void) { ACE_TRACE ("ACE_Task_Base::svc"); return 0; } - -template <ACE_SYNCH_1> ACE_INLINE void -ACE_Task<ACE_SYNCH_2>::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, - size_t size) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::water_marks"); - if (cmd == ACE_IO_Cntl_Msg::SET_LWM) - this->msg_queue_->low_water_mark (size); - else /* cmd == ACE_IO_Cntl_Msg::SET_HWM */ - this->msg_queue_->high_water_mark (size); -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::getq (ACE_Message_Block *&mb, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::getq"); - return this->msg_queue_->dequeue_head (mb, tv); -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::can_put (ACE_Message_Block *) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::can_put"); - assert (!"not implemented"); - return -1; -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::putq (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::putq"); - return this->msg_queue_->enqueue_tail (mb, tv); -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::ungetq (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::ungetq"); - return this->msg_queue_->enqueue_head (mb, tv); -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::flush (u_long flag) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::flush"); - if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL)) - return this->msg_queue_ != 0 && this->msg_queue_->close (); - else - return -1; // Note, need to be more careful about what we free... -} - -template <ACE_SYNCH_1> ACE_INLINE void -ACE_Task<ACE_SYNCH_2>::msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *mq) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::msg_queue"); - this->msg_queue_ = mq; -} - -template <ACE_SYNCH_1> ACE_Message_Queue<ACE_SYNCH_2> * -ACE_Task<ACE_SYNCH_2>::msg_queue (void) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::msg_queue"); - return this->msg_queue_; -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::reply (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::reply"); - return this->sibling ()->put_next (mb, tv); -} - -template <ACE_SYNCH_1> ACE_INLINE ACE_Task<ACE_SYNCH_2> * -ACE_Task<ACE_SYNCH_2>::next (void) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::next"); - return this->next_; -} - -template <ACE_SYNCH_1> ACE_INLINE void -ACE_Task<ACE_SYNCH_2>::next (ACE_Task<ACE_SYNCH_2> *q) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::next"); - this->next_ = q; -} - -// Transfer msg to the next ACE_Task. - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::put_next (ACE_Message_Block *msg, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::put_next"); - return this->next_ == 0 ? -1 : this->next_->put (msg, tv); -} - diff --git a/ace/Task_T.cpp b/ace/Task_T.cpp new file mode 100644 index 00000000000..a31045142a6 --- /dev/null +++ b/ace/Task_T.cpp @@ -0,0 +1,98 @@ +// Task.cpp +// $Id$ + +#if !defined (ACE_TASK_T_C) +#define ACE_TASK_T_C + +#define ACE_BUILD_DLL +#include "ace/Task_T.h" +#include "ace/Module.h" +#include "ace/Service_Config.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Task_T.i" +#endif /* __ACE_INLINE__ */ + +template <ACE_SYNCH_1> ACE_INLINE void +ACE_Task<ACE_SYNCH_2>::dump (void) const +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, "\nthr_mgr_ = %x", this->thr_mgr_)); + this->msg_queue_->dump (); + ACE_DEBUG ((LM_DEBUG, "delete_msg_queue_ = %d\n", this->delete_msg_queue_)); + ACE_DEBUG ((LM_DEBUG, "\nflags = %x", this->flags_)); + ACE_DEBUG ((LM_DEBUG, "\nmod_ = %x", this->mod_)); + ACE_DEBUG ((LM_DEBUG, "\nnext_ = %x", this->next_)); + ACE_DEBUG ((LM_DEBUG, "\ngrp_id_ = %d", this->grp_id_)); + ACE_DEBUG ((LM_DEBUG, "\nthr_count_ = %d", this->thr_count_)); +#if defined (ACE_MT_SAFE) + this->lock_.dump (); +#endif /* ACE_MT_SAFE */ + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +// If the user doesn't supply a ACE_Message_Queue pointer then we'll +// allocate one dynamically. Otherwise, we'll use the one they give. + +template<ACE_SYNCH_1> +ACE_Task<ACE_SYNCH_2>::ACE_Task (ACE_Thread_Manager *thr_man, + ACE_Message_Queue<ACE_SYNCH_2> *mq) + : ACE_Task_Base (thr_man), + msg_queue_ (0), + delete_msg_queue_ (0), + mod_ (0), + next_ (0) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::ACE_Task"); + + if (mq == 0) + { + ACE_NEW (mq, ACE_Message_Queue<ACE_SYNCH_2>); + this->delete_msg_queue_ = 1; + } + + this->msg_queue_ = mq; +} + +template<ACE_SYNCH_1> +ACE_Task<ACE_SYNCH_2>::~ACE_Task (void) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::~ACE_Task"); + if (this->delete_msg_queue_) + delete this->msg_queue_; + + // These assignments aren't strickly necessary but they help guard + // against odd race conditions... + this->delete_msg_queue_ = 0; +} + +template<ACE_SYNCH_1> ACE_Task<ACE_SYNCH_2> * +ACE_Task<ACE_SYNCH_2>::sibling (void) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::sibling"); + if (this->mod_ == 0) + return 0; + else + return this->mod_->sibling (this); +} + +template<ACE_SYNCH_1> const char * +ACE_Task<ACE_SYNCH_2>::name (void) const +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::name"); + if (this->mod_ == 0) + return 0; + else + return this->mod_->name (); +} + +template<ACE_SYNCH_1> ACE_Module<ACE_SYNCH_2> * +ACE_Task<ACE_SYNCH_2>::module (void) const +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::module"); + return this->mod_; +} + +#endif /* ACE_TASK_T_C */ diff --git a/ace/Task_T.h b/ace/Task_T.h new file mode 100644 index 00000000000..e65f2e9b979 --- /dev/null +++ b/ace/Task_T.h @@ -0,0 +1,130 @@ +// ============================================================================ +// +// = LIBRARY +// ace +// +// = FILENAME +// Task_T.h +// +// = AUTHOR +// Doug Schmidt +// +// ============================================================================ + +#if !defined (ACE_TASK_T_H) +#define ACE_TASK_T_H + +#include "ace/Message_Queue.h" +#include "ace/Synch_T.h" +#include "ace/Task.h" + +// Forward decls... +template <ACE_SYNCH_1> class ACE_Module; + +template <ACE_SYNCH_1> +class ACE_Task : public ACE_Task_Base + // = TITLE + // Primary interface for application message processing, as well + // as input and output message queueing. + // + // = DESCRIPTION + // This class serves as the basis for passive and active objects + // in ACE. +{ +friend class ACE_Module<ACE_SYNCH_2>; +friend class ACE_Module_Type; +public: + // = Initialization/termination methods. + ACE_Task (ACE_Thread_Manager *thr_mgr = 0, + ACE_Message_Queue<ACE_SYNCH_2> *mq = 0); + // Initialize a Task, supplying a thread manager and a message + // queue. If the user doesn't supply a ACE_Message_Queue pointer + // then we'll allocate one dynamically. Otherwise, we'll use the + // one they give. + + virtual ~ACE_Task (void); + // Destructor. + + ACE_Message_Queue<ACE_SYNCH_2> *msg_queue (void); + // Gets the message queue associated with this task. + + void msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *); + // Sets the message queue associated with this task. + +public: // Should be protected: + // = Message queue manipulation methods. + + int putq (ACE_Message_Block *, ACE_Time_Value *tv = 0); + // Insert message into the message list. + + int getq (ACE_Message_Block *&mb, ACE_Time_Value *tv = 0); + // Extract the first message from the list (blocking). + + int ungetq (ACE_Message_Block *, ACE_Time_Value *tv = 0); + // Return a message to the queue. + + int can_put (ACE_Message_Block *); + // Tests whether we can enqueue a message without blocking. + + int reply (ACE_Message_Block *, ACE_Time_Value *tv = 0); + // Turn the message back around. + + int put_next (ACE_Message_Block *msg, ACE_Time_Value *tv = 0); + // Transfer message to the adjacent ACE_Task in a ACE_Stream. + + // = ACE_Task utility routines to identify names et al. + const char *name (void) const; + // Return the name of the enclosing Module if there's one associated + // with the Task, else returns 0. + + // = Pointers to next ACE_Task_Base (if ACE is part of an ACE_Stream). + ACE_Task<ACE_SYNCH_2> *next (void); + // Get next Task pointer. + void next (ACE_Task<ACE_SYNCH_2> *); + // Set next Task pointer. + + ACE_Task<ACE_SYNCH_2> *sibling (void); + // Return the Task's sibling if there's one associated with the + // Task's Module, else returns 0. + + ACE_Module<ACE_SYNCH_2> *module (void) const; + // Return the Task's Module if there is one, else returns 0. + + int flush (u_long flag = ACE_Task_Flags::ACE_FLUSHALL); /* Flush the queue */ + // Special routines corresponding to certain message types. + + void water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t); + // Manipulate watermarks. + + ACE_Message_Queue<ACE_SYNCH_2> *msg_queue_; + // List of messages on the ACE_Task.. + + int delete_msg_queue_; + // 1 if should delete Message_Queue, 0 otherwise. + + ACE_Module<ACE_SYNCH_2> *mod_; + // Back-pointer to the enclosing module. + + ACE_Task<ACE_SYNCH_2> *next_; + // Pointer to adjacent ACE_Task. + + void dump (void) const; + // Dump the state of an object. + + ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. +}; + +#if defined (__ACE_INLINE__) +#include "ace/Task_T.i" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Task_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Task_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_TASK_T_H */ diff --git a/ace/Task_T.i b/ace/Task_T.i new file mode 100644 index 00000000000..9f5ba06054e --- /dev/null +++ b/ace/Task_T.i @@ -0,0 +1,98 @@ +/* -*- C++ -*- */ +// $Id$ + +// Task_T.i + +template <ACE_SYNCH_1> ACE_INLINE void +ACE_Task<ACE_SYNCH_2>::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, + size_t size) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::water_marks"); + if (cmd == ACE_IO_Cntl_Msg::SET_LWM) + this->msg_queue_->low_water_mark (size); + else /* cmd == ACE_IO_Cntl_Msg::SET_HWM */ + this->msg_queue_->high_water_mark (size); +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::getq (ACE_Message_Block *&mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::getq"); + return this->msg_queue_->dequeue_head (mb, tv); +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::can_put (ACE_Message_Block *) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::can_put"); + assert (!"not implemented"); + return -1; +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::putq (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::putq"); + return this->msg_queue_->enqueue_tail (mb, tv); +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::ungetq (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::ungetq"); + return this->msg_queue_->enqueue_head (mb, tv); +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::flush (u_long flag) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::flush"); + if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL)) + return this->msg_queue_ != 0 && this->msg_queue_->close (); + else + return -1; // Note, need to be more careful about what we free... +} + +template <ACE_SYNCH_1> ACE_INLINE void +ACE_Task<ACE_SYNCH_2>::msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *mq) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::msg_queue"); + this->msg_queue_ = mq; +} + +template <ACE_SYNCH_1> ACE_Message_Queue<ACE_SYNCH_2> * +ACE_Task<ACE_SYNCH_2>::msg_queue (void) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::msg_queue"); + return this->msg_queue_; +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::reply (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::reply"); + return this->sibling ()->put_next (mb, tv); +} + +template <ACE_SYNCH_1> ACE_INLINE ACE_Task<ACE_SYNCH_2> * +ACE_Task<ACE_SYNCH_2>::next (void) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::next"); + return this->next_; +} + +template <ACE_SYNCH_1> ACE_INLINE void +ACE_Task<ACE_SYNCH_2>::next (ACE_Task<ACE_SYNCH_2> *q) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::next"); + this->next_ = q; +} + +// Transfer msg to the next ACE_Task. + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::put_next (ACE_Message_Block *msg, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::put_next"); + return this->next_ == 0 ? -1 : this->next_->put (msg, tv); +} diff --git a/ace/Thread.h b/ace/Thread.h index 0d90998570b..9258f4093e3 100644 --- a/ace/Thread.h +++ b/ace/Thread.h @@ -20,24 +20,6 @@ #include "ace/ACE.h" -#if !defined (ACE_HAS_THREADS) -class ACE_Export ACE_Thread -{ -public: - static ACE_thread_t self (void); - // Return the unique ID of the thread. - - static void self (ACE_hthread_t &t_id); - // Return the unique kernel ID of the thread. - - static void exit (void *status = 0); - // Exit the current thread and return "status". - -private: - ACE_Thread (void); - // Ensure that we don't get instantiated. -}; -#else class ACE_Export ACE_Thread { // = TITLE @@ -175,7 +157,6 @@ private: ACE_Thread (void); // Ensure that we don't get instantiated. }; -#endif /* ACE_HAS_THREADS */ #if defined (__ACE_INLINE__) #include "ace/Thread.i" diff --git a/ace/Thread.i b/ace/Thread.i index c2842516a02..7d648b9207c 100644 --- a/ace/Thread.i +++ b/ace/Thread.i @@ -3,30 +3,6 @@ // Thread.i -#if !defined (ACE_HAS_THREADS) - -ACE_INLINE ACE_thread_t -ACE_Thread::self (void) -{ -// ACE_TRACE ("ACE_Thread::self"); - return ACE_OS::thr_self (); -} - -ACE_INLINE void -ACE_Thread::self (ACE_hthread_t &t_id) -{ -// ACE_TRACE ("ACE_Thread::self"); - ACE_OS::thr_self (t_id); -} - -ACE_INLINE void -ACE_Thread::exit (void *status) -{ - ACE_TRACE ("ACE_Thread::exit"); - ACE_OS::exit (*((int *) status)); -} -#else - // Allocates a <keyp> that is used to identify data that is specific // to each thread in the process. The key is global to all threads in // the process. @@ -262,5 +238,3 @@ ACE_Thread::self (ACE_hthread_t &t_id) // ACE_TRACE ("ACE_Thread::self"); ACE_OS::thr_self (t_id); } - -#endif /* !defined (ACE_HAS_THREADS) */ diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index c69df42ed22..035af3bf0ec 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -11,8 +11,6 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Control) ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Manager) -#if defined (ACE_HAS_THREADS) - void ACE_Thread_Manager::dump (void) const { @@ -50,7 +48,7 @@ ACE_Thread_Manager::thread_descriptor (ACE_thread_t thr_id, ACE_Thread_Descriptor &descriptor) { ACE_TRACE ("ACE_Thread_Descriptor::thread_descriptor"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); return this->thread_descriptor_i (thr_id, descriptor); } @@ -78,7 +76,7 @@ ACE_Thread_Manager::hthread_descriptor (ACE_hthread_t thr_handle, ACE_Thread_Descriptor &descriptor) { ACE_TRACE ("ACE_Thread_Descriptor::hthread_descriptor"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); return this->hthread_descriptor_i (thr_handle, descriptor); } @@ -89,7 +87,7 @@ int ACE_Thread_Manager::thr_self (ACE_hthread_t &self) { ACE_TRACE ("ACE_Thread_Descriptor::thr_self"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); // Try to get the cached HANDLE out of TSS to avoid lookup. ACE_hthread_t *handle = ACE_LOG_MSG->thr_handle (); @@ -138,7 +136,7 @@ int ACE_Thread_Manager::open (size_t size) { ACE_TRACE ("ACE_Thread_Manager::open"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); if (this->max_table_size_ < size) this->resize (size); @@ -151,8 +149,10 @@ ACE_Thread_Manager::ACE_Thread_Manager (size_t size) : thr_table_ (0), max_table_size_ (0), current_count_ (0), - grp_id_ (1), - zero_cond_ (lock_) + grp_id_ (1) +#if defined (ACE_HAS_THREADS) + , zero_cond_ (lock_) +#endif /* ACE_HAS_THREADS */ { ACE_TRACE ("ACE_Thread_Manager::ACE_Thread_Manager"); if (this->open (size) == -1) @@ -235,7 +235,7 @@ ACE_Thread_Manager::spawn (ACE_THR_FUNC func, size_t stack_size) { ACE_TRACE ("ACE_Thread_Manager::spawn"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); if (grp_id == -1) grp_id = this->grp_id_++; // Increment the group id. @@ -259,7 +259,7 @@ ACE_Thread_Manager::spawn_n (int n, ACE_Task_Base *task) { ACE_TRACE ("ACE_Thread_Manager::spawn_n"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); if (grp_id == -1) grp_id = this->grp_id_++; // Increment the group id. @@ -317,7 +317,7 @@ ACE_Thread_Manager::insert_thr (ACE_thread_t t_id, int grp_id) { ACE_TRACE ("ACE_Thread_Manager::insert_thr"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); // Check for duplicates and bail out if they're already // registered... @@ -347,9 +347,11 @@ ACE_Thread_Manager::remove_thr (int i) this->current_count_--; +#if defined (ACE_HAS_THREADS) // Tell all waiters when there are no more threads left in the pool. if (this->current_count_ == 0) this->zero_cond_.broadcast (); +#endif /* ACE_HAS_THREADS */ } // Factory out some common behavior to simplify the following methods. @@ -423,7 +425,7 @@ ACE_Thread_Manager::find (ACE_thread_t t_id) } #define ACE_EXECUTE_OP(OP) \ - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); \ + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); \ int i = this->find (t_id); \ if (i == -1) return -1; \ return OP (i); @@ -469,7 +471,7 @@ ACE_Thread_Manager::check_state (ACE_Thread_State state, ACE_thread_t id) { ACE_TRACE ("ACE_Thread_Manager::check_state"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); ACE_Thread_State *thr_state = 0; #if 0 @@ -537,7 +539,7 @@ int ACE_Thread_Manager::get_grp (ACE_thread_t t_id, int &grp_id) { ACE_TRACE ("ACE_Thread_Manager::get_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int i = this->find (t_id); if (i == -1) @@ -552,7 +554,7 @@ int ACE_Thread_Manager::set_grp (ACE_thread_t t_id, int grp_id) { ACE_TRACE ("ACE_Thread_Manager::set_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int i = this->find (t_id); if (i == -1) @@ -569,7 +571,7 @@ ACE_Thread_Manager::apply_grp (int grp_id, int arg) { ACE_TRACE ("ACE_Thread_Manager::apply_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int result = 0; @@ -623,7 +625,7 @@ int ACE_Thread_Manager::apply_all (THR_FUNC func, int arg) { ACE_TRACE ("ACE_Thread_Manager::apply_all"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int result = 0; @@ -671,7 +673,7 @@ void * ACE_Thread_Manager::exit (void *status, int do_thr_exit) { ACE_TRACE ("ACE_Thread_Manager::exit"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); int i = this->find (ACE_Thread::self ()); @@ -703,11 +705,15 @@ int ACE_Thread_Manager::wait (const ACE_Time_Value *timeout) { ACE_TRACE ("ACE_Thread_Manager::wait"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); +#if defined (ACE_HAS_THREADS) while (this->current_count_ > 0) if (this->zero_cond_.wait (timeout) == -1) return -1; +#else + timeout = timeout; +#endif /* ACE_HAS_THREADS */ return 0; } @@ -749,7 +755,7 @@ ACE_Thread_Manager::apply_task (ACE_Task_Base *task, int arg) { ACE_TRACE ("ACE_Thread_Manager::apply_task"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int result = 0; @@ -823,7 +829,7 @@ int ACE_Thread_Manager::num_tasks_in_group (int grp_id) { ACE_TRACE ("ACE_Thread_Manager::num_tasks_in_group"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int tasks_count = 0; @@ -841,7 +847,7 @@ int ACE_Thread_Manager::num_threads_in_task (ACE_Task_Base *task) { ACE_TRACE ("ACE_Thread_Manager::num_threads_in_task"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int threads_count = 0; @@ -860,7 +866,7 @@ ACE_Thread_Manager::task_list (int grp_id, size_t n) { ACE_TRACE ("ACE_Thread_Manager::task_list"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); ACE_Task_Base **task_list_iterator = task_list; size_t task_list_count = 0; @@ -885,7 +891,7 @@ ACE_Thread_Manager::thread_list (ACE_Task_Base *task, size_t n) { ACE_TRACE ("ACE_Thread_Manager::thread_list"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); ACE_thread_t *thread_list_iterator = thread_list; size_t thread_list_count = 0; @@ -908,7 +914,7 @@ ACE_Thread_Manager::hthread_list (ACE_Task_Base *task, size_t n) { ACE_TRACE ("ACE_Thread_Manager::thread_list"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); ACE_hthread_t *hthread_list_iterator = hthread_list; size_t hthread_list_count = 0; @@ -930,7 +936,7 @@ ACE_Thread_Manager::set_grp (ACE_Task_Base *task, int grp_id) { ACE_TRACE ("ACE_Thread_Manager::set_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); for (size_t i = 0; i < this->current_count_; i++) if (this->thr_table_[i].task_ == task) @@ -943,7 +949,7 @@ ACE_Thread_Manager::get_grp (ACE_Task_Base *task, int &grp_id) { ACE_TRACE ("ACE_Thread_Manager::get_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int i = this->find_task (task); @@ -1010,5 +1016,3 @@ ACE_Thread_Control::exit (void *exit_status) return 0; } } - -#endif /* !defined (ACE_HAS_THREADS) */ diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h index a4f9a623c71..e092a477135 100644 --- a/ace/Thread_Manager.h +++ b/ace/Thread_Manager.h @@ -67,71 +67,6 @@ private: // Current state of the thread. }; -#if !defined (ACE_HAS_THREADS) - -class ACE_Export ACE_Thread_Manager -{ -public: - enum - { - DEFAULT_SIZE = 100 - }; - - ACE_Thread_Manager (int = 0) {} - ~ACE_Thread_Manager (void) {} - - int open (size_t = DEFAULT_SIZE) { return -1; } - int close (void) { return -1; } - int spawn (ACE_THR_FUNC, - void * = 0, - long = 0, - ACE_thread_t * = 0, - ACE_hthread_t * = 0, - u_int = 0, - int = -1, - void * = 0, - size_t = 0) { return -1;} - int spawn_n (int, - ACE_THR_FUNC, - void * = 0, - long = 0, - u_int = 0, - int = -1 - ACE_Task_Base * = 0) { return -1;} - void *exit (void *) { return 0; } - void wait (const ACE_Time_Value * = 0) {} - int thread_descriptor (ACE_thread_t, ACE_Thread_Descriptor &) { return -1;} - int hthread_descriptor (ACE_hthread_t, ACE_Thread_Descriptor &) { return -1;} - int suspend_all (void) { return -1; } - int suspend (ACE_thread_t) { return -1; } - int suspend_grp (ACE_thread_t) { return -1; } - int resume_all (void) { return -1; } - int resume (ACE_thread_t) { return -1; } - int resume_grp (ACE_thread_t) { return -1; } - int kill_all (int) { return -1; } - int kill (ACE_thread_t) { return -1; } - int kill_grp (ACE_thread_t) { return -1; } - int cancel_all (void) { return -1; } - int cancel (int) { return -1; } - int cancel_grp (int) { return -1; } - void dump (void) const { } -}; - -class ACE_Export ACE_Thread_Control -{ -public: - ACE_Thread_Control (ACE_Thread_Manager * = 0, int = 0) {} - ~ACE_Thread_Control (void) {} - ACE_Thread_Manager *thr_mgr (void) { return 0; } - ACE_Thread_Manager *thr_mgr (ACE_Thread_Manager *) { return 0; } - void *exit (void *) { return 0; } - int insert (ACE_Thread_Manager *) { return 0; } - void *status (void *) { return 0; } - void *status (void) { return 0; } - void dump (void) const { } -}; -#else - // Forward declaration. class ACE_Thread_Control; @@ -400,8 +335,10 @@ private: // Keeps track of the next group id to assign. // = ACE_Thread_Mutex and condition variable for synchronizing termination. +#if defined (ACE_HAS_THREADS) ACE_Thread_Mutex lock_; ACE_Condition_Thread_Mutex zero_cond_; +#endif /* ACE_HAS_THREADS */ }; @@ -459,6 +396,5 @@ private: #include "ace/Thread_Manager.i" #endif /* __ACE_INLINE__ */ -#endif /* !defined (ACE_HAS_THREADS) */ #endif /* ACE_THREAD_MANAGER_H */ diff --git a/ace/Thread_Manager.i b/ace/Thread_Manager.i index 041b74cea66..97a8653e21b 100644 --- a/ace/Thread_Manager.i +++ b/ace/Thread_Manager.i @@ -39,8 +39,6 @@ ACE_Thread_Descriptor::state (void) return thr_state_; } -#if defined (ACE_HAS_THREADS) - // Set the exit status. ACE_INLINE void * @@ -79,5 +77,3 @@ ACE_Thread_Control::thr_mgr (ACE_Thread_Manager *tm) return this->tm_ = tm; return o_tm; } - -#endif /* !defined (ACE_HAS_THREADS) */ diff --git a/ace/Token_Invariants.h b/ace/Token_Invariants.h index eb40c9524a0..67507ee7764 100644 --- a/ace/Token_Invariants.h +++ b/ace/Token_Invariants.h @@ -97,11 +97,11 @@ public: // Dump the state of the class. private: - int readers_; - // Number of owning readers. - int writers_; // Number of owning writers. + + int readers_; + // Number of owning readers. }; class ACE_Export ACE_Token_Invariant_Manager diff --git a/ace/config-win32-msvc4.0.h b/ace/config-win32-msvc4.0.h index af03633ea15..fb529512dc5 100644 --- a/ace/config-win32-msvc4.0.h +++ b/ace/config-win32-msvc4.0.h @@ -7,9 +7,6 @@ #if !defined (ACE_CONFIG_H) #define ACE_CONFIG_H -// Needed for timeval. -#include <winsock.h> - #if defined (_MSC_VER) // "C4355: 'this' : used in base member initializer list" #pragma warning(disable:4355) // disable C4514 warning diff --git a/apps/Gateway/Gateway/Channel.cpp b/apps/Gateway/Gateway/Channel.cpp index c0ee7788ef6..5d47f0492be 100644 --- a/apps/Gateway/Gateway/Channel.cpp +++ b/apps/Gateway/Gateway/Channel.cpp @@ -25,15 +25,15 @@ Channel::Channel (ROUTING_TABLE *rt, Channel_Connector *cc, ACE_Thread_Manager *thr_mgr, int socket_queue_size) - : id_ (-1), + : ACE_Svc_Handler<CHANNEL_PEER_STREAM, SYNCH> (thr_mgr), + routing_table_ (rt), + id_ (-1), total_bytes_ (0), state_ (Channel::IDLE), - routing_table_ (rt), connector_ (cc), timeout_ (1), max_timeout_ (Channel::MAX_RETRY_TIMEOUT), - socket_queue_size_ (socket_queue_size), - ACE_Svc_Handler<CHANNEL_PEER_STREAM, SYNCH> (thr_mgr) + socket_queue_size_ (socket_queue_size) { } diff --git a/apps/Gateway/Gateway/Channel.h b/apps/Gateway/Gateway/Channel.h index 884d9b98d07..339716bc55a 100644 --- a/apps/Gateway/Gateway/Channel.h +++ b/apps/Gateway/Gateway/Channel.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY diff --git a/apps/Gateway/Gateway/Gateway.cpp b/apps/Gateway/Gateway/Gateway.cpp index 82bbd83e802..19edef5d19e 100644 --- a/apps/Gateway/Gateway/Gateway.cpp +++ b/apps/Gateway/Gateway/Gateway.cpp @@ -197,10 +197,10 @@ Gateway<IC, OC>::Gateway (ACE_Thread_Manager *thr_mgr) blocking_semantics_ (ACE_NONBLOCK), debug_ (0), connector_ (0), + socket_queue_size_ (0), thr_mgr_ (thr_mgr), input_thr_mgr_ (thr_mgr), - output_thr_mgr_ (thr_mgr), - socket_queue_size_ (0) + output_thr_mgr_ (thr_mgr) { } diff --git a/apps/Gateway/Peer/Gateway_Handler.cpp b/apps/Gateway/Peer/Gateway_Handler.cpp index 8390fb7b70b..97ce8285e5e 100644 --- a/apps/Gateway/Peer/Gateway_Handler.cpp +++ b/apps/Gateway/Peer/Gateway_Handler.cpp @@ -173,7 +173,6 @@ int Gateway_Handler::handle_output (ACE_HANDLE) { ACE_Message_Block *mb = 0; - int status = 0; ACE_DEBUG ((LM_DEBUG, "in handle_output\n")); // The list had better not be empty, otherwise there's a bug! @@ -247,7 +246,7 @@ Gateway_Handler::send_peer (ACE_Message_Block *mb) if ((n = this->peer ().send (mb->rd_ptr (), len)) <= 0) return errno == EWOULDBLOCK ? 0 : n; - else if (n < len) + else if (n < (ssize_t) len) { // Re-adjust pointer to skip over the part we did send. mb->rd_ptr (n); @@ -341,7 +340,7 @@ Gateway_Handler::recv_peer (ACE_Message_Block *&mb) return n; default: - if (n != len) + if (n != (ssize_t) len) // Re-adjust pointer to skip over the part we've read. { this->msg_frag_->wr_ptr (n); @@ -509,8 +508,8 @@ Gateway_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) // Close down the peer. this->peer ().close (); - return 0; } + return 0; } Gateway_Acceptor::Gateway_Acceptor (Gateway_Handler *handler) diff --git a/examples/Connection/blocking/SPIPE-connector.cpp b/examples/Connection/blocking/SPIPE-connector.cpp index 940f716433f..3bc22f1a280 100644 --- a/examples/Connection/blocking/SPIPE-connector.cpp +++ b/examples/Connection/blocking/SPIPE-connector.cpp @@ -30,7 +30,7 @@ Peer_Handler::open (void *) if (ACE::register_stdin_handler (this, ACE_Service_Config::reactor (), ACE_Service_Config::thr_mgr ()) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "register_stdin_handler")); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_stdin_handler"), -1); } else // If iterations_ has been set, send iterations_ buffers. { @@ -46,9 +46,8 @@ Peer_Handler::open (void *) while (iterations_-- > 0 && this->peer ().send_n (buffer, length) == length) continue; - - return this->peer ().close (); } + return this->peer ().close (); } int @@ -93,8 +92,8 @@ Peer_Handler::display_menu (void) } IPC_Client::IPC_Client (void) - : rendezvous_ ("acepipe"), - iterations_ (0), + : iterations_ (0), + rendezvous_ ("acepipe"), done_handler_ (ACE_Sig_Handler_Ex (ACE_Service_Config::end_proactor_event_loop)) { } diff --git a/examples/Connection/non_blocking/CPP-acceptor.cpp b/examples/Connection/non_blocking/CPP-acceptor.cpp index e3c69ccfddc..e01586cc0d3 100644 --- a/examples/Connection/non_blocking/CPP-acceptor.cpp +++ b/examples/Connection/non_blocking/CPP-acceptor.cpp @@ -101,7 +101,7 @@ IPC_Server<SH, PR_AC_2>::init (int argc, char *argv[]) // Handle SIGPIPE signal through the ACE_Reactor. else if (ACE_Service_Config::reactor ()->register_handler (SIGPIPE, &this->done_handler_) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_handler"), -1); else return 0; } diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp index 5af91f21afe..d4ffacd1171 100644 --- a/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-Msg-server.cpp @@ -12,7 +12,7 @@ main (int, char *[]) char buf[BUFSIZ]; ACE_Str_Buf msg (buf, 0, sizeof buf); int flags = MSG_ANY; - int band = 0; + int band = 0; int n; while ((n = server.recv (&band, &msg, (ACE_Str_Buf *) 0, &flags)) >= 0) @@ -20,7 +20,7 @@ main (int, char *[]) if (msg.len == 0) break; else - printf ("%4d (%4d): %*s", msg.len, band, msg.len, msg.buf); + ACE_DEBUG (("%4d (%4d): %*s", msg.len, band, msg.len, msg.buf)); flags = MSG_ANY; band = 0; } diff --git a/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp index 1cfae1dfd2f..cde046c26ea 100644 --- a/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp +++ b/examples/IPC_SAP/FIFO_SAP/FIFO-test.cpp @@ -1,9 +1,10 @@ -/* Purpose: This program uses ACE_FIFO wrappers to perform interprocess // $Id$ - communication between a parent process and a child process. - The parents reads from an input file and writes it into the fifo. - The child reads from the ACE_FIFO and executes the more command. */ +// Purpose: This program uses ACE_FIFO wrappers to perform +// interprocess communication between a parent process and a child +// process. The parents reads from an input file and writes it into +// the fifo. The child reads from the ACE_FIFO and executes the more +// command. #include "ace/Log_Msg.h" #include "ace/FIFO_Recv.h" @@ -18,7 +19,7 @@ const char *FIFO_NAME = "/tmp/fifo"; int do_child (ACE_FIFO_Recv &fifo_reader) { - /* Set child's stdin to read from the fifo */ + // Set child's stdin to read from the fifo. if (ACE_OS::close (0) == -1 || ACE_OS::dup (fifo_reader.get_handle ()) == -1) return -1; @@ -28,6 +29,7 @@ do_child (ACE_FIFO_Recv &fifo_reader) if (ACE_OS::execvp (EXEC_NAME, argv) == -1) return -1; + return 0; } int @@ -44,7 +46,7 @@ do_parent (const char fifo_name[], char input_filename[]) if ((inputfd = ACE_OS::open (input_filename, O_RDONLY)) == -1) return -1; - /* Read from input file and write into input end of the fifo */ + // Read from input file and write into input end of the fifo. while ((len = ACE_OS::read (inputfd, buf, sizeof buf)) > 0) if (fifo_sender.send (buf, len) != len) @@ -84,7 +86,8 @@ main (int argc, char *argv[]) if (do_parent (FIFO_NAME, argv[1]) == -1) ACE_ERROR ((LM_ERROR, "%n: %p\n%a", "do_parent", 1)); - if (ACE_OS::waitpid (child_pid, (int *) 0, 0) == -1) /* wait for child to ACE_OS::exit */ + // wait for child to ACE_OS::exit. + if (ACE_OS::waitpid (child_pid, (int *) 0, 0) == -1) ACE_ERROR ((LM_ERROR, "%n: %p\n%a", "waitpid", 1)); } diff --git a/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp b/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp index 4c7f2d96052..2165064ab83 100644 --- a/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp +++ b/examples/IPC_SAP/SOCK_SAP/FD-unclient.cpp @@ -1,6 +1,6 @@ -#include "ace/LSOCK_Connector.h" // $Id$ +#include "ace/LSOCK_Connector.h" #include "ace/UNIX_Addr.h" #if defined (ACE_HAS_MSG) && !defined (ACE_HAS_UNIX_DOMAIN_SOCKETS) @@ -10,26 +10,25 @@ int main (int argc, char *argv[]) { char *file_name = argc > 1 ? argv[1] : "./local_data"; - char *send_str = argc > 2 ? argv[2] : "hello world"; - char *rendezvous = argc > 3 ? argv[3] : ACE_DEFAULT_RENDEZVOUS; - int fd; + char *rendezvous = argc > 2 ? argv[2] : ACE_DEFAULT_RENDEZVOUS; + ACE_HANDLE handle; int n; char buf[BUFSIZ]; ACE_LSOCK_Stream cli_stream; ACE_UNIX_Addr addr (rendezvous); - /* Establish the connection with server */ + // Establish the connection with server. ACE_LSOCK_Connector connector; if (connector.connect (cli_stream, addr) == -1) ACE_OS::perror ("connect"), ACE_OS::exit (1); - if ((fd = ACE_OS::open (file_name, O_RDONLY)) == -1) + if ((handle = ACE_OS::open (file_name, O_RDONLY)) == -1) ACE_OS::perror ("open"), ACE_OS::exit (1); - /* Send data to server (correctly handles incomplete writes) */ - if (cli_stream.send_handle (fd) == -1) + // Send handle to server (correctly handles incomplete writes). + if (cli_stream.send_handle (handle) == -1) ACE_OS::perror ("send"), ACE_OS::exit (1); if ((n = cli_stream.recv_n (buf, sizeof buf)) == -1) @@ -37,7 +36,7 @@ main (int argc, char *argv[]) else ACE_OS::write (ACE_STDOUT, buf, n); - /* Explicitly close the connection */ + // Explicitly close the connection. if (cli_stream.close () == -1) ACE_OS::perror ("close"), ACE_OS::exit (1); diff --git a/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp index 219ba019c33..38cf2b9de8c 100644 --- a/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp +++ b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp @@ -1,50 +1,51 @@ -#include "ace/LSOCK_Acceptor.h" // $Id$ +#include "ace/LSOCK_Acceptor.h" #include "ace/LSOCK_Stream.h" #include "ace/UNIX_Addr.h" #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) -/* ACE_SOCK Server */ +// ACE_LSOCK Server int main (int argc, char *argv[]) { char *rendezvous = argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS; - /* Create a server */ + // Create a server. ACE_OS::unlink (rendezvous); ACE_UNIX_Addr addr (rendezvous); ACE_LSOCK_Acceptor peer_acceptor (addr); ACE_LSOCK_Stream new_stream; - /* Performs the iterative server activities */ + // Performs the iterative server activities. for (;;) { char buf[BUFSIZ]; - int fd; + ACE_HANDLE handle; - /* Create a new ACE_SOCK_Stream endpoint */ + // Create a new ACE_SOCK_Stream endpoint. if (peer_acceptor.accept (new_stream) == -1) ACE_OS::perror ("accept"); - /* Read data from client (correctly handles incomplete reads due to flow control) */ + // Read data from client (correctly handles incomplete reads due + // to flow control). - if (new_stream.recv_handle (fd) == -1) - ::perror ("recv_handle"), ACE_OS::exit (1); + if (new_stream.recv_handle (handle) == -1) + ACE_OS::perror ("recv_handle"), ACE_OS::exit (1); ACE_OS::puts ("----------------------------------------"); - for (int n; (n = ACE_OS::read (fd, buf, sizeof buf)) > 0; ) - ::write (1, buf, n); + for (int n; (n = ACE_OS::read (handle, buf, sizeof buf)) > 0; ) + ACE_OS::write (ACE_STDOUT, buf, n); ACE_OS::puts ("----------------------------------------"); if (new_stream.send ("yow", 3) == -1) - ::perror ("send"), ACE_OS::exit (1); + ACE_OS::perror ("send"), ACE_OS::exit (1); - /* Close new endpoint (listening endpoint stays open) */ + // Close new endpoint (listening endpoint stays open). if (new_stream.close () == -1) ACE_OS::perror ("close"); } diff --git a/include/makeinclude/platform_sunos5_g++.GNU b/include/makeinclude/platform_sunos5_g++.GNU index 7f4f8c9d3a9..09370aa718a 100644 --- a/include/makeinclude/platform_sunos5_g++.GNU +++ b/include/makeinclude/platform_sunos5_g++.GNU @@ -3,7 +3,7 @@ # SOBUILD - compile into .so directly # CC = gcc -CXX = gcc -I. -fno-strict-prototypes -D__ACE_INLINE__ -Wall -Wpointer-arith -Winline -frepo +CXX = gcc -I. -fno-strict-prototypes -D__ACE_INLINE__ -Wall -Wpointer-arith -Winline DLD = $(CXX) LDFLAGS += -L $(WRAPPER_ROOT)/ace -L ./ # -z muldefs LIBS += -lsocket -ldl -lstdc++ -lgen -lnsl -lthread -lw diff --git a/netsvcs/lib/Client_Logging_Handler.cpp b/netsvcs/lib/Client_Logging_Handler.cpp index fb05f51847b..746f6d6a130 100644 --- a/netsvcs/lib/Client_Logging_Handler.cpp +++ b/netsvcs/lib/Client_Logging_Handler.cpp @@ -87,7 +87,7 @@ ACE_Client_Logging_Handler::ACE_Client_Logging_Handler (const char rendezvous[]) // This is called when a <send> to the logging server fails... int -ACE_Client_Logging_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *) +ACE_Client_Logging_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { ACE_TRACE ("ACE_Client_Logging_Connector::handle_signal"); // return 0; @@ -175,7 +175,7 @@ ACE_Client_Logging_Handler::close (u_long) } int -ACE_Client_Logging_Handler::handle_output (ACE_HANDLE handle) +ACE_Client_Logging_Handler::handle_output (ACE_HANDLE) { return 0; } @@ -355,7 +355,7 @@ ACE_Client_Logging_Connector::resume (void) // Signal the server to shutdown gracefully. int -ACE_Client_Logging_Connector::handle_signal (int signum, siginfo_t *, ucontext_t *) +ACE_Client_Logging_Connector::handle_signal (int, siginfo_t *, ucontext_t *) { ACE_TRACE ("ACE_Client_Logging_Connector::handle_signal"); ACE_Service_Config::end_reactor_event_loop (); @@ -369,5 +369,5 @@ ACE_Client_Logging_Connector::handle_signal (int signum, siginfo_t *, ucontext_t ACE_SVC_FACTORY_DEFINE (ACE_Client_Logging_Connector) #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Connector<ACE_Client_Logging_Handler, ACE_SOCK_Connector, ACE_INET_Addr>; +template class ACE_Connector<ACE_Client_Logging_Handler, ACE_SOCK_CONNECTOR>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/netsvcs/lib/Logging_Strategy.cpp b/netsvcs/lib/Logging_Strategy.cpp index 43cea9ae7d7..e00171333e4 100644 --- a/netsvcs/lib/Logging_Strategy.cpp +++ b/netsvcs/lib/Logging_Strategy.cpp @@ -64,7 +64,6 @@ ACE_Logging_Strategy::parse_args (int argc, char *argv[]) { ACE_TRACE ("ACE_Logging_Strategy::parse_args"); char *temp; - u_long flag = 0; this->flags_ = 0; this->filename_ = ACE_DEFAULT_LOGFILE; @@ -129,17 +128,3 @@ ACE_Logging_Strategy::init (int argc, char *argv[]) // svc.conf file to dynamically initialize the state of the Logging_Strategy. ACE_SVC_FACTORY_DEFINE (ACE_Logging_Strategy) - -#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Strategy_Acceptor<ACE_TS_Server_Handler, ACE_SOCK_Acceptor, ACE_INET_Addr>; -template class ACE_Schedule_All_Reactive_Strategy<ACE_TS_Server_Handler>; -#if defined (ACE_HAS_THREADS) -template class ACE_Svc_Handler<ACE_SOCK_Stream, ACE_INET_Addr, ACE_Null_Mutex, ACE_Null_Condition_Mutex>; -template class ACE_Task<ACE_Null_Mutex, ACE_Null_Condition_Mutex>; -template class ACE_Message_Queue<ACE_Null_Mutex, ACE_Null_Condition_Mutex>; -template class ACE_Module<ACE_Null_Mutex, ACE_Null_Condition_Mutex>; -template class ACE_Task_Exit<ACE_Null_Mutex, ACE_Null_Condition_Mutex>; -template class ACE_TSS<ACE_Task_Exit<ACE_Null_Mutex, ACE_Null_Condition_Mutex> >; -template class ACE_Thru_Task<ACE_Null_Mutex, ACE_Null_Condition_Mutex>; -#endif -#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/netsvcs/lib/Name_Handler.cpp b/netsvcs/lib/Name_Handler.cpp index 6cdc57f2e2a..09daccbbc7e 100644 --- a/netsvcs/lib/Name_Handler.cpp +++ b/netsvcs/lib/Name_Handler.cpp @@ -445,7 +445,7 @@ ACE_Name_Handler::recv_request (void) ssize_t length = ntohl (this->name_request_.length ()); // Do a sanity check on the length of the message. - if (length > sizeof this->name_request_) + if (length > (ssize_t) sizeof this->name_request_) { ACE_ERROR ((LM_ERROR, "length %d too long\n", length)); return this->abandon (); @@ -733,6 +733,6 @@ ACE_Name_Handler::~ACE_Name_Handler (void) } #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Strategy_Acceptor<ACE_Name_Handler, ACE_SOCK_Acceptor, ACE_INET_Addr>; +template class ACE_Strategy_Acceptor<ACE_Name_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Schedule_All_Reactive_Strategy<ACE_Name_Handler>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/netsvcs/lib/Server_Logging_Handler.cpp b/netsvcs/lib/Server_Logging_Handler.cpp index 1dd2be38b3d..a6a812452f0 100644 --- a/netsvcs/lib/Server_Logging_Handler.cpp +++ b/netsvcs/lib/Server_Logging_Handler.cpp @@ -446,8 +446,8 @@ ACE_Thr_Server_Logging_Handler::svc (void) #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) template class ACE_Strategy_Acceptor<ACE_Thr_Server_Logging_Handler, LOGGING_PEER_ACCEPTOR>; template class ACE_Schedule_All_Threaded_Strategy<ACE_Thr_Server_Logging_Handler>; -template class ACE_Strategy_Acceptor<ACE_Server_Logging_Handler<LOGGING_PEER_STREAM, unsigned long, ACE_Null_Mutex, ACE_Null_Condition_Mutex>, LOGGING_PEER_ACCEPTOR>; -template class ACE_Schedule_All_Reactive_Strategy<ACE_Server_Logging_Handler<LOGGING_PEER_STREAM, unsigned long, ACE_Null_Mutex, ACE_Null_Condition_Mutex> >; +template class ACE_Strategy_Acceptor<ACE_Server_Logging_Handler<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH>, LOGGING_PEER_ACCEPTOR>; +template class ACE_Schedule_All_Reactive_Strategy<ACE_Server_Logging_Handler<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH> >; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/netsvcs/lib/TS_Clerk_Handler.cpp b/netsvcs/lib/TS_Clerk_Handler.cpp index 1128fffc94e..bac46bb603e 100644 --- a/netsvcs/lib/TS_Clerk_Handler.cpp +++ b/netsvcs/lib/TS_Clerk_Handler.cpp @@ -185,7 +185,7 @@ private: int update_time (); // Update delta_time using times obtained from all servers - typedef ACE_Malloc <ACE_MMAP_Memory_Pool, ACE_Null_Mutex> MALLOC; + typedef ACE_Malloc <ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> MALLOC; typedef ACE_Allocator_Adapter<MALLOC> ALLOCATOR; ALLOCATOR *shmem_; // Allocator (used for reading/writing system time from/to shared memory) @@ -223,11 +223,11 @@ private: ACE_TS_Clerk_Handler::ACE_TS_Clerk_Handler (ACE_TS_Clerk_Processor *processor, ACE_INET_Addr &addr) -: processor_ (processor), - remote_addr_ (addr), - state_ (ACE_TS_Clerk_Handler::IDLE), +: state_ (ACE_TS_Clerk_Handler::IDLE), timeout_ (ACE_DEFAULT_TIMEOUT), - max_timeout_ (ACE_TS_Clerk_Handler::MAX_RETRY_TIMEOUT) + max_timeout_ (ACE_TS_Clerk_Handler::MAX_RETRY_TIMEOUT), + remote_addr_ (addr), + processor_ (processor) { ACE_TRACE ("ACE_TS_Clerk_Handler::ACE_TS_Clerk_Handler"); this->time_info_.delta_time_ = 0; @@ -236,7 +236,7 @@ ACE_TS_Clerk_Handler::ACE_TS_Clerk_Handler (ACE_TS_Clerk_Processor *processor, // This is called when a <send> to a server fails... int -ACE_TS_Clerk_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *) +ACE_TS_Clerk_Handler::handle_signal (int, siginfo_t *, ucontext_t *) { ACE_TRACE ("ACE_TS_Clerk_Handler::handle_signal"); return 0; @@ -376,7 +376,7 @@ ACE_TS_Clerk_Handler::reinitiate_connection (void) // Receive a time update from a server int -ACE_TS_Clerk_Handler::handle_input (ACE_HANDLE handle) +ACE_TS_Clerk_Handler::handle_input (ACE_HANDLE) { ACE_TRACE ("ACE_TS_Clerk_Handler::handle_input"); // We're getting a time update message from a server @@ -405,8 +405,8 @@ ACE_TS_Clerk_Handler::handle_input (ACE_HANDLE handle) // Restart connection asynchronously when timeout occurs. int -ACE_TS_Clerk_Handler::handle_timeout (const ACE_Time_Value &tv, - const void *arg) +ACE_TS_Clerk_Handler::handle_timeout (const ACE_Time_Value &, + const void *) { ACE_TRACE ("ACE_TS_Clerk_Handler::handle_timeout"); ACE_DEBUG ((LM_DEBUG, @@ -535,8 +535,8 @@ ACE_TS_Clerk_Processor::alloc (void) // Query the servers for the latest time int -ACE_TS_Clerk_Processor::handle_timeout (const ACE_Time_Value &tv, - const void *arg) +ACE_TS_Clerk_Processor::handle_timeout (const ACE_Time_Value &, + const void *) { ACE_TRACE ("ACE_TS_Clerk_Processor::handle_timeout"); return this->update_time (); @@ -632,7 +632,7 @@ ACE_TS_Clerk_Processor::fini (void) } int -ACE_TS_Clerk_Processor::info (char **strp, size_t length) const +ACE_TS_Clerk_Processor::info (char **, size_t) const { ACE_TRACE ("ACE_TS_Clerk_Processor::info"); return 0; @@ -652,9 +652,6 @@ ACE_TS_Clerk_Processor::init (int argc, char *argv[]) // Ignore SIPPIPE so each Output_Channel can handle it. ACE_Sig_Action sig (ACE_SignalHandler (SIG_IGN), SIGPIPE); -// ACE_Sig_Set sig_set; -// sig_set.sig_add (SIGINT); - // Register ourselves to receive SIGINT and SIGPIPE // so we can shut down gracefully via signals. if (ACE_Service_Config::reactor ()->register_handler (SIGINT, @@ -809,7 +806,7 @@ ACE_TS_Clerk_Processor::resume (void) // Signal the server to shutdown gracefully. int -ACE_TS_Clerk_Processor::handle_signal (int signum, siginfo_t *, ucontext_t *) +ACE_TS_Clerk_Processor::handle_signal (int, siginfo_t *, ucontext_t *) { ACE_TRACE ("ACE_TS_Clerk_Processor::handle_signal"); ACE_Service_Config::end_reactor_event_loop (); @@ -822,5 +819,5 @@ ACE_TS_Clerk_Processor::handle_signal (int signum, siginfo_t *, ucontext_t *) ACE_SVC_FACTORY_DEFINE (ACE_TS_Clerk_Processor) #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Connector<ACE_TS_Clerk_Handler, ACE_SOCK_Connector, ACE_INET_Addr>; +template class ACE_Connector<ACE_TS_Clerk_Handler, ACE_SOCK_CONNECTOR>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/netsvcs/lib/TS_Server_Handler.cpp b/netsvcs/lib/TS_Server_Handler.cpp index da683b92439..848a18016bf 100644 --- a/netsvcs/lib/TS_Server_Handler.cpp +++ b/netsvcs/lib/TS_Server_Handler.cpp @@ -319,6 +319,6 @@ ACE_TS_Server_Handler::~ACE_TS_Server_Handler (void) } #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Strategy_Acceptor<ACE_TS_Server_Handler, ACE_SOCK_Acceptor, ACE_INET_Addr>; +template class ACE_Strategy_Acceptor<ACE_TS_Server_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Schedule_All_Reactive_Strategy<ACE_TS_Server_Handler>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/netsvcs/lib/Token_Handler.cpp b/netsvcs/lib/Token_Handler.cpp index 1208cdbd1a7..daf8486e534 100644 --- a/netsvcs/lib/Token_Handler.cpp +++ b/netsvcs/lib/Token_Handler.cpp @@ -104,13 +104,13 @@ private: // Keeps track of the synchronization options (i.e., the timeout // interval). + ACE_Token_Collection collection_; + // collection of the client's token proxies. + int timeout_id_; // ID returned by the Reactor that is used to kill registered timers // when a token operation times out. - ACE_Token_Collection collection_; - // collection of the client's token proxies. - ACE_Token_Request token_request_; // Cache request from the client. @@ -341,7 +341,7 @@ ACE_Token_Handler::send_reply (ACE_UINT32 err) n = this->peer ().send (buf, len); - if (n != len) + if (n != (ssize_t) len) ACE_ERROR_RETURN ((LM_ERROR, "%p, expected len = %d, actual len = %d\n", "send failed", len, n), -1); @@ -645,7 +645,7 @@ ACE_Token_Handler::recv_request (void) ssize_t length = this->token_request_.length (); // Do a sanity check on the length of the message. - if (length > sizeof this->token_request_) + if (length > (ssize_t) sizeof this->token_request_) { ACE_ERROR ((LM_ERROR, "length %d too long\n", length)); return this->abandon (1); @@ -875,8 +875,6 @@ ACE_TS_WLock::clone (void) const } #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Strategy_Acceptor<ACE_Token_Handler, ACE_SOCK_Acceptor, ACE_INET_Addr>; +template class ACE_Strategy_Acceptor<ACE_Token_Handler, ACE_SOCK_ACCEPTOR>; template class ACE_Schedule_All_Reactive_Strategy<ACE_Token_Handler>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ - - |