aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-11 14:59:19 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-11 14:59:19 -0700
commit0189ac0b00286b88b495092e615a64f79521b9e1 (patch)
tree501a87c95ec6a54176e762fd3e8685727fd5b5e1 /src/core
parent4a71600c0495c1e45d9c0a226dac6c02fc312310 (diff)
Add new fds to server pollsets (for now)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/iomgr/tcp_server_posix.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c
index d1cd8a769c..bb53865bd1 100644
--- a/src/core/iomgr/tcp_server_posix.c
+++ b/src/core/iomgr/tcp_server_posix.c
@@ -114,6 +114,9 @@ struct grpc_tcp_server {
/* shutdown callback */
void (*shutdown_complete)(void *);
void *shutdown_complete_arg;
+
+ grpc_pollset **pollsets;
+ size_t pollset_count;
};
grpc_tcp_server *grpc_tcp_server_create(void) {
@@ -272,6 +275,8 @@ error:
/* event manager callback when reads are ready */
static void on_read(void *arg, int success) {
server_port *sp = arg;
+ grpc_fd *fdobj;
+ size_t i;
if (!success) {
goto error;
@@ -299,9 +304,16 @@ static void on_read(void *arg, int success) {
grpc_set_socket_no_sigpipe_if_possible(fd);
+ fdobj = grpc_fd_create(fd);
+ /* TODO(ctiller): revise this when we have server-side sharding
+ of channels -- we certainly should not be automatically adding every
+ incoming channel to every pollset owned by the server */
+ for (i = 0; i < sp->server->pollset_count; i++) {
+ grpc_pollset_add_fd(sp->server->pollsets[i], fdobj);
+ }
sp->server->cb(
sp->server->cb_arg,
- grpc_tcp_create(grpc_fd_create(fd), GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
+ grpc_tcp_create(fdobj, GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
}
abort();
@@ -436,6 +448,8 @@ void grpc_tcp_server_start(grpc_tcp_server *s, grpc_pollset **pollsets,
GPR_ASSERT(s->active_ports == 0);
s->cb = cb;
s->cb_arg = cb_arg;
+ s->pollsets = pollsets;
+ s->pollset_count = pollset_count;
for (i = 0; i < s->nports; i++) {
for (j = 0; j < pollset_count; j++) {
grpc_pollset_add_fd(pollsets[j], s->ports[i].emfd);