ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
murgatroid99 | 1191b72 | 2017-02-08 11:56:52 -0800 | [diff] [blame] | 19 | #include "src/core/lib/iomgr/port.h" |
| 20 | |
| 21 | // This test won't work except with posix sockets enabled |
| 22 | #ifdef GRPC_POSIX_SOCKET |
| 23 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 24 | #include "src/core/lib/iomgr/tcp_client.h" |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 25 | |
| 26 | #include <errno.h> |
| 27 | #include <netinet/in.h> |
| 28 | #include <string.h> |
| 29 | #include <sys/socket.h> |
| 30 | #include <unistd.h> |
| 31 | |
Craig Tiller | be95249 | 2015-08-25 16:59:00 -0700 | [diff] [blame] | 32 | #include <grpc/grpc.h> |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 33 | #include <grpc/support/alloc.h> |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 34 | #include <grpc/support/log.h> |
| 35 | #include <grpc/support/time.h> |
Craig Tiller | be95249 | 2015-08-25 16:59:00 -0700 | [diff] [blame] | 36 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 37 | #include "src/core/lib/iomgr/iomgr.h" |
Craig Tiller | 8a03448 | 2016-03-28 16:09:04 -0700 | [diff] [blame] | 38 | #include "src/core/lib/iomgr/pollset_set.h" |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 39 | #include "src/core/lib/iomgr/socket_utils_posix.h" |
| 40 | #include "src/core/lib/iomgr/timer.h" |
Craig Tiller | 8ad8a41 | 2015-02-25 08:36:40 -0800 | [diff] [blame] | 41 | #include "test/core/util/test_config.h" |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 42 | |
Craig Tiller | a75d18a | 2016-02-25 08:45:00 -0800 | [diff] [blame] | 43 | static grpc_pollset_set *g_pollset_set; |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 44 | static gpr_mu *g_mu; |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 45 | static grpc_pollset *g_pollset; |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 46 | static int g_connections_complete = 0; |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 47 | static grpc_endpoint *g_connecting = NULL; |
Craig Tiller | b1fa1d5 | 2015-05-11 10:27:53 -0700 | [diff] [blame] | 48 | |
Craig Tiller | c0df1c0 | 2017-07-17 16:12:33 -0700 | [diff] [blame] | 49 | static grpc_millis test_deadline(void) { |
Craig Tiller | 9a8c3f3 | 2017-07-21 13:14:14 -0700 | [diff] [blame] | 50 | return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 51 | } |
| 52 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 53 | static void finish_connection() { |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 54 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 55 | g_connections_complete++; |
Craig Tiller | 0ff222a | 2017-09-01 09:41:43 -0700 | [diff] [blame] | 56 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
| 57 | GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick", |
| 58 | grpc_pollset_kick(&exec_ctx, g_pollset, NULL))); |
| 59 | grpc_exec_ctx_finish(&exec_ctx); |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 60 | gpr_mu_unlock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 63 | static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, |
| 64 | grpc_error *error) { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 65 | GPR_ASSERT(g_connecting != NULL); |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 66 | GPR_ASSERT(error == GRPC_ERROR_NONE); |
ncteisen | 4b36a3d | 2017-03-13 19:08:06 -0700 | [diff] [blame] | 67 | grpc_endpoint_shutdown( |
| 68 | exec_ctx, g_connecting, |
| 69 | GRPC_ERROR_CREATE_FROM_STATIC_STRING("must_succeed called")); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 70 | grpc_endpoint_destroy(exec_ctx, g_connecting); |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 71 | g_connecting = NULL; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 72 | finish_connection(); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 73 | } |
| 74 | |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 75 | static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 76 | GPR_ASSERT(g_connecting == NULL); |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 77 | GPR_ASSERT(error != GRPC_ERROR_NONE); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 78 | finish_connection(); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 79 | } |
| 80 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 81 | void test_succeeds(void) { |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 82 | grpc_resolved_address resolved_addr; |
| 83 | struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 84 | int svr_fd; |
| 85 | int r; |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 86 | int connections_complete_before; |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 87 | grpc_closure done; |
Craig Tiller | f5768a6 | 2015-09-22 10:54:34 -0700 | [diff] [blame] | 88 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 89 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 90 | gpr_log(GPR_DEBUG, "test_succeeds"); |
Craig Tiller | e959335 | 2015-07-15 07:35:09 -0700 | [diff] [blame] | 91 | |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 92 | memset(&resolved_addr, 0, sizeof(resolved_addr)); |
| 93 | resolved_addr.len = sizeof(struct sockaddr_in); |
| 94 | addr->sin_family = AF_INET; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 95 | |
| 96 | /* create a dummy server */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 97 | svr_fd = socket(AF_INET, SOCK_STREAM, 0); |
| 98 | GPR_ASSERT(svr_fd >= 0); |
murgatroid99 | dedb923 | 2016-09-26 13:54:04 -0700 | [diff] [blame] | 99 | GPR_ASSERT( |
| 100 | 0 == bind(svr_fd, (struct sockaddr *)addr, (socklen_t)resolved_addr.len)); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 101 | GPR_ASSERT(0 == listen(svr_fd, 1)); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 102 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 103 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 104 | connections_complete_before = g_connections_complete; |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 105 | gpr_mu_unlock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 106 | |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 107 | /* connect to it */ |
murgatroid99 | dedb923 | 2016-09-26 13:54:04 -0700 | [diff] [blame] | 108 | GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)addr, |
| 109 | (socklen_t *)&resolved_addr.len) == 0); |
ncteisen | 274bbbe | 2017-06-08 14:57:11 -0700 | [diff] [blame] | 110 | GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx); |
Craig Tiller | 30ff60e | 2016-09-23 14:54:27 -0700 | [diff] [blame] | 111 | grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL, |
Craig Tiller | c0df1c0 | 2017-07-17 16:12:33 -0700 | [diff] [blame] | 112 | &resolved_addr, GRPC_MILLIS_INF_FUTURE); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 113 | |
| 114 | /* await the connection */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 115 | do { |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 116 | resolved_addr.len = sizeof(addr); |
murgatroid99 | a460192 | 2016-10-12 13:19:40 -0700 | [diff] [blame] | 117 | r = accept(svr_fd, (struct sockaddr *)addr, |
| 118 | (socklen_t *)&resolved_addr.len); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 119 | } while (r == -1 && errno == EINTR); |
| 120 | GPR_ASSERT(r >= 0); |
| 121 | close(r); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 122 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 123 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 124 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 125 | while (g_connections_complete == connections_complete_before) { |
Craig Tiller | d0a8ae1 | 2016-02-18 08:01:19 -0800 | [diff] [blame] | 126 | grpc_pollset_worker *worker = NULL; |
Craig Tiller | 1aee536 | 2016-05-07 11:26:50 -0700 | [diff] [blame] | 127 | GPR_ASSERT(GRPC_LOG_IF_ERROR( |
| 128 | "pollset_work", |
Craig Tiller | 9a8c3f3 | 2017-07-21 13:14:14 -0700 | [diff] [blame] | 129 | grpc_pollset_work(&exec_ctx, g_pollset, &worker, |
| 130 | grpc_timespec_to_millis_round_up( |
| 131 | grpc_timeout_seconds_to_deadline(5))))); |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 132 | gpr_mu_unlock(g_mu); |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 133 | grpc_exec_ctx_flush(&exec_ctx); |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 134 | gpr_mu_lock(g_mu); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 135 | } |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 136 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 137 | gpr_mu_unlock(g_mu); |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 138 | |
| 139 | grpc_exec_ctx_finish(&exec_ctx); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 140 | } |
| 141 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 142 | void test_fails(void) { |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 143 | grpc_resolved_address resolved_addr; |
| 144 | struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 145 | int connections_complete_before; |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 146 | grpc_closure done; |
Craig Tiller | f5768a6 | 2015-09-22 10:54:34 -0700 | [diff] [blame] | 147 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 148 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 149 | gpr_log(GPR_DEBUG, "test_fails"); |
Craig Tiller | e959335 | 2015-07-15 07:35:09 -0700 | [diff] [blame] | 150 | |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 151 | memset(&resolved_addr, 0, sizeof(resolved_addr)); |
| 152 | resolved_addr.len = sizeof(struct sockaddr_in); |
| 153 | addr->sin_family = AF_INET; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 154 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 155 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 156 | connections_complete_before = g_connections_complete; |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 157 | gpr_mu_unlock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 158 | |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 159 | /* connect to a broken address */ |
ncteisen | 274bbbe | 2017-06-08 14:57:11 -0700 | [diff] [blame] | 160 | GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx); |
Craig Tiller | 30ff60e | 2016-09-23 14:54:27 -0700 | [diff] [blame] | 161 | grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL, |
Craig Tiller | c0df1c0 | 2017-07-17 16:12:33 -0700 | [diff] [blame] | 162 | &resolved_addr, GRPC_MILLIS_INF_FUTURE); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 163 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 164 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 165 | |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 166 | /* wait for the connection callback to finish */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 167 | while (g_connections_complete == connections_complete_before) { |
Craig Tiller | d0a8ae1 | 2016-02-18 08:01:19 -0800 | [diff] [blame] | 168 | grpc_pollset_worker *worker = NULL; |
Craig Tiller | c0df1c0 | 2017-07-17 16:12:33 -0700 | [diff] [blame] | 169 | grpc_millis polling_deadline = test_deadline(); |
| 170 | switch (grpc_timer_check(&exec_ctx, &polling_deadline)) { |
Craig Tiller | b2ef1cf | 2017-05-30 09:25:48 -0700 | [diff] [blame] | 171 | case GRPC_TIMERS_FIRED: |
| 172 | break; |
| 173 | case GRPC_TIMERS_NOT_CHECKED: |
Craig Tiller | c0df1c0 | 2017-07-17 16:12:33 -0700 | [diff] [blame] | 174 | polling_deadline = 0; |
Craig Tiller | b2ef1cf | 2017-05-30 09:25:48 -0700 | [diff] [blame] | 175 | /* fall through */ |
| 176 | case GRPC_TIMERS_CHECKED_AND_EMPTY: |
| 177 | GPR_ASSERT(GRPC_LOG_IF_ERROR( |
| 178 | "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, |
Craig Tiller | c0df1c0 | 2017-07-17 16:12:33 -0700 | [diff] [blame] | 179 | polling_deadline))); |
Craig Tiller | b2ef1cf | 2017-05-30 09:25:48 -0700 | [diff] [blame] | 180 | break; |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 181 | } |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 182 | gpr_mu_unlock(g_mu); |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 183 | grpc_exec_ctx_flush(&exec_ctx); |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 184 | gpr_mu_lock(g_mu); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 185 | } |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 186 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 187 | gpr_mu_unlock(g_mu); |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 188 | grpc_exec_ctx_finish(&exec_ctx); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 189 | } |
| 190 | |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 191 | static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, |
| 192 | grpc_error *error) { |
Craig Tiller | f840110 | 2017-04-17 09:47:28 -0700 | [diff] [blame] | 193 | grpc_pollset_destroy(exec_ctx, p); |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 194 | } |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 195 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 196 | int main(int argc, char **argv) { |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 197 | grpc_closure destroyed; |
Craig Tiller | f5768a6 | 2015-09-22 10:54:34 -0700 | [diff] [blame] | 198 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 199 | grpc_test_init(argc, argv); |
| 200 | grpc_init(); |
Craig Tiller | a75d18a | 2016-02-25 08:45:00 -0800 | [diff] [blame] | 201 | g_pollset_set = grpc_pollset_set_create(); |
Yuchen Zeng | 47de64c | 2017-02-22 19:04:38 -0800 | [diff] [blame] | 202 | g_pollset = gpr_zalloc(grpc_pollset_size()); |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 203 | grpc_pollset_init(g_pollset, &g_mu); |
Craig Tiller | a75d18a | 2016-02-25 08:45:00 -0800 | [diff] [blame] | 204 | grpc_pollset_set_add_pollset(&exec_ctx, g_pollset_set, g_pollset); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 205 | grpc_exec_ctx_finish(&exec_ctx); |
| 206 | test_succeeds(); |
| 207 | gpr_log(GPR_ERROR, "End of first test"); |
| 208 | test_fails(); |
Craig Tiller | 9e5ac1b | 2017-02-14 22:25:50 -0800 | [diff] [blame] | 209 | grpc_pollset_set_destroy(&exec_ctx, g_pollset_set); |
ncteisen | 274bbbe | 2017-06-08 14:57:11 -0700 | [diff] [blame] | 210 | GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset, |
Craig Tiller | d465456 | 2017-01-03 08:45:56 -0800 | [diff] [blame] | 211 | grpc_schedule_on_exec_ctx); |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 212 | grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 213 | grpc_exec_ctx_finish(&exec_ctx); |
| 214 | grpc_shutdown(); |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 215 | gpr_free(g_pollset); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 216 | return 0; |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 217 | } |
murgatroid99 | 1191b72 | 2017-02-08 11:56:52 -0800 | [diff] [blame] | 218 | |
| 219 | #else /* GRPC_POSIX_SOCKET */ |
| 220 | |
| 221 | int main(int argc, char **argv) { return 1; } |
| 222 | |
| 223 | #endif /* GRPC_POSIX_SOCKET */ |