You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by wh...@apache.org on 2015/10/07 09:20:21 UTC

[55/56] [abbrv] hadoop git commit: HDFS-9108. InputStreamImpl::ReadBlockContinuation stores wrong pointers of buffers. Contributed by Haohui Mai.

HDFS-9108. InputStreamImpl::ReadBlockContinuation stores wrong pointers of buffers. Contributed by Haohui Mai.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/89156eb5
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/89156eb5
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/89156eb5

Branch: refs/heads/HDFS-8707
Commit: 89156eb57a8525f912bedf9d5452767d990bc16b
Parents: 3bdf6e4
Author: Haohui Mai <wh...@apache.org>
Authored: Mon Sep 21 16:13:53 2015 -0700
Committer: Haohui Mai <wh...@apache.org>
Committed: Wed Oct 7 00:17:14 2015 -0700

----------------------------------------------------------------------
 .../main/native/libhdfspp/lib/fs/inputstream_impl.h   | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/89156eb5/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/lib/fs/inputstream_impl.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/lib/fs/inputstream_impl.h b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/lib/fs/inputstream_impl.h
index ca5ac38..2044f3f 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/lib/fs/inputstream_impl.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/lib/fs/inputstream_impl.h
@@ -25,6 +25,7 @@
 
 #include <functional>
 #include <future>
+#include <type_traits>
 
 namespace hdfs {
 
@@ -91,7 +92,10 @@ struct InputStreamImpl::ReadBlockContinuation : continuation::Continuation {
   ReadBlockContinuation(Reader *reader, MutableBufferSequence buffer,
                         size_t *transferred)
       : reader_(reader), buffer_(buffer),
-        buffer_size_(asio::buffer_size(buffer)), transferred_(transferred) {}
+        buffer_size_(asio::buffer_size(buffer)), transferred_(transferred) {
+    static_assert(!std::is_reference<MutableBufferSequence>::value,
+                  "Buffer must not be a reference type");
+  }
 
   virtual void Run(const Next &next) override {
     *transferred_ = 0;
@@ -101,7 +105,7 @@ struct InputStreamImpl::ReadBlockContinuation : continuation::Continuation {
 
 private:
   Reader *reader_;
-  MutableBufferSequence buffer_;
+  const MutableBufferSequence buffer_;
   const size_t buffer_size_;
   size_t *transferred_;
   std::function<void(const Status &)> next_;
@@ -176,12 +180,12 @@ void InputStreamImpl::AsyncReadBlock(
   size_t size = asio::buffer_size(buffers);
   m->Push(new HandshakeContinuation<Reader>(s.reader(), client_name, nullptr,
                                             &block.b(), size, offset))
-      .Push(new ReadBlockContinuation<Reader, decltype(buffers)>(
+      .Push(new ReadBlockContinuation<Reader, MutableBufferSequence>(
           s.reader(), buffers, s.transferred()));
   const std::string &dnid = dn.id().datanodeuuid();
   m->Run([handler, dnid](const Status &status,
-                   const typename BlockReaderTrait::State &state) {
-           handler(status, dnid, *state.transferred());
+                         const typename BlockReaderTrait::State &state) {
+    handler(status, dnid, *state.transferred());
   });
 }
 }