aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar ahedberg <ahedberg@google.com>2016-03-18 10:46:38 -0400
committerGravatar ahedberg <ahedberg@google.com>2016-03-18 10:46:38 -0400
commit43df29552865541e6d6d11a14b3cf47a4c162b42 (patch)
treeca8a63c98038f5e7cfb08547912095ed9ec890a6 /src/core
parent80d6b12a86a636edc8811b880296fbe45bb214a6 (diff)
add unix_sockets_posix module to build system and fix compilation errors
Diffstat (limited to 'src/core')
-rw-r--r--src/core/iomgr/resolve_address_posix.c2
-rw-r--r--src/core/iomgr/sockaddr_utils.c2
-rw-r--r--src/core/iomgr/tcp_client_posix.c4
-rw-r--r--src/core/iomgr/unix_sockets_posix.c18
-rw-r--r--src/core/iomgr/unix_sockets_posix.h15
-rw-r--r--src/core/iomgr/unix_sockets_posix_noop.c23
6 files changed, 33 insertions, 31 deletions
diff --git a/src/core/iomgr/resolve_address_posix.c b/src/core/iomgr/resolve_address_posix.c
index ef193c02ec..26b3aa8189 100644
--- a/src/core/iomgr/resolve_address_posix.c
+++ b/src/core/iomgr/resolve_address_posix.c
@@ -50,7 +50,7 @@
#include "src/core/iomgr/executor.h"
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/sockaddr_utils.h"
-#include "src/core/iomgr/unix_posix_sockets.h"
+#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/block_annotate.h"
#include "src/core/support/string.h"
diff --git a/src/core/iomgr/sockaddr_utils.c b/src/core/iomgr/sockaddr_utils.c
index 667ab01432..682b290a83 100644
--- a/src/core/iomgr/sockaddr_utils.c
+++ b/src/core/iomgr/sockaddr_utils.c
@@ -200,7 +200,7 @@ int grpc_sockaddr_get_port(const struct sockaddr *addr) {
case AF_INET6:
return ntohs(((struct sockaddr_in6 *)addr)->sin6_port);
default:
- if (grpc_is_unix_socket(addr->sa_family)) {
+ if (grpc_is_unix_socket(addr)) {
return 1;
}
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_get_port",
diff --git a/src/core/iomgr/tcp_client_posix.c b/src/core/iomgr/tcp_client_posix.c
index 2ed6fb107b..1d3f9b6555 100644
--- a/src/core/iomgr/tcp_client_posix.c
+++ b/src/core/iomgr/tcp_client_posix.c
@@ -54,6 +54,7 @@
#include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/tcp_posix.h"
#include "src/core/iomgr/timer.h"
+#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
extern int grpc_tcp_trace;
@@ -77,8 +78,7 @@ static int prepare_socket(const struct sockaddr *addr, int fd) {
}
if (!grpc_set_socket_nonblocking(fd, 1) || !grpc_set_socket_cloexec(fd, 1) ||
- (!grpc_is_unix_socket(addr->sa_family) &&
- !grpc_set_socket_low_latency(fd, 1)) ||
+ (!grpc_is_unix_socket(addr) && !grpc_set_socket_low_latency(fd, 1)) ||
!grpc_set_socket_no_sigpipe_if_possible(fd)) {
gpr_log(GPR_ERROR, "Unable to configure socket %d: %s", fd,
strerror(errno));
diff --git a/src/core/iomgr/unix_sockets_posix.c b/src/core/iomgr/unix_sockets_posix.c
index 531ddcb37d..0ff48320ca 100644
--- a/src/core/iomgr/unix_sockets_posix.c
+++ b/src/core/iomgr/unix_sockets_posix.c
@@ -36,6 +36,7 @@
#ifdef GPR_HAVE_UNIX_SOCKET
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/un.h>
#include <grpc/support/alloc.h>
@@ -47,7 +48,7 @@ void grpc_create_socketpair_if_unix(int sv[2]) {
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char* name) {
struct sockaddr_un *un;
- addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
+ grpc_resolved_addresses *addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
addrs->naddrs = 1;
addrs->addrs = gpr_malloc(sizeof(grpc_resolved_address));
un = (struct sockaddr_un *)addrs->addrs->addr;
@@ -57,11 +58,11 @@ grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char* name) {
return addrs;
}
-int grpc_is_unix_socket(sa_family_t addr_family) {
- return addr_family == AF_UNIX;
+int grpc_is_unix_socket(const struct sockaddr *addr) {
+ return addr->sa_family == AF_UNIX;
}
-static void unlink_if_unix_domain_socket(const struct sockaddr *addr) {
+void unlink_if_unix_domain_socket(const struct sockaddr *addr) {
if (addr->sa_family != AF_UNIX) {
return;
}
@@ -73,8 +74,7 @@ static void unlink_if_unix_domain_socket(const struct sockaddr *addr) {
}
}
-static int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr,
- size_t *len) {
+int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
struct sockaddr_un *un = (struct sockaddr_un *)addr;
un->sun_family = AF_UNIX;
@@ -84,12 +84,12 @@ static int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr,
return 1;
}
-static char *unix_get_default_authority(grpc_resolver_factory *factory,
- grpc_uri *uri) {
+char *unix_get_default_authority(grpc_resolver_factory *factory,
+ grpc_uri *uri) {
return gpr_strdup("localhost");
}
-char *grpc_sockaddr_to_uri_unix_if_possible(struct sockaddr *addr) {
+char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
if (addr->sa_family != AF_UNIX) {
return NULL;
}
diff --git a/src/core/iomgr/unix_sockets_posix.h b/src/core/iomgr/unix_sockets_posix.h
index 6023611373..c7ba0bfe09 100644
--- a/src/core/iomgr/unix_sockets_posix.h
+++ b/src/core/iomgr/unix_sockets_posix.h
@@ -43,25 +43,22 @@
#include <grpc/support/string_util.h>
#include "src/core/client_config/resolver_factory.h"
-#include "src/core/client_config/uri_parser.h";
+#include "src/core/client_config/uri_parser.h"
#include "src/core/iomgr/resolve_address.h"
void grpc_create_socketpair_if_unix(int sv[2]);
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char* name);
-int grpc_is_unix_socket(sa_family_t addr_family);
+int grpc_is_unix_socket(const struct sockaddr *addr);
-static void unlink_if_unix_domain_socket(const struct sockaddr *addr);
+void unlink_if_unix_domain_socket(const struct sockaddr *addr);
-static int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr,
- size_t *len);
+int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len);
-static char *unix_get_default_authority(grpc_resolver_factory *factory,
- grpc_uri *uri);
+char *unix_get_default_authority(grpc_resolver_factory *factory, grpc_uri *uri);
-char *grpc_sockaddr_to_uri_unix_if_possible(char **strp,
- const char *format, ...);
+char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr);
#endif
#endif /* GRPC_INTERNAL_CORE_IOMGR_UNIX_SOCKETS_POSIX_H */
diff --git a/src/core/iomgr/unix_sockets_posix_noop.c b/src/core/iomgr/unix_sockets_posix_noop.c
index 1e29242486..1f6773576c 100644
--- a/src/core/iomgr/unix_sockets_posix_noop.c
+++ b/src/core/iomgr/unix_sockets_posix_noop.c
@@ -34,26 +34,31 @@
#include "src/core/iomgr/unix_sockets_posix.h"
+#ifdef GPR_POSIX_SOCKET
+
void grpc_create_socketpair_if_unix(int sv[2]) {}
-void grpc_resolve_unix_domain_address(const char* name) {
+grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char* name) {
return NULL;
}
-int grpc_is_unix_socket(sa_family_t addr_family) {
+int grpc_is_unix_socket(const struct sockaddr *addr) {
return false;
}
-static void unlink_if_unix_domain_socket(const struct sockaddr *addr) {}
+void unlink_if_unix_domain_socket(const struct sockaddr *addr) {}
-static int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr,
- size_t *len) {}
+int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
+ return 0;
+}
-static char *unix_get_default_authority(grpc_resolver_factory *factory,
- grpc_uri *uri) {}
+char *unix_get_default_authority(grpc_resolver_factory *factory,
+ grpc_uri *uri) {
+ return NULL;
+}
-char *grpc_sockaddr_to_uri_unix_if_possible(struct sockaddr *addr) {
- return NULL;
+char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
+ return NULL;
}
#endif