summaryrefslogtreecommitdiff
path: root/ACE/netsvcs/lib
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2009-02-02 07:40:58 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2009-02-02 07:40:58 +0000
commitaa2ff175a23d851dd1b35b9c29eae5108cc254c8 (patch)
treea200ec67fb82dd3830a6fe79b81c637e16c3bc27 /ACE/netsvcs/lib
parent8935af1a871a6ed8882fb355c71aad9564b28665 (diff)
downloadATCD-aa2ff175a23d851dd1b35b9c29eae5108cc254c8.tar.gz
Mon Feb 2 07:40:17 UTC 2009 Johnny Willemsen <jwillemsen@remedy.nl>
* netsvcs/lib/Client_Logging_Handler.cpp: * netsvcs/lib/Server_Logging_Handler_T.cpp: Check return values of stream operators * netsvcs/lib/Client_Logging_Handler.h: Doxygen changes
Diffstat (limited to 'ACE/netsvcs/lib')
-rw-r--r--ACE/netsvcs/lib/Client_Logging_Handler.cpp36
-rw-r--r--ACE/netsvcs/lib/Client_Logging_Handler.h8
-rw-r--r--ACE/netsvcs/lib/Server_Logging_Handler_T.cpp12
3 files changed, 33 insertions, 23 deletions
diff --git a/ACE/netsvcs/lib/Client_Logging_Handler.cpp b/ACE/netsvcs/lib/Client_Logging_Handler.cpp
index ae37c10fecd..72835e0620f 100644
--- a/ACE/netsvcs/lib/Client_Logging_Handler.cpp
+++ b/ACE/netsvcs/lib/Client_Logging_Handler.cpp
@@ -200,20 +200,22 @@ ACE_Client_Logging_Handler::handle_input (ACE_HANDLE handle)
#endif /* ACE_HAS_STREAM_PIPES */
// Reflect addition of 8 bytes for the header.
- header->wr_ptr (8);
+ header->wr_ptr (8);
// Create a CDR stream to parse the 8-byte header.
ACE_InputCDR header_cdr (header.get ());
// Extract the byte-order and use helper methods to disambiguate
// octet, booleans, and chars.
- header_cdr >> ACE_InputCDR::to_boolean (byte_order);
+ if (!(header_cdr >> ACE_InputCDR::to_boolean (byte_order)))
+ return -1;
// Set the byte-order on the stream...
header_cdr.reset_byte_order (byte_order);
// Extract the length
- header_cdr >> length;
+ if (!(header_cdr >> length))
+ return -1;
ACE_NEW_RETURN (payload_p,
ACE_Message_Block (length),
@@ -274,11 +276,12 @@ ACE_Client_Logging_Handler::handle_input (ACE_HANDLE handle)
#endif /* ACE_HAS_STREAM_PIPES */
// Reflect additional bytes for the message.
- payload->wr_ptr (length);
+ payload->wr_ptr (length);
ACE_InputCDR payload_cdr (payload.get ());
payload_cdr.reset_byte_order (byte_order);
- payload_cdr >> log_record; // Finally extract the <ACE_log_record>.
+ if (!(payload_cdr >> log_record)) // Finally extract the <ACE_log_record>.
+ return -1;
log_record.length (length);
@@ -335,9 +338,11 @@ ACE_Client_Logging_Handler::send (ACE_Log_Record &log_record)
*orig_ostream);
if (this->logging_output_ == ACE_STDERR)
- log_record.print (ACE_TEXT ("<localhost>"),
- ACE_Log_Msg::instance ()->flags (),
- stderr);
+ {
+ log_record.print (ACE_TEXT ("<localhost>"),
+ ACE_Log_Msg::instance ()->flags (),
+ stderr);
+ }
else
{
// Serialize the log record using a CDR stream, allocate enough
@@ -352,18 +357,21 @@ ACE_Client_Logging_Handler::send (ACE_Log_Record &log_record)
// Insert contents of <log_record> into payload stream.
ACE_OutputCDR payload (max_payload_size);
- payload << log_record;
+ if (!(payload << log_record))
+ return -1;
// Get the number of bytes used by the CDR stream.
- ACE_CDR::ULong length = payload.total_length ();
+ ACE_CDR::ULong const length = payload.total_length ();
// Send a header so the receiver can determine the byte order and
// size of the incoming CDR stream.
ACE_OutputCDR header (ACE_CDR::MAX_ALIGNMENT + 8);
- header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER);
+ if (!(header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER)))
+ return -1;
// Store the size of the payload that follows
- header << ACE_CDR::ULong (length);
+ if (!(header << ACE_CDR::ULong (length)))
+ return -1;
// Use an iovec to send both buffer and payload simultaneously.
iovec iov[2];
@@ -376,7 +384,7 @@ ACE_Client_Logging_Handler::send (ACE_Log_Record &log_record)
// efficiently using "gather-write".
if (ACE::sendv_n (this->logging_output_,iov, 2) == -1)
{
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
"Something about the sendv_n() failed, so switch to stderr\n"));
if (ACE_Log_Msg::instance ()->msg_ostream () == 0)
@@ -453,7 +461,7 @@ private:
ACE_Client_Logging_Handler *handler_;
// Pointer to the singleton handler that receives messages from
- // clients and forwards to the server.
+ // clients and forwards to the server.
};
int
diff --git a/ACE/netsvcs/lib/Client_Logging_Handler.h b/ACE/netsvcs/lib/Client_Logging_Handler.h
index 20b593c2168..912c2231f50 100644
--- a/ACE/netsvcs/lib/Client_Logging_Handler.h
+++ b/ACE/netsvcs/lib/Client_Logging_Handler.h
@@ -57,17 +57,17 @@ class ACE_Svc_Export ACE_Client_Logging_Handler : public ACE_Svc_Handler<LOGGING
public:
// = Initialization and termination.
- /// Default constructor. <handle> is where the output is sent.
+ /// Default constructor. @a handle is where the output is sent.
ACE_Client_Logging_Handler (ACE_HANDLE handle = ACE_STDERR);
- /// Activate this instance of the <ACE_Client_Logging_Handler>
+ /// Activate this instance of the ACE_Client_Logging_Handler
/// (called by the <ACE_Client_Logging_Acceptor>).
virtual int open (void * = 0);
/// Return the handle of the IPC endpoint.
virtual ACE_HANDLE get_handle (void) const;
- /// Called when object is removed from the <ACE_Reactor>.
+ /// Called when object is removed from the ACE_Reactor.
virtual int close (u_long);
private:
@@ -90,7 +90,7 @@ private:
/// Called back when it's ok to send.
virtual int handle_output (ACE_HANDLE);
- /// Send the <log_record> to the logging server.
+ /// Send the @a log_record to the logging server.
int send (ACE_Log_Record &log_record);
/// This is either a SOCKET (if we're connected to a logging server)
diff --git a/ACE/netsvcs/lib/Server_Logging_Handler_T.cpp b/ACE/netsvcs/lib/Server_Logging_Handler_T.cpp
index 1938c39e552..d67b800552c 100644
--- a/ACE/netsvcs/lib/Server_Logging_Handler_T.cpp
+++ b/ACE/netsvcs/lib/Server_Logging_Handler_T.cpp
@@ -78,7 +78,7 @@ ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::ha
ACE_CDR::Boolean byte_order;
ACE_CDR::ULong length;
- ssize_t count = ACE::recv_n (this->peer ().get_handle (),
+ ssize_t count = ACE::recv_n (this->peer ().get_handle (),
header->wr_ptr (),
8);
switch (count)
@@ -107,14 +107,16 @@ ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::ha
// Extract the byte-order and use helper methods to disambiguate
// octet, booleans, and chars.
- header_cdr >> ACE_InputCDR::to_boolean (byte_order);
+ if (!(header_cdr >> ACE_InputCDR::to_boolean (byte_order)))
+ return -1;
// Set the byte-order on the stream...
header_cdr.reset_byte_order (byte_order);
// Extract the length
- header_cdr >> length;
-
+ if (!(header_cdr >> length))
+ return -1;
+
ACE_NEW_RETURN (payload_p,
ACE_Message_Block (length),
-1);
@@ -126,7 +128,7 @@ ACE_Server_Logging_Handler_T<ACE_PEER_STREAM_2, COUNTER, ACE_SYNCH_USE, LMR>::ha
// Use <recv_n> to obtain the contents.
if (ACE::recv_n (this->peer ().get_handle (),
payload->wr_ptr (),
- length) <= 0)
+ length) <= 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),