You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by mp...@apache.org on 2017/11/09 08:36:30 UTC

[2/2] kudu git commit: [blocking_ops] remove extra Socket::IsNonBlocking call

[blocking_ops] remove extra Socket::IsNonBlocking call

Removed duplicate call to Socket::IsNonBlocking() from
rpc::SendFramedMessageBlocking().

Change-Id: Iaafe3f2de33f42bad87bbfe7e3ad2ca14cab82d0
Reviewed-on: http://gerrit.cloudera.org:8080/8454
Tested-by: Alexey Serbin <as...@cloudera.com>
Reviewed-by: Mike Percy <mp...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/0ca288b9
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/0ca288b9
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/0ca288b9

Branch: refs/heads/master
Commit: 0ca288b917c64207e9e81dd8764f4cb3f0d147c0
Parents: d3bde5d
Author: Alexey Serbin <as...@cloudera.com>
Authored: Thu Nov 2 21:30:33 2017 -0700
Committer: Mike Percy <mp...@apache.org>
Committed: Thu Nov 9 08:34:49 2017 +0000

----------------------------------------------------------------------
 src/kudu/rpc/blocking_ops.cc       | 14 ++++++--------
 src/kudu/rpc/blocking_ops.h        |  2 +-
 src/kudu/rpc/client_negotiation.cc |  2 +-
 src/kudu/rpc/server_negotiation.cc |  2 +-
 4 files changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/0ca288b9/src/kudu/rpc/blocking_ops.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/blocking_ops.cc b/src/kudu/rpc/blocking_ops.cc
index e676e94..f5cd644 100644
--- a/src/kudu/rpc/blocking_ops.cc
+++ b/src/kudu/rpc/blocking_ops.cc
@@ -42,11 +42,13 @@ using google::protobuf::MessageLite;
 
 const char kHTTPHeader[] = "HTTP";
 
-Status EnsureBlockingMode(const Socket* sock) {
+Status CheckInBlockingMode(const Socket* sock) {
   bool is_nonblocking;
   RETURN_NOT_OK(sock->IsNonBlocking(&is_nonblocking));
   if (is_nonblocking) {
-    return Status::IllegalState("Underlying socket is not set to blocking mode!");
+    static const char* const kErrMsg = "socket is not in blocking mode";
+    LOG(DFATAL) << kErrMsg;
+    return Status::IllegalState(kErrMsg);
   }
   return Status::OK();
 }
@@ -57,13 +59,9 @@ Status SendFramedMessageBlocking(Socket* sock, const MessageLite& header, const
   DCHECK(header.IsInitialized()) << "header protobuf must be initialized";
   DCHECK(msg.IsInitialized()) << "msg protobuf must be initialized";
 
-  RETURN_NOT_OK(EnsureBlockingMode(sock));
-
   // Ensure we are in blocking mode.
   // These blocking calls are typically not in the fast path, so doing this for all build types.
-  bool is_non_blocking = false;
-  RETURN_NOT_OK(sock->IsNonBlocking(&is_non_blocking));
-  DCHECK(!is_non_blocking) << "Socket must be in blocking mode to use SendFramedMessage";
+  RETURN_NOT_OK(CheckInBlockingMode(sock));
 
   // Serialize message
   faststring param_buf;
@@ -88,7 +86,7 @@ Status ReceiveFramedMessageBlocking(Socket* sock, faststring* recv_buf,
   DCHECK(header != nullptr);
   DCHECK(param_buf != nullptr);
 
-  RETURN_NOT_OK(EnsureBlockingMode(sock));
+  RETURN_NOT_OK(CheckInBlockingMode(sock));
 
   // Read the message prefix, which specifies the length of the payload.
   recv_buf->clear();

http://git-wip-us.apache.org/repos/asf/kudu/blob/0ca288b9/src/kudu/rpc/blocking_ops.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/blocking_ops.h b/src/kudu/rpc/blocking_ops.h
index 900f9df..b305ba7 100644
--- a/src/kudu/rpc/blocking_ops.h
+++ b/src/kudu/rpc/blocking_ops.h
@@ -35,7 +35,7 @@ class Status;
 namespace rpc {
 
 // Returns OK if socket is in blocking mode. Otherwise, returns an error.
-Status EnsureBlockingMode(const Socket* sock);
+Status CheckInBlockingMode(const Socket* sock);
 
 // Encode and send a message over a socket.
 // header: Request or Response header protobuf.

http://git-wip-us.apache.org/repos/asf/kudu/blob/0ca288b9/src/kudu/rpc/client_negotiation.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/client_negotiation.cc b/src/kudu/rpc/client_negotiation.cc
index de69c62..0a4a372 100644
--- a/src/kudu/rpc/client_negotiation.cc
+++ b/src/kudu/rpc/client_negotiation.cc
@@ -158,7 +158,7 @@ Status ClientNegotiation::Negotiate(unique_ptr<ErrorStatusPB>* rpc_error) {
   TRACE("Beginning negotiation");
 
   // Ensure we can use blocking calls on the socket during negotiation.
-  RETURN_NOT_OK(EnsureBlockingMode(socket_.get()));
+  RETURN_NOT_OK(CheckInBlockingMode(socket_.get()));
 
   // Step 1: send the connection header.
   RETURN_NOT_OK(SendConnectionHeader());

http://git-wip-us.apache.org/repos/asf/kudu/blob/0ca288b9/src/kudu/rpc/server_negotiation.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/server_negotiation.cc b/src/kudu/rpc/server_negotiation.cc
index 6e87fb6..231a6fe 100644
--- a/src/kudu/rpc/server_negotiation.cc
+++ b/src/kudu/rpc/server_negotiation.cc
@@ -183,7 +183,7 @@ Status ServerNegotiation::Negotiate() {
   DCHECK(token_verifier_);
 
   // Ensure we can use blocking calls on the socket during negotiation.
-  RETURN_NOT_OK(EnsureBlockingMode(socket_.get()));
+  RETURN_NOT_OK(CheckInBlockingMode(socket_.get()));
 
   faststring recv_buf;