summaryrefslogtreecommitdiffstats
path: root/src/include/sock_compat.h
blob: 14b5efa1df2dbfc7b109a028e4beb4aa53ab6342 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2018 Red Hat, Inc.
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software
 * Foundation.  See file COPYING.
 */

#ifndef CEPH_SOCK_COMPAT_H
#define CEPH_SOCK_COMPAT_H

#include "include/compat.h"
#include <sys/socket.h>

/*
 * 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
#  define CEPH_USE_SIGPIPE_BLOCKER
#  warning "Using SIGPIPE blocking instead of suppression; this is not well-tested upstream!"
# endif
#endif

int socket_cloexec(int domain, int type, int protocol);
int socketpair_cloexec(int domain, int type, int protocol, int sv[2]);
int accept_cloexec(int sockfd, struct sockaddr* addr, socklen_t* addrlen);

#endif