diff options
author | Tim Emiola <tbetbetbe@users.noreply.github.com> | 2015-02-17 09:31:07 -0800 |
---|---|---|
committer | Tim Emiola <tbetbetbe@users.noreply.github.com> | 2015-02-17 09:31:07 -0800 |
commit | 483312f96f4dc0ec4969ba4fefb41c4f9133d209 (patch) | |
tree | 443f932e374cef1b18de03dce6ee0a20df69df1f /src/core | |
parent | b4215bba564627b62241ef7e37528fa154a79e7c (diff) | |
parent | 772c97bbad386c942a318aaf781578172addd764 (diff) |
Merge pull request #541 from ctiller/alias
Fix aliasing
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/iomgr/tcp_server_posix.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c index 355a040ff2..6a96163718 100644 --- a/src/core/iomgr/tcp_server_posix.c +++ b/src/core/iomgr/tcp_server_posix.c @@ -75,7 +75,11 @@ typedef struct { int fd; grpc_fd *emfd; grpc_tcp_server *server; - gpr_uint8 addr[GRPC_MAX_SOCKADDR_SIZE]; + union { + gpr_uint8 untyped[GRPC_MAX_SOCKADDR_SIZE]; + struct sockaddr sockaddr; + struct sockaddr_un un; + } addr; int addr_len; } server_port; @@ -125,9 +129,8 @@ void grpc_tcp_server_destroy(grpc_tcp_server *s) { /* delete ALL the things */ for (i = 0; i < s->nports; i++) { server_port *sp = &s->ports[i]; - if (((struct sockaddr *)sp->addr)->sa_family == AF_UNIX) { - struct sockaddr_un *un = (struct sockaddr_un *)sp->addr; - unlink(un->sun_path); + if (sp->addr.sockaddr.sa_family == AF_UNIX) { + unlink(sp->addr.un.sun_path); } grpc_fd_orphan(sp->emfd, NULL, NULL); } @@ -273,7 +276,7 @@ static int add_socket_to_server(grpc_tcp_server *s, int fd, sp->server = s; sp->fd = fd; sp->emfd = grpc_fd_create(fd); - memcpy(sp->addr, addr, addr_len); + memcpy(sp->addr.untyped, addr, addr_len); sp->addr_len = addr_len; GPR_ASSERT(sp->emfd); gpr_mu_unlock(&s->mu); |