}
center->delete_file_event(sd, EVENT_WRITABLE);
+ net.set_priority(sd, async_msgr->get_socket_priority());
ldout(async_msgr->cct, 10) << __func__ << " connect successfully, ready to send banner" << dendl;
bufferlist bl;
goto fail;
net.set_socket_options(sd);
+ net.set_priority(sd, async_msgr->get_socket_priority());
bl.append(CEPH_BANNER, strlen(CEPH_BANNER));
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#endif
}
+void NetHandler::set_priority(int sd, int prio)
+{
+ if (prio >= 0) {
+ int r = -1;
+#ifdef IPTOS_CLASS_CS6
+ int iptos = IPTOS_CLASS_CS6;
+ r = ::setsockopt(sd, IPPROTO_IP, IP_TOS, &iptos, sizeof(iptos));
+ if (r < 0) {
+ ldout(cct, 0) << __func__ << " couldn't set IP_TOS to " << iptos
+ << ": " << cpp_strerror(errno) << dendl;
+ }
+#endif
+#if defined(SO_PRIORITY)
+ // setsockopt(IPTOS_CLASS_CS6) sets the priority of the socket as 0.
+ // See http://goo.gl/QWhvsD and http://goo.gl/laTbjT
+ // We need to call setsockopt(SO_PRIORITY) after it.
+#if defined(__linux__)
+ r = ::setsockopt(sd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio));
+#endif
+ if (r < 0) {
+ ldout(cct, 0) << __func__ << " couldn't set SO_PRIORITY to " << prio
+ << ": " << cpp_strerror(errno) << dendl;
+ }
+#endif
+ }
+}
+
int NetHandler::generic_connect(const entity_addr_t& addr, bool nonblock)
{
int ret;
*/
int reconnect(const entity_addr_t &addr, int sd);
int nonblock_connect(const entity_addr_t &addr);
+ void set_priority(int sd, int priority);
};
}