Fix android build

pull/10123/head
Yuchen Zeng 8 years ago
parent 86ac76a0df
commit f134206509
  1. 4
      src/core/lib/iomgr/port.h
  2. 9
      src/core/lib/iomgr/tcp_server_posix.c

@ -39,6 +39,7 @@
#if defined(GRPC_UV) #if defined(GRPC_UV)
// Do nothing // Do nothing
#elif defined(GPR_MANYLINUX1) #elif defined(GPR_MANYLINUX1)
#define GRPC_HAVE_IFADDRS 1
#define GRPC_HAVE_IPV6_RECVPKTINFO 1 #define GRPC_HAVE_IPV6_RECVPKTINFO 1
#define GRPC_HAVE_IP_PKTINFO 1 #define GRPC_HAVE_IP_PKTINFO 1
#define GRPC_HAVE_MSG_NOSIGNAL 1 #define GRPC_HAVE_MSG_NOSIGNAL 1
@ -65,6 +66,7 @@
#define GRPC_POSIX_WAKEUP_FD 1 #define GRPC_POSIX_WAKEUP_FD 1
#define GRPC_TIMER_USE_GENERIC 1 #define GRPC_TIMER_USE_GENERIC 1
#elif defined(GPR_LINUX) #elif defined(GPR_LINUX)
#define GRPC_HAVE_IFADDRS 1
#define GRPC_HAVE_IPV6_RECVPKTINFO 1 #define GRPC_HAVE_IPV6_RECVPKTINFO 1
#define GRPC_HAVE_IP_PKTINFO 1 #define GRPC_HAVE_IP_PKTINFO 1
#define GRPC_HAVE_MSG_NOSIGNAL 1 #define GRPC_HAVE_MSG_NOSIGNAL 1
@ -90,6 +92,7 @@
#define GRPC_POSIX_SOCKETUTILS #define GRPC_POSIX_SOCKETUTILS
#endif #endif
#elif defined(GPR_APPLE) #elif defined(GPR_APPLE)
#define GRPC_HAVE_IFADDRS 1
#define GRPC_HAVE_SO_NOSIGPIPE 1 #define GRPC_HAVE_SO_NOSIGPIPE 1
#define GRPC_HAVE_UNIX_SOCKET 1 #define GRPC_HAVE_UNIX_SOCKET 1
#define GRPC_MSG_IOVLEN_TYPE int #define GRPC_MSG_IOVLEN_TYPE int
@ -100,6 +103,7 @@
#define GRPC_POSIX_WAKEUP_FD 1 #define GRPC_POSIX_WAKEUP_FD 1
#define GRPC_TIMER_USE_GENERIC 1 #define GRPC_TIMER_USE_GENERIC 1
#elif defined(GPR_FREEBSD) #elif defined(GPR_FREEBSD)
#define GRPC_HAVE_IFADDRS 1
#define GRPC_HAVE_IPV6_RECVPKTINFO 1 #define GRPC_HAVE_IPV6_RECVPKTINFO 1
#define GRPC_HAVE_SO_NOSIGPIPE 1 #define GRPC_HAVE_SO_NOSIGPIPE 1
#define GRPC_HAVE_UNIX_SOCKET 1 #define GRPC_HAVE_UNIX_SOCKET 1

@ -42,9 +42,12 @@
#include "src/core/lib/iomgr/tcp_server.h" #include "src/core/lib/iomgr/tcp_server.h"
#ifdef GRPC_HAVE_IFADDRS
#include <ifaddrs.h>
#endif /* GRPC_HAVE_IFADDRS */
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <ifaddrs.h>
#include <limits.h> #include <limits.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
@ -598,6 +601,7 @@ static grpc_error *add_all_local_addrs_to_server(grpc_tcp_server *s,
unsigned port_index, unsigned port_index,
int requested_port, int requested_port,
int *out_port) { int *out_port) {
#ifdef GRPC_HAVE_IFADDRS
struct ifaddrs *ifa = NULL; struct ifaddrs *ifa = NULL;
struct ifaddrs *ifa_it; struct ifaddrs *ifa_it;
unsigned fd_index = 0; unsigned fd_index = 0;
@ -685,6 +689,9 @@ static grpc_error *add_all_local_addrs_to_server(grpc_tcp_server *s,
*out_port = sp->port; *out_port = sp->port;
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
#else /* GRPC_HAVE_IFADDRS */
return GRPC_ERROR_NONE;
#endif /* GRPC_HAVE_IFADDRS */
} }
/* Treat :: or 0.0.0.0 as a family-agnostic wildcard. */ /* Treat :: or 0.0.0.0 as a family-agnostic wildcard. */

Loading…
Cancel
Save