ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 3 | * Copyright 2015, Google Inc. |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 4 | * 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 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 34 | #include "src/core/lib/iomgr/tcp_client.h" |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 35 | |
| 36 | #include <errno.h> |
| 37 | #include <netinet/in.h> |
| 38 | #include <string.h> |
| 39 | #include <sys/socket.h> |
| 40 | #include <unistd.h> |
| 41 | |
Craig Tiller | be95249 | 2015-08-25 16:59:00 -0700 | [diff] [blame] | 42 | #include <grpc/grpc.h> |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 43 | #include <grpc/support/alloc.h> |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 44 | #include <grpc/support/log.h> |
| 45 | #include <grpc/support/time.h> |
Craig Tiller | be95249 | 2015-08-25 16:59:00 -0700 | [diff] [blame] | 46 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 47 | #include "src/core/lib/iomgr/iomgr.h" |
Craig Tiller | 8a03448 | 2016-03-28 16:09:04 -0700 | [diff] [blame] | 48 | #include "src/core/lib/iomgr/pollset_set.h" |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 49 | #include "src/core/lib/iomgr/socket_utils_posix.h" |
| 50 | #include "src/core/lib/iomgr/timer.h" |
Craig Tiller | 8ad8a41 | 2015-02-25 08:36:40 -0800 | [diff] [blame] | 51 | #include "test/core/util/test_config.h" |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 52 | |
Craig Tiller | a75d18a | 2016-02-25 08:45:00 -0800 | [diff] [blame] | 53 | static grpc_pollset_set *g_pollset_set; |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 54 | static gpr_mu *g_mu; |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 55 | static grpc_pollset *g_pollset; |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 56 | static int g_connections_complete = 0; |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 57 | static grpc_endpoint *g_connecting = NULL; |
Craig Tiller | b1fa1d5 | 2015-05-11 10:27:53 -0700 | [diff] [blame] | 58 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 59 | static gpr_timespec test_deadline(void) { |
Robbie Shade | ca7effc | 2017-01-17 09:14:29 -0500 | [diff] [blame] | 60 | return grpc_timeout_seconds_to_deadline(10); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 61 | } |
| 62 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 63 | static void finish_connection() { |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 64 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 65 | g_connections_complete++; |
Craig Tiller | 1aee536 | 2016-05-07 11:26:50 -0700 | [diff] [blame] | 66 | GPR_ASSERT( |
| 67 | GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL))); |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 68 | gpr_mu_unlock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 71 | static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, |
| 72 | grpc_error *error) { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 73 | GPR_ASSERT(g_connecting != NULL); |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 74 | GPR_ASSERT(error == GRPC_ERROR_NONE); |
Craig Tiller | cda759d | 2017-01-27 11:37:37 -0800 | [diff] [blame] | 75 | grpc_endpoint_shutdown(exec_ctx, g_connecting, |
| 76 | GRPC_ERROR_CREATE("must_succeed called")); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 77 | grpc_endpoint_destroy(exec_ctx, g_connecting); |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 78 | g_connecting = NULL; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 79 | finish_connection(); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 80 | } |
| 81 | |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 82 | 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] | 83 | GPR_ASSERT(g_connecting == NULL); |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 84 | GPR_ASSERT(error != GRPC_ERROR_NONE); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 85 | finish_connection(); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 86 | } |
| 87 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 88 | void test_succeeds(void) { |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 89 | grpc_resolved_address resolved_addr; |
| 90 | struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 91 | int svr_fd; |
| 92 | int r; |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 93 | int connections_complete_before; |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 94 | grpc_closure done; |
Craig Tiller | f5768a6 | 2015-09-22 10:54:34 -0700 | [diff] [blame] | 95 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 96 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 97 | gpr_log(GPR_DEBUG, "test_succeeds"); |
Craig Tiller | e959335 | 2015-07-15 07:35:09 -0700 | [diff] [blame] | 98 | |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 99 | memset(&resolved_addr, 0, sizeof(resolved_addr)); |
| 100 | resolved_addr.len = sizeof(struct sockaddr_in); |
| 101 | addr->sin_family = AF_INET; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 102 | |
| 103 | /* create a dummy server */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 104 | svr_fd = socket(AF_INET, SOCK_STREAM, 0); |
| 105 | GPR_ASSERT(svr_fd >= 0); |
murgatroid99 | dedb923 | 2016-09-26 13:54:04 -0700 | [diff] [blame] | 106 | GPR_ASSERT( |
| 107 | 0 == bind(svr_fd, (struct sockaddr *)addr, (socklen_t)resolved_addr.len)); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 108 | GPR_ASSERT(0 == listen(svr_fd, 1)); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 109 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 110 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 111 | connections_complete_before = g_connections_complete; |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 112 | gpr_mu_unlock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 113 | |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 114 | /* connect to it */ |
murgatroid99 | dedb923 | 2016-09-26 13:54:04 -0700 | [diff] [blame] | 115 | GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)addr, |
| 116 | (socklen_t *)&resolved_addr.len) == 0); |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 117 | grpc_closure_init(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx); |
Craig Tiller | 30ff60e | 2016-09-23 14:54:27 -0700 | [diff] [blame] | 118 | grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL, |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 119 | &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME)); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 120 | |
| 121 | /* await the connection */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 122 | do { |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 123 | resolved_addr.len = sizeof(addr); |
murgatroid99 | a460192 | 2016-10-12 13:19:40 -0700 | [diff] [blame] | 124 | r = accept(svr_fd, (struct sockaddr *)addr, |
| 125 | (socklen_t *)&resolved_addr.len); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 126 | } while (r == -1 && errno == EINTR); |
| 127 | GPR_ASSERT(r >= 0); |
| 128 | close(r); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 129 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 130 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 131 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 132 | while (g_connections_complete == connections_complete_before) { |
Craig Tiller | d0a8ae1 | 2016-02-18 08:01:19 -0800 | [diff] [blame] | 133 | grpc_pollset_worker *worker = NULL; |
Craig Tiller | 1aee536 | 2016-05-07 11:26:50 -0700 | [diff] [blame] | 134 | GPR_ASSERT(GRPC_LOG_IF_ERROR( |
| 135 | "pollset_work", |
| 136 | grpc_pollset_work(&exec_ctx, g_pollset, &worker, |
| 137 | gpr_now(GPR_CLOCK_MONOTONIC), |
Robbie Shade | ca7effc | 2017-01-17 09:14:29 -0500 | [diff] [blame] | 138 | grpc_timeout_seconds_to_deadline(5)))); |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 139 | gpr_mu_unlock(g_mu); |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 140 | grpc_exec_ctx_flush(&exec_ctx); |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 141 | gpr_mu_lock(g_mu); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 142 | } |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 143 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 144 | gpr_mu_unlock(g_mu); |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 145 | |
| 146 | grpc_exec_ctx_finish(&exec_ctx); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 147 | } |
| 148 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 149 | void test_fails(void) { |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 150 | grpc_resolved_address resolved_addr; |
| 151 | struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 152 | int connections_complete_before; |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 153 | grpc_closure done; |
Craig Tiller | f5768a6 | 2015-09-22 10:54:34 -0700 | [diff] [blame] | 154 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 155 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 156 | gpr_log(GPR_DEBUG, "test_fails"); |
Craig Tiller | e959335 | 2015-07-15 07:35:09 -0700 | [diff] [blame] | 157 | |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 158 | memset(&resolved_addr, 0, sizeof(resolved_addr)); |
| 159 | resolved_addr.len = sizeof(struct sockaddr_in); |
| 160 | addr->sin_family = AF_INET; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 161 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 162 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 163 | connections_complete_before = g_connections_complete; |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 164 | gpr_mu_unlock(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 | /* connect to a broken address */ |
Craig Tiller | 91031da | 2016-12-28 15:44:25 -0800 | [diff] [blame] | 167 | grpc_closure_init(&done, must_fail, NULL, grpc_schedule_on_exec_ctx); |
Craig Tiller | 30ff60e | 2016-09-23 14:54:27 -0700 | [diff] [blame] | 168 | grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL, |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 169 | &resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME)); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 170 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 171 | gpr_mu_lock(g_mu); |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 172 | |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 173 | /* wait for the connection callback to finish */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 174 | while (g_connections_complete == connections_complete_before) { |
Craig Tiller | d0a8ae1 | 2016-02-18 08:01:19 -0800 | [diff] [blame] | 175 | grpc_pollset_worker *worker = NULL; |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 176 | gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); |
| 177 | gpr_timespec polling_deadline = test_deadline(); |
| 178 | if (!grpc_timer_check(&exec_ctx, now, &polling_deadline)) { |
Craig Tiller | 1aee536 | 2016-05-07 11:26:50 -0700 | [diff] [blame] | 179 | GPR_ASSERT(GRPC_LOG_IF_ERROR( |
| 180 | "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, now, |
| 181 | polling_deadline))); |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 182 | } |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 183 | gpr_mu_unlock(g_mu); |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 184 | grpc_exec_ctx_flush(&exec_ctx); |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 185 | gpr_mu_lock(g_mu); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 186 | } |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 187 | |
Craig Tiller | 85371a2 | 2016-02-25 13:55:13 -0800 | [diff] [blame] | 188 | gpr_mu_unlock(g_mu); |
Craig Tiller | 311445f | 2016-02-18 07:31:39 -0800 | [diff] [blame] | 189 | grpc_exec_ctx_finish(&exec_ctx); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 190 | } |
| 191 | |
Craig Tiller | f707d62 | 2016-05-06 14:26:12 -0700 | [diff] [blame] | 192 | static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, |
| 193 | grpc_error *error) { |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 194 | grpc_pollset_destroy(p); |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 195 | } |
Craig Tiller | cb63a9b | 2015-05-13 09:52:36 -0700 | [diff] [blame] | 196 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 197 | int main(int argc, char **argv) { |
Craig Tiller | dfff1b8 | 2015-09-21 14:39:57 -0700 | [diff] [blame] | 198 | grpc_closure destroyed; |
Craig Tiller | f5768a6 | 2015-09-22 10:54:34 -0700 | [diff] [blame] | 199 | grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 200 | grpc_test_init(argc, argv); |
| 201 | grpc_init(); |
Craig Tiller | a75d18a | 2016-02-25 08:45:00 -0800 | [diff] [blame] | 202 | g_pollset_set = grpc_pollset_set_create(); |
Yuchen Zeng | 47de64c | 2017-02-22 19:04:38 -0800 | [diff] [blame] | 203 | g_pollset = gpr_zalloc(grpc_pollset_size()); |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 204 | grpc_pollset_init(g_pollset, &g_mu); |
Craig Tiller | a75d18a | 2016-02-25 08:45:00 -0800 | [diff] [blame] | 205 | grpc_pollset_set_add_pollset(&exec_ctx, g_pollset_set, g_pollset); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 206 | grpc_exec_ctx_finish(&exec_ctx); |
| 207 | test_succeeds(); |
| 208 | gpr_log(GPR_ERROR, "End of first test"); |
| 209 | test_fails(); |
Craig Tiller | 9e5ac1b | 2017-02-14 22:25:50 -0800 | [diff] [blame] | 210 | grpc_pollset_set_destroy(&exec_ctx, g_pollset_set); |
Craig Tiller | d465456 | 2017-01-03 08:45:56 -0800 | [diff] [blame] | 211 | grpc_closure_init(&destroyed, destroy_pollset, g_pollset, |
| 212 | grpc_schedule_on_exec_ctx); |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 213 | grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 214 | grpc_exec_ctx_finish(&exec_ctx); |
| 215 | grpc_shutdown(); |
Craig Tiller | a8be91b | 2016-02-19 16:22:44 -0800 | [diff] [blame] | 216 | gpr_free(g_pollset); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 217 | return 0; |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 218 | } |