blob: 482166e2eb67a6275a1f14669b613ffc018f001a [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Craig Tiller06059952015-02-18 08:34:56 -08003 * Copyright 2015, Google Inc.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
David Klempner78b79922015-02-04 10:18:59 -080034/* FIXME: "posix" files shouldn't be depending on _GNU_SOURCE */
35#ifndef _GNU_SOURCE
36#define _GNU_SOURCE
37#endif
38
Craig Tiller0c0b60c2015-01-21 15:49:28 -080039#include <grpc/support/port_platform.h>
40
Craig Tillera172ad72015-01-21 15:51:47 -080041#ifdef GPR_POSIX_SOCKET
Craig Tiller0c0b60c2015-01-21 15:49:28 -080042
ctiller18b49ab2014-12-09 14:39:16 -080043#include "src/core/iomgr/tcp_server.h"
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080044
Craig Tilleraa31da42015-02-17 16:33:35 -080045#include <errno.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080046#include <fcntl.h>
Craig Tilleraa31da42015-02-17 16:33:35 -080047#include <limits.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080048#include <netinet/in.h>
49#include <netinet/tcp.h>
50#include <stdio.h>
Craig Tilleraa31da42015-02-17 16:33:35 -080051#include <string.h>
52#include <sys/socket.h>
53#include <sys/stat.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080054#include <sys/types.h>
Craig Tillerae7fe922015-02-13 23:16:32 -080055#include <sys/un.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080056#include <unistd.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080057
ctiller58393c22015-01-07 14:03:30 -080058#include "src/core/iomgr/pollset_posix.h"
Craig Tillerae7fe922015-02-13 23:16:32 -080059#include "src/core/iomgr/resolve_address.h"
ctiller18b49ab2014-12-09 14:39:16 -080060#include "src/core/iomgr/sockaddr_utils.h"
61#include "src/core/iomgr/socket_utils_posix.h"
62#include "src/core/iomgr/tcp_posix.h"
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080063#include <grpc/support/alloc.h>
64#include <grpc/support/log.h>
65#include <grpc/support/sync.h>
66#include <grpc/support/time.h>
67
68#define INIT_PORT_CAP 2
69#define MIN_SAFE_ACCEPT_QUEUE_SIZE 100
70
71static gpr_once s_init_max_accept_queue_size;
72static int s_max_accept_queue_size;
73
74/* one listening port */
75typedef struct {
76 int fd;
ctiller18b49ab2014-12-09 14:39:16 -080077 grpc_fd *emfd;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080078 grpc_tcp_server *server;
Craig Tiller772c97b2015-02-17 08:07:34 -080079 union {
80 gpr_uint8 untyped[GRPC_MAX_SOCKADDR_SIZE];
81 struct sockaddr sockaddr;
82 struct sockaddr_un un;
83 } addr;
Craig Tillerae7fe922015-02-13 23:16:32 -080084 int addr_len;
Craig Tiller0fcd53c2015-02-18 15:10:53 -080085 grpc_iomgr_closure read_closure;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080086} server_port;
87
Craig Tilleraa31da42015-02-17 16:33:35 -080088static void unlink_if_unix_domain_socket(const struct sockaddr_un *un) {
89 struct stat st;
90
91 if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
92 unlink(un->sun_path);
93 }
94}
95
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080096/* the overall server */
97struct grpc_tcp_server {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080098 grpc_tcp_server_cb cb;
99 void *cb_arg;
100
101 gpr_mu mu;
102 gpr_cv cv;
103
104 /* active port count: how many ports are actually still listening */
Craig Tilleraec96aa2015-04-07 14:32:15 -0700105 size_t active_ports;
106 /* destroyed port count: how many ports are completely destroyed */
107 size_t destroyed_ports;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800108
109 /* all listening ports */
110 server_port *ports;
111 size_t nports;
112 size_t port_capacity;
Craig Tilleraec96aa2015-04-07 14:32:15 -0700113
114 /* shutdown callback */
115 void (*shutdown_complete)(void *);
116 void *shutdown_complete_arg;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800117};
118
Craig Tiller32946d32015-01-15 11:37:30 -0800119grpc_tcp_server *grpc_tcp_server_create(void) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800120 grpc_tcp_server *s = gpr_malloc(sizeof(grpc_tcp_server));
121 gpr_mu_init(&s->mu);
122 gpr_cv_init(&s->cv);
123 s->active_ports = 0;
Craig Tilleraec96aa2015-04-07 14:32:15 -0700124 s->destroyed_ports = 0;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800125 s->cb = NULL;
126 s->cb_arg = NULL;
127 s->ports = gpr_malloc(sizeof(server_port) * INIT_PORT_CAP);
128 s->nports = 0;
129 s->port_capacity = INIT_PORT_CAP;
130 return s;
131}
132
Craig Tilleraec96aa2015-04-07 14:32:15 -0700133static void finish_shutdown(grpc_tcp_server *s) {
134 s->shutdown_complete(s->shutdown_complete_arg);
135
136 gpr_mu_destroy(&s->mu);
137 gpr_cv_destroy(&s->cv);
138
139 gpr_free(s->ports);
140 gpr_free(s);
141}
142
143static void destroyed_port(void *server, int success) {
144 grpc_tcp_server *s = server;
145 gpr_mu_lock(&s->mu);
146 s->destroyed_ports++;
147 if (s->destroyed_ports == s->nports) {
148 gpr_mu_unlock(&s->mu);
149 finish_shutdown(s);
150 } else {
151 gpr_mu_unlock(&s->mu);
152 }
153}
154
155static void dont_care_about_shutdown_completion(void *ignored) {}
156
157void grpc_tcp_server_destroy(grpc_tcp_server *s,
158 void (*shutdown_complete)(void *shutdown_complete_arg),
159 void *shutdown_complete_arg) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800160 size_t i;
161 gpr_mu_lock(&s->mu);
Craig Tilleraec96aa2015-04-07 14:32:15 -0700162
163 s->shutdown_complete = shutdown_complete ? shutdown_complete : dont_care_about_shutdown_completion;
164 s->shutdown_complete_arg = shutdown_complete_arg;
165
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800166 /* shutdown all fd's */
167 for (i = 0; i < s->nports; i++) {
ctiller18b49ab2014-12-09 14:39:16 -0800168 grpc_fd_shutdown(s->ports[i].emfd);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800169 }
170 /* wait while that happens */
Craig Tilleraec96aa2015-04-07 14:32:15 -0700171 /* TODO(ctiller): make this asynchronous also */
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800172 while (s->active_ports) {
173 gpr_cv_wait(&s->cv, &s->mu, gpr_inf_future);
174 }
175 gpr_mu_unlock(&s->mu);
176
177 /* delete ALL the things */
Craig Tilleraec96aa2015-04-07 14:32:15 -0700178 if (s->nports) {
179 for (i = 0; i < s->nports; i++) {
180 server_port *sp = &s->ports[i];
181 if (sp->addr.sockaddr.sa_family == AF_UNIX) {
182 unlink_if_unix_domain_socket(&sp->addr.un);
183 }
184 grpc_fd_orphan(sp->emfd, destroyed_port, s);
Craig Tillerae7fe922015-02-13 23:16:32 -0800185 }
Craig Tilleraec96aa2015-04-07 14:32:15 -0700186 } else {
187 finish_shutdown(s);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800188 }
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800189}
190
191/* get max listen queue size on linux */
Craig Tiller32946d32015-01-15 11:37:30 -0800192static void init_max_accept_queue_size(void) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800193 int n = SOMAXCONN;
194 char buf[64];
195 FILE *fp = fopen("/proc/sys/net/core/somaxconn", "r");
196 if (fp == NULL) {
197 /* 2.4 kernel. */
198 s_max_accept_queue_size = SOMAXCONN;
199 return;
200 }
201 if (fgets(buf, sizeof buf, fp)) {
202 char *end;
203 long i = strtol(buf, &end, 10);
204 if (i > 0 && i <= INT_MAX && end && *end == 0) {
205 n = i;
206 }
207 }
208 fclose(fp);
209 s_max_accept_queue_size = n;
210
211 if (s_max_accept_queue_size < MIN_SAFE_ACCEPT_QUEUE_SIZE) {
212 gpr_log(GPR_INFO,
213 "Suspiciously small accept queue (%d) will probably lead to "
214 "connection drops",
215 s_max_accept_queue_size);
216 }
217}
218
Craig Tiller32946d32015-01-15 11:37:30 -0800219static int get_max_accept_queue_size(void) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800220 gpr_once_init(&s_init_max_accept_queue_size, init_max_accept_queue_size);
221 return s_max_accept_queue_size;
222}
223
nnoble0c475f02014-12-05 15:37:39 -0800224/* Prepare a recently-created socket for listening. */
225static int prepare_socket(int fd, const struct sockaddr *addr, int addr_len) {
ctiller570d1f42015-01-12 16:29:52 -0800226 struct sockaddr_storage sockname_temp;
227 socklen_t sockname_len;
228
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800229 if (fd < 0) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800230 goto error;
231 }
232
233 if (!grpc_set_socket_nonblocking(fd, 1) || !grpc_set_socket_cloexec(fd, 1) ||
Craig Tillerd209ed02015-02-13 23:18:15 -0800234 (addr->sa_family != AF_UNIX && (!grpc_set_socket_low_latency(fd, 1) ||
235 !grpc_set_socket_reuse_addr(fd, 1)))) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800236 gpr_log(GPR_ERROR, "Unable to configure socket %d: %s", fd,
237 strerror(errno));
238 goto error;
239 }
240
nnoble0c475f02014-12-05 15:37:39 -0800241 if (bind(fd, addr, addr_len) < 0) {
242 char *addr_str;
243 grpc_sockaddr_to_string(&addr_str, addr, 0);
244 gpr_log(GPR_ERROR, "bind addr=%s: %s", addr_str, strerror(errno));
245 gpr_free(addr_str);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800246 goto error;
247 }
248
249 if (listen(fd, get_max_accept_queue_size()) < 0) {
250 gpr_log(GPR_ERROR, "listen: %s", strerror(errno));
251 goto error;
252 }
253
ctiller570d1f42015-01-12 16:29:52 -0800254 sockname_len = sizeof(sockname_temp);
255 if (getsockname(fd, (struct sockaddr *)&sockname_temp, &sockname_len) < 0) {
256 goto error;
257 }
258
259 return grpc_sockaddr_get_port((struct sockaddr *)&sockname_temp);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800260
261error:
262 if (fd >= 0) {
263 close(fd);
264 }
ctiller570d1f42015-01-12 16:29:52 -0800265 return -1;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800266}
267
268/* event manager callback when reads are ready */
ctiller58393c22015-01-07 14:03:30 -0800269static void on_read(void *arg, int success) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800270 server_port *sp = arg;
271
ctiller58393c22015-01-07 14:03:30 -0800272 if (!success) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800273 goto error;
274 }
275
276 /* loop until accept4 returns EAGAIN, and then re-arm notification */
277 for (;;) {
278 struct sockaddr_storage addr;
279 socklen_t addrlen = sizeof(addr);
nnoble0c475f02014-12-05 15:37:39 -0800280 /* Note: If we ever decide to return this address to the user, remember to
281 strip off the ::ffff:0.0.0.0/96 prefix first. */
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800282 int fd = grpc_accept4(sp->fd, (struct sockaddr *)&addr, &addrlen, 1, 1);
283 if (fd < 0) {
284 switch (errno) {
285 case EINTR:
286 continue;
287 case EAGAIN:
Craig Tiller0fcd53c2015-02-18 15:10:53 -0800288 grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800289 return;
290 default:
291 gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno));
292 goto error;
293 }
294 }
295
ctiller18b49ab2014-12-09 14:39:16 -0800296 sp->server->cb(
297 sp->server->cb_arg,
298 grpc_tcp_create(grpc_fd_create(fd), GRPC_TCP_DEFAULT_READ_SLICE_SIZE));
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800299 }
300
301 abort();
302
303error:
304 gpr_mu_lock(&sp->server->mu);
305 if (0 == --sp->server->active_ports) {
306 gpr_cv_broadcast(&sp->server->cv);
307 }
308 gpr_mu_unlock(&sp->server->mu);
309}
310
nnoble0c475f02014-12-05 15:37:39 -0800311static int add_socket_to_server(grpc_tcp_server *s, int fd,
312 const struct sockaddr *addr, int addr_len) {
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800313 server_port *sp;
ctiller570d1f42015-01-12 16:29:52 -0800314 int port;
nnoble0c475f02014-12-05 15:37:39 -0800315
ctiller570d1f42015-01-12 16:29:52 -0800316 port = prepare_socket(fd, addr, addr_len);
317 if (port >= 0) {
318 gpr_mu_lock(&s->mu);
319 GPR_ASSERT(!s->cb && "must add ports before starting server");
320 /* append it to the list under a lock */
321 if (s->nports == s->port_capacity) {
322 s->port_capacity *= 2;
Yang Gao5fd0d292015-01-26 00:19:48 -0800323 s->ports = gpr_realloc(s->ports, sizeof(server_port) * s->port_capacity);
ctiller570d1f42015-01-12 16:29:52 -0800324 }
325 sp = &s->ports[s->nports++];
326 sp->server = s;
327 sp->fd = fd;
328 sp->emfd = grpc_fd_create(fd);
Craig Tiller772c97b2015-02-17 08:07:34 -0800329 memcpy(sp->addr.untyped, addr, addr_len);
Craig Tillerae7fe922015-02-13 23:16:32 -0800330 sp->addr_len = addr_len;
ctiller570d1f42015-01-12 16:29:52 -0800331 GPR_ASSERT(sp->emfd);
332 gpr_mu_unlock(&s->mu);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800333 }
334
ctiller570d1f42015-01-12 16:29:52 -0800335 return port;
nnoble0c475f02014-12-05 15:37:39 -0800336}
337
Craig Tillera172ad72015-01-21 15:51:47 -0800338int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
nnoble0c475f02014-12-05 15:37:39 -0800339 int addr_len) {
ctiller570d1f42015-01-12 16:29:52 -0800340 int allocated_port1 = -1;
341 int allocated_port2 = -1;
Nicolas "Pixel" Noble213ed912015-01-30 02:11:35 +0100342 unsigned i;
nnoble0c475f02014-12-05 15:37:39 -0800343 int fd;
344 grpc_dualstack_mode dsmode;
345 struct sockaddr_in6 addr6_v4mapped;
346 struct sockaddr_in wild4;
347 struct sockaddr_in6 wild6;
348 struct sockaddr_in addr4_copy;
ctiller570d1f42015-01-12 16:29:52 -0800349 struct sockaddr *allocated_addr = NULL;
350 struct sockaddr_storage sockname_temp;
351 socklen_t sockname_len;
nnoble0c475f02014-12-05 15:37:39 -0800352 int port;
353
Craig Tilleraa31da42015-02-17 16:33:35 -0800354 if (((struct sockaddr *)addr)->sa_family == AF_UNIX) {
355 unlink_if_unix_domain_socket(addr);
356 }
357
ctiller570d1f42015-01-12 16:29:52 -0800358 /* Check if this is a wildcard port, and if so, try to keep the port the same
359 as some previously created listener. */
360 if (grpc_sockaddr_get_port(addr) == 0) {
361 for (i = 0; i < s->nports; i++) {
362 sockname_len = sizeof(sockname_temp);
363 if (0 == getsockname(s->ports[i].fd, (struct sockaddr *)&sockname_temp,
364 &sockname_len)) {
365 port = grpc_sockaddr_get_port((struct sockaddr *)&sockname_temp);
366 if (port > 0) {
367 allocated_addr = malloc(addr_len);
368 memcpy(allocated_addr, addr, addr_len);
369 grpc_sockaddr_set_port(allocated_addr, port);
370 addr = allocated_addr;
371 break;
372 }
373 }
374 }
375 }
376
nnoble0c475f02014-12-05 15:37:39 -0800377 if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) {
378 addr = (const struct sockaddr *)&addr6_v4mapped;
379 addr_len = sizeof(addr6_v4mapped);
380 }
381
382 /* Treat :: or 0.0.0.0 as a family-agnostic wildcard. */
383 if (grpc_sockaddr_is_wildcard(addr, &port)) {
384 grpc_sockaddr_make_wildcards(port, &wild4, &wild6);
385
386 /* Try listening on IPv6 first. */
387 addr = (struct sockaddr *)&wild6;
388 addr_len = sizeof(wild6);
389 fd = grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, &dsmode);
ctiller570d1f42015-01-12 16:29:52 -0800390 allocated_port1 = add_socket_to_server(s, fd, addr, addr_len);
nnoble0c475f02014-12-05 15:37:39 -0800391 if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) {
ctiller570d1f42015-01-12 16:29:52 -0800392 goto done;
nnoble0c475f02014-12-05 15:37:39 -0800393 }
394
395 /* If we didn't get a dualstack socket, also listen on 0.0.0.0. */
ctiller570d1f42015-01-12 16:29:52 -0800396 if (port == 0 && allocated_port1 > 0) {
397 grpc_sockaddr_set_port((struct sockaddr *)&wild4, allocated_port1);
398 }
nnoble0c475f02014-12-05 15:37:39 -0800399 addr = (struct sockaddr *)&wild4;
400 addr_len = sizeof(wild4);
401 }
402
403 fd = grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, &dsmode);
404 if (fd < 0) {
405 gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno));
406 }
407 if (dsmode == GRPC_DSMODE_IPV4 &&
408 grpc_sockaddr_is_v4mapped(addr, &addr4_copy)) {
409 addr = (struct sockaddr *)&addr4_copy;
410 addr_len = sizeof(addr4_copy);
411 }
ctiller570d1f42015-01-12 16:29:52 -0800412 allocated_port2 = add_socket_to_server(s, fd, addr, addr_len);
413
414done:
415 gpr_free(allocated_addr);
416 return allocated_port1 >= 0 ? allocated_port1 : allocated_port2;
nnoble0c475f02014-12-05 15:37:39 -0800417}
418
Nicolas "Pixel" Noble213ed912015-01-30 02:11:35 +0100419int grpc_tcp_server_get_fd(grpc_tcp_server *s, unsigned index) {
420 return (index < s->nports) ? s->ports[index].fd : -1;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800421}
422
Craig Tiller20bc56d2015-02-12 09:02:56 -0800423void grpc_tcp_server_start(grpc_tcp_server *s, grpc_pollset **pollsets,
424 size_t pollset_count, grpc_tcp_server_cb cb,
425 void *cb_arg) {
426 size_t i, j;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800427 GPR_ASSERT(cb);
428 gpr_mu_lock(&s->mu);
429 GPR_ASSERT(!s->cb);
430 GPR_ASSERT(s->active_ports == 0);
431 s->cb = cb;
432 s->cb_arg = cb_arg;
433 for (i = 0; i < s->nports; i++) {
Craig Tiller20bc56d2015-02-12 09:02:56 -0800434 for (j = 0; j < pollset_count; j++) {
435 grpc_pollset_add_fd(pollsets[j], s->ports[i].emfd);
ctiller58393c22015-01-07 14:03:30 -0800436 }
Craig Tiller0fcd53c2015-02-18 15:10:53 -0800437 s->ports[i].read_closure.cb = on_read;
438 s->ports[i].read_closure.cb_arg = &s->ports[i];
439 grpc_fd_notify_on_read(s->ports[i].emfd, &s->ports[i].read_closure);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -0800440 s->active_ports++;
441 }
442 gpr_mu_unlock(&s->mu);
443}
Craig Tiller0c0b60c2015-01-21 15:49:28 -0800444
Craig Tiller190d3602015-02-18 09:23:38 -0800445#endif