Skip to content
Snippets Groups Projects
Commit 483312f9 authored by Tim Emiola's avatar Tim Emiola
Browse files

Merge pull request #541 from ctiller/alias

Fix aliasing
parents b4215bba 772c97bb
No related branches found
No related tags found
No related merge requests found
...@@ -75,7 +75,11 @@ typedef struct { ...@@ -75,7 +75,11 @@ typedef struct {
int fd; int fd;
grpc_fd *emfd; grpc_fd *emfd;
grpc_tcp_server *server; 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; int addr_len;
} server_port; } server_port;
...@@ -125,9 +129,8 @@ void grpc_tcp_server_destroy(grpc_tcp_server *s) { ...@@ -125,9 +129,8 @@ void grpc_tcp_server_destroy(grpc_tcp_server *s) {
/* delete ALL the things */ /* delete ALL the things */
for (i = 0; i < s->nports; i++) { for (i = 0; i < s->nports; i++) {
server_port *sp = &s->ports[i]; server_port *sp = &s->ports[i];
if (((struct sockaddr *)sp->addr)->sa_family == AF_UNIX) { if (sp->addr.sockaddr.sa_family == AF_UNIX) {
struct sockaddr_un *un = (struct sockaddr_un *)sp->addr; unlink(sp->addr.un.sun_path);
unlink(un->sun_path);
} }
grpc_fd_orphan(sp->emfd, NULL, NULL); grpc_fd_orphan(sp->emfd, NULL, NULL);
} }
...@@ -273,7 +276,7 @@ static int add_socket_to_server(grpc_tcp_server *s, int fd, ...@@ -273,7 +276,7 @@ static int add_socket_to_server(grpc_tcp_server *s, int fd,
sp->server = s; sp->server = s;
sp->fd = fd; sp->fd = fd;
sp->emfd = grpc_fd_create(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; sp->addr_len = addr_len;
GPR_ASSERT(sp->emfd); GPR_ASSERT(sp->emfd);
gpr_mu_unlock(&s->mu); gpr_mu_unlock(&s->mu);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment