From: Dennis Schafroth Date: Tue, 30 Jun 2015 17:47:24 +0000 (+0200) Subject: msg/simple: Move MSG_ and SO_NOSIGPIPE into porting.h X-Git-Tag: v9.1.0~259^2~50 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7e1d83bb4d4b658ee93466d8382feb1c41ed4cc6;p=ceph.git msg/simple: Move MSG_ and SO_NOSIGPIPE into porting.h Only enable SO_PRIORITY on Linux Signed-off-by: Dennis Schafroth --- diff --git a/src/msg/simple/Pipe.cc b/src/msg/simple/Pipe.cc index a9b3b54e870..42995840d45 100644 --- a/src/msg/simple/Pipe.cc +++ b/src/msg/simple/Pipe.cc @@ -32,6 +32,8 @@ #include "auth/cephx/CephxProtocol.h" #include "auth/AuthSessionHandler.h" +#include "porting.h" + // Constant to limit starting sequence number to 2^31. Nothing special about it, just a big number. PLR #define SEQ_MASK 0x7fffffff #define dout_subsys ceph_subsys_ms @@ -53,26 +55,6 @@ ostream& operator<<(ostream &out, const Pipe &pipe) { return pipe._pipe_prefix(out); } -/* - * This optimization may not be available on all platforms (e.g. OSX). - * Apparently a similar approach based on TCP_CORK can be used. - */ -#ifndef MSG_MORE -# define MSG_MORE 0 -#endif - -/* - * On BSD SO_NOSIGPIPE can be set via setsockopt to block SIGPIPE. - */ -#ifndef MSG_NOSIGNAL -# define MSG_NOSIGNAL 0 -# ifdef SO_NOSIGPIPE -# define CEPH_USE_SO_NOSIGPIPE -# else -# error "Cannot block SIGPIPE!" -# endif -#endif - /************************************** * Pipe */ @@ -854,7 +836,7 @@ void Pipe::set_socket_options() int prio = msgr->get_socket_priority(); if (prio >= 0) { - int r; + int r = -1; #ifdef IPTOS_CLASS_CS6 int iptos = IPTOS_CLASS_CS6; r = ::setsockopt(sd, IPPROTO_IP, IP_TOS, &iptos, sizeof(iptos)); @@ -866,7 +848,9 @@ void Pipe::set_socket_options() // 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(msgr->cct,0) << "couldn't set SO_PRIORITY to " << prio << ": " << cpp_strerror(errno) << dendl;