diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-12-04 07:46:34 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-12-04 07:46:34 +0000 |
commit | 0f5489223d4a5ed4c027516a6e18c9024a7dfcad (patch) | |
tree | d6db6c12219f51d10aaea5f6db95e8a18cc75108 /netsvcs | |
parent | a744bcb9a499eb3bac37b863bb98233a83281bc0 (diff) | |
download | ATCD-0f5489223d4a5ed4c027516a6e18c9024a7dfcad.tar.gz |
*** empty log message ***
Diffstat (limited to 'netsvcs')
-rw-r--r-- | netsvcs/clients/Logger/direct_logging.cpp | 7 | ||||
-rw-r--r-- | netsvcs/clients/Logger/indirect_logging.cpp | 4 | ||||
-rw-r--r-- | netsvcs/lib/Client_Logging_Handler.cpp | 20 | ||||
-rw-r--r-- | netsvcs/lib/Client_Logging_Handler.h | 4 | ||||
-rw-r--r-- | netsvcs/lib/Server_Logging_Handler_T.cpp | 63 |
5 files changed, 49 insertions, 49 deletions
diff --git a/netsvcs/clients/Logger/direct_logging.cpp b/netsvcs/clients/Logger/direct_logging.cpp index fb4311ad3bc..1c0cc6e3f8a 100644 --- a/netsvcs/clients/Logger/direct_logging.cpp +++ b/netsvcs/clients/Logger/direct_logging.cpp @@ -1,6 +1,6 @@ -// This program sends logging records directly to the server, rather // $Id$ +// This program sends logging records directly to the server, rather // than going through the client logging daemon. #include "ace/SOCK_Connector.h" @@ -29,12 +29,9 @@ main (int argc, char *argv[]) log_record.msg_data (DATA); size_t len = log_record.length (); - size_t encoded_len = htonl (len); - log_record.encode (); - if (logger.send (4, &encoded_len, sizeof encoded_len, - (char *) &log_record, len) == -1) + if (logger.send ((char *) &log_record, len) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "send"), -1); else if (logger.close () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "close"), -1); diff --git a/netsvcs/clients/Logger/indirect_logging.cpp b/netsvcs/clients/Logger/indirect_logging.cpp index 7b3aa03afbb..3a3183d3c12 100644 --- a/netsvcs/clients/Logger/indirect_logging.cpp +++ b/netsvcs/clients/Logger/indirect_logging.cpp @@ -11,8 +11,8 @@ int main (int argc, char *argv[]) { const char *prog_name = argv[0]; - int iterations = argc < 2 ? 10 : ACE_OS::atoi (argv[1]); - const char *logger_key = argc < 3 ? ACE_DEFAULT_RENDEZVOUS : argv[2]; + int iterations = argc < 2 ? 10 : ACE_OS::atoi (argv[1]); + const char *logger_key = argc < 3 ? ACE_DEFAULT_LOGGING_KEY : argv[2]; ACE_OS::srand ((u_int) ACE_OS::time (0)); diff --git a/netsvcs/lib/Client_Logging_Handler.cpp b/netsvcs/lib/Client_Logging_Handler.cpp index 33c659f37c9..9ed9f983aa6 100644 --- a/netsvcs/lib/Client_Logging_Handler.cpp +++ b/netsvcs/lib/Client_Logging_Handler.cpp @@ -109,12 +109,13 @@ ACE_Client_Logging_Handler::handle_input (ACE_HANDLE handle) return 0; } #else - long length; + ACE_INT32 length; // We need to use the ol' two-read trick here since TCP sockets // don't support framing natively. Note that the first call is just // a "peek" -- we don't actually remove the data until the second - // call. + // call. Note that this code is portable as long as ACE_UNIT32 is + // always 32 bits on both the sender and receiver side. switch (ACE_OS::recv (handle, (char *) &length, @@ -194,14 +195,9 @@ ACE_Client_Logging_Handler::send (ACE_Log_Record &log_record) else { long len = log_record.length (); - ACE_INT32 encoded_len = htonl (len); - log_record.encode (); if (ACE::send (this->logging_output_, - 4, - &encoded_len, - sizeof encoded_len, (char *) &log_record, len) == -1) // Switch over to logging to stdout for now. Eventually, @@ -260,7 +256,7 @@ private: ACE_INET_Addr server_addr_; // Address of the logging server. - const char *rendezvous_key_; + const char *logger_key_; // Communication endpoint where the client logging daemon will // listen for connections from clients. @@ -305,7 +301,7 @@ ACE_Client_Logging_Acceptor::info (char **strp, size_t length) const ACE_Client_Logging_Acceptor::ACE_Client_Logging_Acceptor (void) : server_host_ (ACE_DEFAULT_SERVER_HOST), server_port_ (ACE_DEFAULT_LOGGING_SERVER_PORT), - rendezvous_key_ (DEFAULT_RENDEZVOUS), + logger_key_ (DEFAULT_LOGGER_KEY), handler_ (0) { } @@ -321,8 +317,8 @@ ACE_Client_Logging_Acceptor::init (int argc, char *argv[]) this->parse_args (argc, argv); // Initialize the acceptor endpoint. - if (this->open (LOGGING_ADDR (this->rendezvous_key_)) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", this->rendezvous_key_), -1); + if (this->open (LOGGING_ADDR (this->logger_key_)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", this->logger_key_), -1); // Establish connection with the server. ACE_SOCK_Connector con; @@ -371,7 +367,7 @@ ACE_Client_Logging_Acceptor::parse_args (int argc, char *argv[]) this->server_host_ = get_opt.optarg; break; case 'k': - this->rendezvous_key_ = get_opt.optarg; + this->logger_key_ = get_opt.optarg; break; case 'p': this->server_port_ = ACE_OS::atoi (get_opt.optarg); diff --git a/netsvcs/lib/Client_Logging_Handler.h b/netsvcs/lib/Client_Logging_Handler.h index 443f389bdc3..35921993787 100644 --- a/netsvcs/lib/Client_Logging_Handler.h +++ b/netsvcs/lib/Client_Logging_Handler.h @@ -23,12 +23,12 @@ #include "ace/Synch.h" #if defined (ACE_HAS_STREAM_PIPES) -#define DEFAULT_RENDEZVOUS ACE_DEFAULT_RENDEZVOUS +#define DEFAULT_LOGGER_KEY ACE_DEFAULT_LOGGER_KEY #define LOGGING_STREAM ACE_SPIPE_STREAM #define LOGGING_ACCEPTOR ACE_SPIPE_ACCEPTOR #define LOGGING_ADDR ACE_SPIPE_Addr #else -#define DEFAULT_RENDEZVOUS "10012" +#define DEFAULT_LOGGER_KEY "10012" #define LOGGING_STREAM ACE_SOCK_STREAM #define LOGGING_ACCEPTOR ACE_SOCK_ACCEPTOR #define LOGGING_ADDR ACE_INET_Addr diff --git a/netsvcs/lib/Server_Logging_Handler_T.cpp b/netsvcs/lib/Server_Logging_Handler_T.cpp index 566eaef1f69..c5e5e6fccde 100644 --- a/netsvcs/lib/Server_Logging_Handler_T.cpp +++ b/netsvcs/lib/Server_Logging_Handler_T.cpp @@ -54,60 +54,67 @@ ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::ho template <ACE_PEER_STREAM_1, class COUNTER, ACE_SYNCH_DECL, class LMR> int ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::handle_logging_record (void) { - ACE_INT32 len; + ACE_INT32 length; - // Perform two recv's to emulate record-oriented semantics. Note - // that this code is portable as long as ACE_UNIT32 is always 32 - // bits on both the sender and receiver side. + // We need to use the ol' two-read trick here since TCP sockets + // don't support framing natively. Note that the first call is just + // a "peek" -- we don't actually remove the data until the second + // call. Note that this code is portable as long as ACE_UNIT32 is + // always 32 bits on both the sender and receiver side. - ssize_t n = this->peer ().recv ((void *) &len, sizeof len); - - switch (n) + 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", - this->host_name ()), -1); + this->host_name ()), -1); /* NOTREACHED */ - case sizeof (ACE_INT32): + case sizeof length: { 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\n", count)); + ACE_DEBUG ((LM_DEBUG, + "request count = %d, length = %d\n", + count, length)); #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ - len = ntohl (len); - n = this->peer ().recv_n ((void *) &lp, len); - if (n != len) - ACE_ERROR_RETURN ((LM_ERROR, "len = %d, %p at host %s\n", - n, "server logger", this->host_name ()), -1); + // Perform the actual <recv> this time. + ssize_t n = this->peer ().recv_n ((void *) &lp, length); + + 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 (); if (lp.length () == n) - { - receiver().log_record(this->host_name (), lp); - // Send the log record to the log message receiver for - // processing. - } + // 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", - lp.length (), n)); - break; + lp.length (), n)); + return n; } - default: - ACE_ERROR_RETURN ((LM_ERROR, "%p at host %s\n", - "server logger", this->host_name ()), -1); - /* NOTREACHED */ } - return n; + /* NOTREACHED */ + return -1; } // Hook called by Server_Logging_Acceptor when connection is |