summaryrefslogtreecommitdiff
path: root/ace/FIFO_Recv_Msg.i
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2002-08-22 21:36:20 +0000
committerSteve Huston <shuston@riverace.com>2002-08-22 21:36:20 +0000
commit28b08af1f62222bf186f1a154ef0a8e7218891a0 (patch)
tree4d84d8ef233363408e5ebacc70913c1c8f8d5544 /ace/FIFO_Recv_Msg.i
parent6dddb6dd7c39aec6b37d9633081876b711e1c0bd (diff)
downloadATCD-28b08af1f62222bf186f1a154ef0a8e7218891a0.tar.gz
ChangeLogTag:Thu Aug 22 17:34:18 2002 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace/FIFO_Recv_Msg.i')
-rw-r--r--ace/FIFO_Recv_Msg.i39
1 files changed, 32 insertions, 7 deletions
diff --git a/ace/FIFO_Recv_Msg.i b/ace/FIFO_Recv_Msg.i
index e47c0beef3e..b3ada5c2b1b 100644
--- a/ace/FIFO_Recv_Msg.i
+++ b/ace/FIFO_Recv_Msg.i
@@ -3,10 +3,6 @@
// FIFO_Recv_Msg.i
-// Note that the return values mean different things if
-// ACE_HAS_STREAM_PIPES vs. if it doesn't... See the manual page on
-// getmsg(2) and read(2) for more details.
-
ASYS_INLINE ssize_t
ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf &recv_msg)
{
@@ -26,9 +22,38 @@ ACE_FIFO_Recv_Msg::recv (ACE_Str_Buf &recv_msg)
sizeof recv_msg.len) != sizeof recv_msg.len)
return -1;
else
- return ACE_OS::read (this->get_handle (),
- (char *) recv_msg.buf,
- (int) recv_msg.len);
+ {
+ size_t remaining = ACE_static_cast (size_t, recv_msg.len);
+ size_t requested = ACE_static_cast (size_t, recv_msg.maxlen);
+ ssize_t recv_len = ACE_OS::read (this->get_handle (),
+ (char *) recv_msg.buf,
+ ACE_MIN (remaining, requested));
+ if (recv_len == -1)
+ return -1;
+ // Tell caller what's really in the buffer.
+ recv_msg.len = ACE_static_cast (int, recv_len);
+
+ // If there are more bytes remaining in the message, read them and
+ // throw them away. Leaving them in the FIFO would make it difficult
+ // to find the start of the next message in the fifo.
+ // Since the ACE_HAS_STREAM_PIPES version of this method doesn't
+ // return getmsg()'s indication of "data remaining", don't worry about
+ // saving the indication here either to read the remainder later.
+ size_t total_msg_size = remaining;
+ remaining -= recv_len;
+ while (remaining > 0)
+ {
+ const size_t throw_away = 1024;
+ char dev_null[throw_away];
+ recv_len = ACE_OS::read (this->get_handle (),
+ dev_null,
+ ACE_MIN (remaining, throw_away));
+ if (recv_len == -1)
+ break;
+ remaining -= recv_len;
+ }
+ return total_msg_size;
+ }
#endif /* ACE_HAS_STREAM_PIPES */
}