diff options
author | Yang Gao <yangg@google.com> | 2015-09-15 12:42:34 -0700 |
---|---|---|
committer | Yang Gao <yangg@google.com> | 2015-09-15 12:42:34 -0700 |
commit | 3d29666b9d2bb38c8fd4c51b7245951a1a5c5599 (patch) | |
tree | 310f0a8cd8cb55a4c4e38b43c4bc2e5587a3e292 /src | |
parent | 6f3680160a8a7dde0d6fd2ea021209df3336a3c3 (diff) | |
parent | e388ed3a458b42928a358bc51078ddc7c39f120a (diff) |
Merge pull request #3135 from rjshade/remove_udp_new_transport_cb
Remove on_connect callback from udp_server
Diffstat (limited to 'src')
-rw-r--r-- | src/core/iomgr/udp_server.c | 15 | ||||
-rw-r--r-- | src/core/iomgr/udp_server.h | 12 |
2 files changed, 5 insertions, 22 deletions
diff --git a/src/core/iomgr/udp_server.c b/src/core/iomgr/udp_server.c index ed9eee8726..afe7d9e0dd 100644 --- a/src/core/iomgr/udp_server.c +++ b/src/core/iomgr/udp_server.c @@ -94,9 +94,6 @@ static void unlink_if_unix_domain_socket(const struct sockaddr_un *un) { /* the overall server */ struct grpc_udp_server { - grpc_udp_server_cb cb; - void *cb_arg; - gpr_mu mu; gpr_cv cv; @@ -130,8 +127,6 @@ grpc_udp_server *grpc_udp_server_create(void) { s->active_ports = 0; s->destroyed_ports = 0; s->shutdown = 0; - s->cb = NULL; - s->cb_arg = NULL; s->ports = gpr_malloc(sizeof(server_port) * INIT_PORT_CAP); s->nports = 0; s->port_capacity = INIT_PORT_CAP; @@ -282,7 +277,7 @@ static void on_read(void *arg, int success) { /* Tell the registered callback that data is available to read. */ GPR_ASSERT(sp->read_cb); - sp->read_cb(sp->fd, sp->server->cb, sp->server->cb_arg); + sp->read_cb(sp->fd); /* Re-arm the notification event so we get another chance to read. */ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure); @@ -301,7 +296,6 @@ static int add_socket_to_server(grpc_udp_server *s, int fd, grpc_sockaddr_to_string(&addr_str, (struct sockaddr *)&addr, 1); gpr_asprintf(&name, "udp-server-listener:%s", addr_str); gpr_mu_lock(&s->mu); - GPR_ASSERT(!s->cb && "must add ports before starting server"); /* append it to the list under a lock */ if (s->nports == s->port_capacity) { s->port_capacity *= 2; @@ -407,15 +401,10 @@ int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index) { } void grpc_udp_server_start(grpc_udp_server *s, grpc_pollset **pollsets, - size_t pollset_count, - grpc_udp_server_cb new_transport_cb, void *cb_arg) { + size_t pollset_count) { size_t i, j; - GPR_ASSERT(new_transport_cb); gpr_mu_lock(&s->mu); - GPR_ASSERT(!s->cb); GPR_ASSERT(s->active_ports == 0); - s->cb = new_transport_cb; - s->cb_arg = cb_arg; s->pollsets = pollsets; for (i = 0; i < s->nports; i++) { for (j = 0; j < pollset_count; j++) { diff --git a/src/core/iomgr/udp_server.h b/src/core/iomgr/udp_server.h index 389f84ecca..c930e81cbc 100644 --- a/src/core/iomgr/udp_server.h +++ b/src/core/iomgr/udp_server.h @@ -39,21 +39,15 @@ /* Forward decl of grpc_udp_server */ typedef struct grpc_udp_server grpc_udp_server; -/* New server callback: ep is the newly connected connection */ -typedef void (*grpc_udp_server_cb)(void *arg, grpc_endpoint *ep); - /* Called when data is available to read from the socket. */ -typedef void (*grpc_udp_server_read_cb)(int fd, - grpc_udp_server_cb new_transport_cb, - void *cb_arg); +typedef void (*grpc_udp_server_read_cb)(int fd); /* Create a server, initially not bound to any ports */ grpc_udp_server *grpc_udp_server_create(void); /* Start listening to bound ports */ -void grpc_udp_server_start(grpc_udp_server *server, grpc_pollset **pollsets, - size_t pollset_count, grpc_udp_server_cb cb, - void *cb_arg); +void grpc_udp_server_start(grpc_udp_server *udp_server, grpc_pollset **pollsets, + size_t pollset_count); int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index); |