]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: throw read_eof if short read 39592/head
authorKefu Chai <kchai@redhat.com>
Sat, 20 Feb 2021 08:49:19 +0000 (16:49 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 20 Feb 2021 09:03:54 +0000 (17:03 +0800)
as per the implementation and the document of input_stream::read_exactly():

/// stream and returns them. If the end of stream is reached before n
/// bytes were read, fewer than n bytes will be returned - so despite
/// the method's name, the caller must not assume the returned buffer
/// will always contain exactly n bytes.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/net/Socket.cc

index 8ad106dbdd7e22525d8485603cbe1af9f13b7e0f..990c191a250dbc09dbb4d1f87e16e84d29520452 100644 (file)
@@ -92,8 +92,8 @@ Socket::read_exactly(size_t bytes) {
     if (bytes == 0) {
       return seastar::make_ready_future<seastar::temporary_buffer<char>>();
     }
-    return in.read_exactly(bytes).then([](auto buf) {
-      if (buf.empty()) {
+    return in.read_exactly(bytes).then([bytes](auto buf) {
+      if (buf.size() < bytes) {
         throw std::system_error(make_error_code(error::read_eof));
       }
       return seastar::make_ready_future<tmp_buf>(std::move(buf));