summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2001-10-04 17:36:13 +0000
committerSteve Huston <shuston@riverace.com>2001-10-04 17:36:13 +0000
commit2277f50c7aafa222aa85884c1390fa3ef6888f9e (patch)
tree9528f690de571838a2d3adf759b84d352a5ff384
parent5e558b6c8798adbfd968146d90a9aac773eef228 (diff)
downloadATCD-2277f50c7aafa222aa85884c1390fa3ef6888f9e.tar.gz
ChangeLogTag:Thu Oct 4 13:18:37 2001 Steve Huston <shuston@riverace.com>
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLogs/ChangeLog-02a5
-rw-r--r--ChangeLogs/ChangeLog-03a5
-rw-r--r--examples/C++NPv1/Logging_Handler.cpp25
4 files changed, 29 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 6a7dd018111..6d28da2a81e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Oct 4 13:18:37 2001 Steve Huston <shuston@riverace.com>
+
+ * examples/C++NPv1/Logging_Handler.cpp: Use a ACE_Message_Block,
+ rather than hijacking a CDR block, to read the payload into.
+
Thu Oct 4 10:14:34 2001 Balachandran Natarajan <bala@cs.wustl.edu>
* THANKS: Added Donald Acton to the Hall of Fame.
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 6a7dd018111..6d28da2a81e 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,8 @@
+Thu Oct 4 13:18:37 2001 Steve Huston <shuston@riverace.com>
+
+ * examples/C++NPv1/Logging_Handler.cpp: Use a ACE_Message_Block,
+ rather than hijacking a CDR block, to read the payload into.
+
Thu Oct 4 10:14:34 2001 Balachandran Natarajan <bala@cs.wustl.edu>
* THANKS: Added Donald Acton to the Hall of Fame.
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 6a7dd018111..6d28da2a81e 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,8 @@
+Thu Oct 4 13:18:37 2001 Steve Huston <shuston@riverace.com>
+
+ * examples/C++NPv1/Logging_Handler.cpp: Use a ACE_Message_Block,
+ rather than hijacking a CDR block, to read the payload into.
+
Thu Oct 4 10:14:34 2001 Balachandran Natarajan <bala@cs.wustl.edu>
* THANKS: Added Donald Acton to the Hall of Fame.
diff --git a/examples/C++NPv1/Logging_Handler.cpp b/examples/C++NPv1/Logging_Handler.cpp
index c3659b2767f..cd4c8c4bdd8 100644
--- a/examples/C++NPv1/Logging_Handler.cpp
+++ b/examples/C++NPv1/Logging_Handler.cpp
@@ -44,9 +44,13 @@ int Logging_Handler::recv_log_record (ACE_Message_Block *&mblk)
peer_addr.get_host_name (mblk->wr_ptr (), MAXHOSTNAMELEN);
mblk->wr_ptr (strlen (mblk->wr_ptr ()) + 1); // Go past name
- // Create a CDR stream to parse the 8-byte header.
- ACE_InputCDR cdr (8);
- if (logging_peer_.recv_n (cdr.rd_ptr (), 8, MSG_PEEK) == 8) {
+ ACE_Message_Block *payload = new ACE_Message_Block (8);
+ if (logging_peer_.recv_n (payload->wr_ptr (), 8) == 8) {
+ payload->wr_ptr (8); // Reflect addition of 8 bytes
+
+ // Create a CDR stream to parse the 8-byte header.
+ ACE_InputCDR cdr (payload);
+
// Extract the byte-order and use helper methods to
// disambiguate octet, booleans, and chars.
ACE_CDR::Boolean byte_order;
@@ -60,21 +64,20 @@ int Logging_Handler::recv_log_record (ACE_Message_Block *&mblk)
cdr >> length;
// Ensure there's sufficient room for log record payload.
- // After grow(), the original 8 bytes are gone, but since
- // we only peeked at them, they'll get re-read.
- length += 8;
- cdr.grow (length);
+ payload->size (length + 8);
// Use <recv_n> to obtain the contents.
- if (logging_peer_.recv_n (cdr.rd_ptr (), length) > 0) {
- // Obtain the message block underlying the CDR stream and
- // chain it via the contination field.
- mblk->cont (cdr.steal_contents ());
+ if (logging_peer_.recv_n (payload->wr_ptr (), length) > 0) {
+ payload->wr_ptr (length); // Reflect additional bytes
+ // Chain the payload to mblk via the contination field.
+ mblk->cont (payload);
return length;
}
}
// Error cases end up here, so we need to release the memory to
// prevent a leak.
+ payload->release ();
+ payload = 0;
mblk->release ();
mblk = 0;
return -1;