diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-01-01 14:56:22 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-01-01 14:56:22 +0000 |
commit | a4992e6885fb8e1d8972435cb5a5a29fd5f07788 (patch) | |
tree | 847ba2b1e9e6b958c80833f86a5b1a58a4c56de7 /netsvcs | |
parent | 390e1225ecb0ead241ad8ec2dd1a68d163b3e82a (diff) | |
download | ATCD-a4992e6885fb8e1d8972435cb5a5a29fd5f07788.tar.gz |
don't use Base_Optimizer with g++
Diffstat (limited to 'netsvcs')
-rw-r--r-- | netsvcs/lib/Server_Logging_Handler_T.cpp | 149 | ||||
-rw-r--r-- | netsvcs/lib/Server_Logging_Handler_T.h | 73 |
2 files changed, 110 insertions, 112 deletions
diff --git a/netsvcs/lib/Server_Logging_Handler_T.cpp b/netsvcs/lib/Server_Logging_Handler_T.cpp index c5e5e6fccde..8cf25bb25bb 100644 --- a/netsvcs/lib/Server_Logging_Handler_T.cpp +++ b/netsvcs/lib/Server_Logging_Handler_T.cpp @@ -1,5 +1,4 @@ // $Id$ -// Server_Logging_Handler.cpp #if !defined (ACE_SERVER_LOGGING_HANDLERT_C) #define ACE_SERVER_LOGGING_HANDLERT_C @@ -16,17 +15,17 @@ COUNTER ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ template <ACE_PEER_STREAM_1, class COUNTER, ACE_SYNCH_DECL, class LMR> -ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::ACE_Server_Logging_Handler_T +ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::ACE_Server_Logging_Handler_T (ACE_Thread_Manager *, - LMR const &receiver) + LMR const &receiver) // Initialize the CString to something that is not the empty string // to avoid problems when calling fast_rep() -#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) - : receiver_ (receiver, ACE_CString (" ", 1)) +#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) + : receiver_ (receiver, ACE_CString (" ", 1)) #else : receiver_ (receiver), - host_name_ (ACE_CString (" ", 1) -#endif /* ACE_HAS_BROKEN_HPUX_TEMPLATES */ + host_name_ (ACE_CString (" ", 1)) +#endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ { } @@ -42,12 +41,12 @@ ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::ha template <ACE_PEER_STREAM_1, class COUNTER, ACE_SYNCH_DECL, class LMR> const char * ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::host_name (void) -{ -#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) +{ +#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) return this->receiver_.m_.fast_rep (); #else return this->host_name_.fast_rep (); -#endif /* ACE_HAS_BROKEN_HPUX_TEMPLATES */ +#endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ } @@ -62,14 +61,14 @@ ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::ha // call. Note that this code is portable as long as ACE_UNIT32 is // always 32 bits on both the sender and receiver side. - switch (this->peer ().recv ((void *) &length, + switch (this->peer ().recv ((void *) &length, sizeof length, MSG_PEEK)) { default: case -1: ACE_ERROR_RETURN ((LM_ERROR, "%p at host %s\n", - "server logger", this->host_name ()), -1); + "server logger", this->host_name ()), -1); /* NOTREACHED */ case 0: ACE_ERROR_RETURN ((LM_ERROR, "closing log daemon at host %s\n", @@ -77,37 +76,37 @@ ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::ha /* NOTREACHED */ case sizeof length: { - ACE_Log_Record lp; - + ACE_Log_Record lp; + length = ntohl (length); #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) - u_long count = ++this->request_count_; - ACE_DEBUG ((LM_DEBUG, - "request count = %d, length = %d\n", + u_long count = ++this->request_count_; + ACE_DEBUG ((LM_DEBUG, + "request count = %d, length = %d\n", count, length)); #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ // Perform the actual <recv> this time. - ssize_t n = this->peer ().recv_n ((void *) &lp, length); + ssize_t n = this->peer ().recv_n ((void *) &lp, length); - if (n != length) - ACE_ERROR_RETURN ((LM_ERROR, + if (n != length) + ACE_ERROR_RETURN ((LM_ERROR, "%d != %d, %p at host %s\n", n, length, "server logger", this->host_name ()), -1); - /* NOTREACHED */ - - lp.decode (); + /* NOTREACHED */ + + lp.decode (); - if (lp.length () == n) + if (lp.length () == n) // Send the log record to the log message receiver for // processing. receiver ().log_record (this->host_name (), lp); - else - ACE_ERROR ((LM_ERROR, "error, lp.length = %d, n = %d\n", + else + ACE_ERROR ((LM_ERROR, "error, lp.length = %d, n = %d\n", lp.length (), n)); return n; } @@ -132,47 +131,47 @@ ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::op // Determine the address of the client and display it. if (this->peer ().get_remote_addr (client_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_remote_addr"), -1); - -#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) + +#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) this->receiver_.m_ = ACE_CString (client_addr.get_host_name (), - MAXHOSTNAMELEN + 1); + MAXHOSTNAMELEN + 1); #else this->host_name_ = ACE_CString (client_addr.get_host_name (), - MAXHOSTNAMELEN + 1); -#endif /* ACE_HAS_BROKEN_HPUX_TEMPLATES */ + MAXHOSTNAMELEN + 1); +#endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ ACE_DEBUG ((LM_DEBUG, "(%t) accepted connection from host %s on fd %d\n", - client_addr.get_host_name (), this->peer ().get_handle ())); + client_addr.get_host_name (), this->peer ().get_handle ())); return 0; } template<class SLH, class LMR, class SST> -ACE_Server_Logging_Acceptor_T<SLH, LMR, SST>::ACE_Server_Logging_Acceptor_T (void) -#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) +ACE_Server_Logging_Acceptor_T<SLH, LMR, SST>::ACE_Server_Logging_Acceptor_T (void) +#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) : receiver_ (LMR (), SST ()) #else : receiver_ (LMR ()), schedule_strategy_ (SST ()) -#endif /* ACE_HAS_BROKEN_HPUX_TEMPLATES */ +#endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ { } template<class SLH, class LMR, class SST> LMR & ACE_Server_Logging_Acceptor_T<SLH, LMR, SST>::receiver (void) -{ - return receiver_; +{ + return receiver_; } template<class SLH, class LMR, class SST> SST & ACE_Server_Logging_Acceptor_T<SLH, LMR, SST>::scheduling_strategy (void) -{ -#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) +{ +#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) return receiver_.m_; #else return schedule_strategy_; -#endif /* ACE_HAS_BROKEN_HPUX_TEMPLATES */ +#endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ } template<class SLH, class LMR, class SST> int @@ -186,14 +185,14 @@ ACE_Server_Logging_Acceptor_T<SLH, LMR, SST>::init (int argc, char *argv[]) // Set the acceptor endpoint into listen mode (use the Singleton // global Reactor...). - if (this->open (this->service_addr_, - ACE_Reactor::instance (), - 0, 0, 0, - &this->scheduling_strategy(), - "Logging Server", "ACE logging service") == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%n: %p on port %d\n", - "acceptor::open failed", - this->service_addr_.get_port_number ()), -1); + if (this->open (this->service_addr_, + ACE_Reactor::instance (), + 0, 0, 0, + &this->scheduling_strategy(), + "Logging Server", "ACE logging service") == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%n: %p on port %d\n", + "acceptor::open failed", + this->service_addr_.get_port_number ()), -1); // Ignore SIGPIPE so that each <SVC_HANDLER> can handle this on its // own. @@ -205,11 +204,11 @@ ACE_Server_Logging_Acceptor_T<SLH, LMR, SST>::init (int argc, char *argv[]) // Figure out what port we're really bound to. if (this->acceptor ().get_local_addr (server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "get_local_addr"), -1); - - ACE_DEBUG ((LM_DEBUG, - "starting up Logging Server at port %d on handle %d\n", - server_addr.get_port_number (), - this->acceptor ().get_handle ())); + + ACE_DEBUG ((LM_DEBUG, + "starting up Logging Server at port %d on handle %d\n", + server_addr.get_port_number (), + this->acceptor ().get_handle ())); return 0; } @@ -227,15 +226,15 @@ ACE_Server_Logging_Acceptor_T<SLH, LMR, SST>::parse_args (int argc, char *argv[] for (int c; (c = get_opt ()) != -1; ) { switch (c) - { - case 'p': - this->service_port_ = ACE_OS::atoi (get_opt.optarg); - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "%n:\n[-p server-port]\n%a", 1), - -1); - } + { + case 'p': + this->service_port_ = ACE_OS::atoi (get_opt.optarg); + break; + default: + ACE_ERROR_RETURN ((LM_ERROR, + "%n:\n[-p server-port]\n%a", 1), + -1); + } } this->service_addr_.set (this->service_port_); @@ -245,23 +244,23 @@ ACE_Server_Logging_Acceptor_T<SLH, LMR, SST>::parse_args (int argc, char *argv[] template<class SLH, class LMR, class SST> int ACE_Server_Logging_Acceptor_T<SLH, LMR, SST>::make_svc_handler (SLH *&handler) { - ACE_NEW_RETURN (handler, - SLH (ACE_Thread_Manager::instance (), - this->receiver()), - -1); + ACE_NEW_RETURN (handler, + SLH (ACE_Thread_Manager::instance (), + this->receiver()), + -1); return 0; } -template<class LMR> +template<class LMR> ACE_Server_Logging_Handler<LMR>::ACE_Server_Logging_Handler (ACE_Thread_Manager * tm, - LMR const& receiver) + LMR const& receiver) : ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, LMR>(tm, - receiver) + receiver) { } -template<class LMR> -ACE_Server_Logging_Handler<LMR>::ACE_Server_Logging_Handler(ACE_Thread_Manager * tm) +template<class LMR> +ACE_Server_Logging_Handler<LMR>::ACE_Server_Logging_Handler(ACE_Thread_Manager * tm) : ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, LMR>(tm, LMR()) { } @@ -275,13 +274,13 @@ ACE_Server_Logging_Handler<LMR>::open (void *) // Register ourselves with the Reactor to enable subsequent // dispatching. - if (ACE_Reactor::instance ()->register_handler + if (ACE_Reactor::instance ()->register_handler (this, ACE_Event_Handler::READ_MASK) == -1) return -1; return 0; } -template<class LMR> +template<class LMR> ACE_Thr_Server_Logging_Handler<LMR>::ACE_Thr_Server_Logging_Handler (ACE_Thread_Manager *tm, LMR const &receiver) : ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, ACE_LOGGER_COUNTER, ACE_LOGGER_SYNCH, LMR>(tm, receiver) { @@ -304,11 +303,11 @@ ACE_Thr_Server_Logging_Handler<LMR>::open (void *) // client. Note that this implicitly uses the // ACE_Thread_Manager::instance () to control all the threads. if (this->activate (THR_BOUND | THR_DETACHED) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); return 0; } -// Process remote logging records. +// Process remote logging records. template<class LMR> int ACE_Thr_Server_Logging_Handler<LMR>::svc (void) diff --git a/netsvcs/lib/Server_Logging_Handler_T.h b/netsvcs/lib/Server_Logging_Handler_T.h index caf905a7cba..dafd1cbac60 100644 --- a/netsvcs/lib/Server_Logging_Handler_T.h +++ b/netsvcs/lib/Server_Logging_Handler_T.h @@ -5,13 +5,13 @@ // // = LIBRARY // ace -// +// // = FILENAME -// Server_Logging_Handler_T.h +// Server_Logging_Handler_T.h // // = AUTHOR // Doug Schmidt and Per Andersson -// +// // ============================================================================ #if !defined (ACE_SERVER_LOGGING_HANDLER_T_H) @@ -22,11 +22,10 @@ #include "ace/SOCK_Acceptor.h" #include "ace/Acceptor.h" #include "ace/SString.h" -#include "Base_Optimizer.h" -#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) +#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) #include "Base_Optimizer.h" -#endif /* ACE_HAS_BROKEN_HPUX_TEMPLATES */ +#endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ template <ACE_PEER_STREAM_1, class COUNTER, ACE_SYNCH_DECL, class LOG_MESSAGE_RECEIVER> class ACE_Server_Logging_Handler_T : public ACE_Svc_Handler<ACE_PEER_STREAM_2, ACE_SYNCH_USE> @@ -34,20 +33,20 @@ class ACE_Server_Logging_Handler_T : public ACE_Svc_Handler<ACE_PEER_STREAM_2, A // = TITLE // Product object created by an <ACE_Server_Logging_Acceptor_T>. An // <ACE_Server_Logging_Handler_T> receives, and frames logging - // records. The logging record is then processed by the + // records. The logging record is then processed by the // <LOG_MESSAGE_RECEIVER> - // + // // = DESCRIPTION // Defines the classes that perform server logging daemon // functionality. -public: +public: ACE_Server_Logging_Handler_T (ACE_Thread_Manager *, - const LOG_MESSAGE_RECEIVER &receiver ); + const LOG_MESSAGE_RECEIVER &receiver ); // Constructor. virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); - // Process remote logging records. + // Process remote logging records. protected: int handle_logging_record (void); @@ -56,13 +55,13 @@ protected: int open_common (void); // Common parts of open function, sets hostname and diables NONBLOCK in peer // called from derived classes open method. - + #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) static COUNTER request_count_; // Count the number of logging records that arrive. #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ -#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) +#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) Base_Optimizer<LOG_MESSAGE_RECEIVER, ACE_CString> receiver_; // Packs a LOG_MESSAGE_RECEIVER and ACE_CString attribute together // in a optimized fashion. The LOG_MESSAGE_RECEIVER class is often @@ -70,10 +69,10 @@ protected: #else LOG_MESSAGE_RECEIVER receiver_; ACE_CString host_name_; -#endif /* ACE_HAS_BROKEN_HPUX_TEMPLATES */ +#endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ const char *host_name (void); // Name of the host we are connected to. - + LOG_MESSAGE_RECEIVER &receiver (void){ return receiver_; } // The receiver of log records }; @@ -98,31 +97,31 @@ class ACE_Server_Logging_Acceptor_T : public ACE_Strategy_Acceptor<SERVER_LOGGIN // easily be factored into the <ACE_Strategy_Acceptor>. { public: - ACE_Server_Logging_Acceptor_T (void); + ACE_Server_Logging_Acceptor_T (void); virtual int init (int argc, char *argv[]); // Dynamic linking hook. protected: int parse_args (int argc, char *argv[]); // Parse svc.conf arguments. - + virtual int make_svc_handler (SERVER_LOGGING_HANDLER *&); // Factory that creates a new <SERVER_LOGGING_HANDLER>. We need to // specialize this since the <LOG_MESSAGE_RECEIVER> held by this Acceptor must be - // passed into the <SERVER_LOGGING_HANDLER>. + // passed into the <SERVER_LOGGING_HANDLER>. private: // At the moment each ACE_Server_Logging_Acceptor_T contains // a <LOG_MESSAGE_RECEIVER> attribute that is passed to the - // <SERVER_LOGGING_HANDLER> at construction. A better idea might + // <SERVER_LOGGING_HANDLER> at construction. A better idea might // be to have accessor class as template argument. The accessor - // should be a factory/strategy that hands the + // should be a factory/strategy that hands the // ACE_Server_Logging_Acceptor_T instance references // to a <LOG_MESSAGE_RECEIVER>. This makes it possible // to change how <LOG_MESSAGE_RECEIVER> are created without chaning the // ACE_Server_Logging_Acceptor_T code. -#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) +#if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) Base_Optimizer<LOG_MESSAGE_RECEIVER, SCHEDULE_STRATEGY> receiver_; // Packs a LOG_MESSAGE_RECEIVER and ACE_CString attribute together // in a optimized fashion. The LOG_MESSAGE_RECEIVER class is often a @@ -130,21 +129,21 @@ private: #else LOG_MESSAGE_RECEIVER receiver_; SCHEDULE_STRATEGY schedule_strategy_; -#endif /* ACE_HAS_BROKEN_HPUX_TEMPLATES */ +#endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ SCHEDULE_STRATEGY &scheduling_strategy (void); // The scheduling strategy for the service. - + LOG_MESSAGE_RECEIVER &receiver (void); // The receiver of log records }; -template<class LOG_MESSAGE_RECEIVER> -class ACE_Server_Logging_Handler : public ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, LOG_MESSAGE_RECEIVER> +template<class LOG_MESSAGE_RECEIVER> +class ACE_Server_Logging_Handler : public ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, u_long, ACE_NULL_SYNCH, LOG_MESSAGE_RECEIVER> // = TITLE - // Product object created by a + // Product object created by a // <ACE_Server_Logging_Acceptor_T<ACE_Server_Logging_Handler> >. An - // <ACE_Server_Logging_Handler> receives, frames. The logging record + // <ACE_Server_Logging_Handler> receives, frames. The logging record // is then processed by the <LOG_MESSAGE_RECEIVER> // // = DESCRIPTION @@ -153,25 +152,25 @@ class ACE_Server_Logging_Handler : public ACE_Server_Logging_Handler_T<LOGGING_P public: ACE_Server_Logging_Handler (ACE_Thread_Manager * = 0); ACE_Server_Logging_Handler (ACE_Thread_Manager *, - const LOG_MESSAGE_RECEIVER &receiver); - + const LOG_MESSAGE_RECEIVER &receiver); + virtual int open (void* = 0); }; -#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_THREADS) typedef ACE_Atomic_Op <ACE_Thread_Mutex, u_long> ACE_LOGGER_COUNTER; -#define ACE_LOGGER_SYNCH ACE_MT_SYNCH +#define ACE_LOGGER_SYNCH ACE_MT_SYNCH #else typedef u_long ACE_LOGGER_COUNTER; -#define ACE_LOGGER_SYNCH ACE_NULL_SYNCH +#define ACE_LOGGER_SYNCH ACE_NULL_SYNCH #endif /* ACE_HAS_THREADS */ -template<class LOG_MESSAGE_RECEIVER> -class ACE_Thr_Server_Logging_Handler : public ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, ACE_LOGGER_COUNTER, ACE_LOGGER_SYNCH, LOG_MESSAGE_RECEIVER> +template<class LOG_MESSAGE_RECEIVER> +class ACE_Thr_Server_Logging_Handler : public ACE_Server_Logging_Handler_T<LOGGING_PEER_STREAM, ACE_LOGGER_COUNTER, ACE_LOGGER_SYNCH, LOG_MESSAGE_RECEIVER> // = TITLE - // Product object created by a + // Product object created by a // <ACE_Server_Logging_Acceptor_T<ACE_Thr_Server_Logging_Handler> >. An - // <ACE_Thr_Server_Logging_Handler> receives, frames. The logging record is then processed by the + // <ACE_Thr_Server_Logging_Handler> receives, frames. The logging record is then processed by the // <LOG_MESSAGE_RECEIVER> // // = DESCRIPTION @@ -180,7 +179,7 @@ class ACE_Thr_Server_Logging_Handler : public ACE_Server_Logging_Handler_T<LOGGI public: ACE_Thr_Server_Logging_Handler (ACE_Thread_Manager * = 0); ACE_Thr_Server_Logging_Handler (ACE_Thread_Manager *, - const LOG_MESSAGE_RECEIVER &receiver); + const LOG_MESSAGE_RECEIVER &receiver); virtual int open (void * = 0); virtual int svc (void); }; |