]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async: refactor NetHandler::set_priority() to sync with msg/simple
authorKefu Chai <kchai@redhat.com>
Sat, 29 Apr 2017 05:26:36 +0000 (13:26 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 29 Apr 2017 05:38:57 +0000 (13:38 +0800)
so it's sync'ed with Pipe::set_socket_options()

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/msg/async/net_handler.cc

index d43e6a45a01bfecaa72b207e60438efe040953ab..5a138d9a5b6599740fb24f07146c26177a0ddd9c 100644 (file)
@@ -132,25 +132,24 @@ void NetHandler::set_priority(int sd, int prio, int domain)
 #ifdef IPTOS_CLASS_CS6
   int iptos = IPTOS_CLASS_CS6;
   int r = -1;
-  if (domain == AF_INET) {
+  switch (domain) {
+  case AF_INET:
     r = ::setsockopt(sd, IPPROTO_IP, IP_TOS, &iptos, sizeof(iptos));
-    if (r < 0) {
-      r = errno;
-      ldout(cct,0) << "couldn't set IP_TOS to " << iptos
-                  << ": " << cpp_strerror(r) << dendl;
-    }
-  } else if (domain == AF_INET6) {
+    break;
+  case AF_INET6:
     r = ::setsockopt(sd, IPPROTO_IPV6, IPV6_TCLASS, &iptos, sizeof(iptos));
-    if (r < 0) {
-      r = errno;
-      ldout(cct,0) << "couldn't set IPV6_TCLASS to " << iptos
-                  << ": " << cpp_strerror(r) << dendl;
-    }
-  } else {
+    break;
+  default:
     lderr(cct) << "couldn't set ToS of unknown family (" << domain << ")"
               << " to " << iptos << dendl;
     return;
   }
+  if (r < 0) {
+    r = errno;
+    ldout(cct,0) << "couldn't set TOS to " << iptos
+                << ": " << cpp_strerror(r) << dendl;
+  }
+
 #endif // IPTOS_CLASS_CS6
   // setsockopt(IPTOS_CLASS_CS6) sets the priority of the socket as 0.
   // See http://goo.gl/QWhvsD and http://goo.gl/laTbjT