Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2016, Google Inc. |
| 3 | // All rights reserved. |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without |
| 6 | // modification, are permitted provided that the following conditions are |
| 7 | // met: |
| 8 | // |
| 9 | // * Redistributions of source code must retain the above copyright |
| 10 | // notice, this list of conditions and the following disclaimer. |
| 11 | // * Redistributions in binary form must reproduce the above |
| 12 | // copyright notice, this list of conditions and the following disclaimer |
| 13 | // in the documentation and/or other materials provided with the |
| 14 | // distribution. |
| 15 | // * Neither the name of Google Inc. nor the names of its |
| 16 | // contributors may be used to endorse or promote products derived from |
| 17 | // this software without specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | // |
| 31 | |
| 32 | #include "src/core/lib/channel/deadline_filter.h" |
| 33 | |
| 34 | #include <stdbool.h> |
| 35 | #include <string.h> |
| 36 | |
Mark D. Roth | f28763c | 2016-09-14 15:18:40 -0700 | [diff] [blame] | 37 | #include <grpc/support/alloc.h> |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 38 | #include <grpc/support/log.h> |
Mark D. Roth | 1bbe6cb | 2016-08-31 08:33:37 -0700 | [diff] [blame] | 39 | #include <grpc/support/sync.h> |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 40 | #include <grpc/support/time.h> |
| 41 | |
Mark D. Roth | f28763c | 2016-09-14 15:18:40 -0700 | [diff] [blame] | 42 | #include "src/core/lib/iomgr/exec_ctx.h" |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 43 | #include "src/core/lib/iomgr/timer.h" |
| 44 | |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 45 | // |
| 46 | // grpc_deadline_state |
| 47 | // |
| 48 | |
| 49 | // Timer callback. |
Mark D. Roth | 932b10c | 2016-09-09 08:44:30 -0700 | [diff] [blame] | 50 | static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg, |
| 51 | grpc_error* error) { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 52 | grpc_call_element* elem = arg; |
| 53 | grpc_deadline_state* deadline_state = elem->call_data; |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 54 | gpr_mu_lock(&deadline_state->timer_mu); |
| 55 | deadline_state->timer_pending = false; |
| 56 | gpr_mu_unlock(&deadline_state->timer_mu); |
| 57 | if (error != GRPC_ERROR_CANCELLED) { |
Mark D. Roth | 75d7478 | 2016-09-09 07:46:01 -0700 | [diff] [blame] | 58 | gpr_slice msg = gpr_slice_from_static_string("Deadline Exceeded"); |
Mark D. Roth | 932b10c | 2016-09-09 08:44:30 -0700 | [diff] [blame] | 59 | grpc_call_element_send_cancel_with_message( |
| 60 | exec_ctx, elem, GRPC_STATUS_DEADLINE_EXCEEDED, &msg); |
Mark D. Roth | 75d7478 | 2016-09-09 07:46:01 -0700 | [diff] [blame] | 61 | gpr_slice_unref(msg); |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 62 | } |
| 63 | GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer"); |
| 64 | } |
| 65 | |
| 66 | // Starts the deadline timer. |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 67 | static void start_timer_if_needed_locked(grpc_exec_ctx* exec_ctx, |
| 68 | grpc_call_element* elem, |
| 69 | gpr_timespec deadline) { |
| 70 | grpc_deadline_state* deadline_state = elem->call_data; |
| 71 | deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); |
| 72 | // Note: We do not start the timer if there is already a timer |
| 73 | // pending. This should be okay, because this is only called from two |
| 74 | // functions exported by this module: grpc_deadline_state_start(), which |
| 75 | // starts the initial timer, and grpc_deadline_state_reset(), which |
| 76 | // cancels any pre-existing timer before starting a new one. In |
| 77 | // particular, we want to ensure that if grpc_deadline_state_start() |
| 78 | // winds up trying to start the timer after grpc_deadline_state_reset() |
| 79 | // has already done so, we ignore the value from the former. |
| 80 | if (!deadline_state->timer_pending && |
| 81 | gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) != 0) { |
| 82 | // Take a reference to the call stack, to be owned by the timer. |
| 83 | GRPC_CALL_STACK_REF(deadline_state->call_stack, "deadline_timer"); |
| 84 | deadline_state->timer_pending = true; |
| 85 | grpc_timer_init(exec_ctx, &deadline_state->timer, deadline, timer_callback, |
| 86 | elem, gpr_now(GPR_CLOCK_MONOTONIC)); |
| 87 | } |
| 88 | } |
Mark D. Roth | 932b10c | 2016-09-09 08:44:30 -0700 | [diff] [blame] | 89 | static void start_timer_if_needed(grpc_exec_ctx* exec_ctx, |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 90 | grpc_call_element* elem, |
| 91 | gpr_timespec deadline) { |
| 92 | grpc_deadline_state* deadline_state = elem->call_data; |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 93 | gpr_mu_lock(&deadline_state->timer_mu); |
| 94 | start_timer_if_needed_locked(exec_ctx, elem, deadline); |
| 95 | gpr_mu_unlock(&deadline_state->timer_mu); |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | // Cancels the deadline timer. |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 99 | static void cancel_timer_if_needed_locked(grpc_exec_ctx* exec_ctx, |
| 100 | grpc_deadline_state* deadline_state) { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 101 | if (deadline_state->timer_pending) { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 102 | grpc_timer_cancel(exec_ctx, &deadline_state->timer); |
| 103 | deadline_state->timer_pending = false; |
| 104 | } |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 105 | } |
| 106 | static void cancel_timer_if_needed(grpc_exec_ctx* exec_ctx, |
| 107 | grpc_deadline_state* deadline_state) { |
| 108 | gpr_mu_lock(&deadline_state->timer_mu); |
| 109 | cancel_timer_if_needed_locked(exec_ctx, deadline_state); |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 110 | gpr_mu_unlock(&deadline_state->timer_mu); |
| 111 | } |
| 112 | |
| 113 | // Callback run when the call is complete. |
Mark D. Roth | 932b10c | 2016-09-09 08:44:30 -0700 | [diff] [blame] | 114 | static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 115 | grpc_deadline_state* deadline_state = arg; |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 116 | cancel_timer_if_needed(exec_ctx, deadline_state); |
| 117 | // Invoke the next callback. |
| 118 | deadline_state->next_on_complete->cb( |
| 119 | exec_ctx, deadline_state->next_on_complete->cb_arg, error); |
| 120 | } |
| 121 | |
| 122 | // Inject our own on_complete callback into op. |
| 123 | static void inject_on_complete_cb(grpc_deadline_state* deadline_state, |
| 124 | grpc_transport_stream_op* op) { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 125 | deadline_state->next_on_complete = op->on_complete; |
| 126 | grpc_closure_init(&deadline_state->on_complete, on_complete, deadline_state); |
| 127 | op->on_complete = &deadline_state->on_complete; |
| 128 | } |
| 129 | |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 130 | void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, |
| 131 | grpc_call_stack* call_stack) { |
| 132 | grpc_deadline_state* deadline_state = elem->call_data; |
| 133 | memset(deadline_state, 0, sizeof(*deadline_state)); |
| 134 | deadline_state->call_stack = call_stack; |
| 135 | gpr_mu_init(&deadline_state->timer_mu); |
| 136 | } |
| 137 | |
| 138 | void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, |
| 139 | grpc_call_element* elem) { |
| 140 | grpc_deadline_state* deadline_state = elem->call_data; |
| 141 | cancel_timer_if_needed(exec_ctx, deadline_state); |
| 142 | gpr_mu_destroy(&deadline_state->timer_mu); |
| 143 | } |
| 144 | |
Mark D. Roth | f28763c | 2016-09-14 15:18:40 -0700 | [diff] [blame] | 145 | // Callback and associated state for starting the timer after call stack |
| 146 | // initialization has been completed. |
| 147 | struct start_timer_after_init_state { |
| 148 | grpc_call_element* elem; |
| 149 | gpr_timespec deadline; |
| 150 | grpc_closure closure; |
| 151 | }; |
| 152 | static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg, |
| 153 | grpc_error* error) { |
| 154 | struct start_timer_after_init_state* state = arg; |
| 155 | start_timer_if_needed(exec_ctx, state->elem, state->deadline); |
| 156 | gpr_free(state); |
| 157 | } |
| 158 | |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 159 | void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, |
| 160 | gpr_timespec deadline) { |
Mark D. Roth | f28763c | 2016-09-14 15:18:40 -0700 | [diff] [blame] | 161 | // Deadline will always be infinite on servers, so the timer will only be |
| 162 | // set on clients with a finite deadline. |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 163 | deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); |
Mark D. Roth | f28763c | 2016-09-14 15:18:40 -0700 | [diff] [blame] | 164 | if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) != 0) { |
| 165 | // When the deadline passes, we indicate the failure by sending down |
| 166 | // an op with cancel_error set. However, we can't send down any ops |
| 167 | // until after the call stack is fully initialized. If we start the |
| 168 | // timer here, we have no guarantee that the timer won't pop before |
| 169 | // call stack initialization is finished. To avoid that problem, we |
| 170 | // create a closure to start the timer, and we schedule that closure |
| 171 | // to be run after call stack initialization is done. |
| 172 | struct start_timer_after_init_state* state = gpr_malloc(sizeof(*state)); |
| 173 | state->elem = elem; |
| 174 | state->deadline = deadline; |
| 175 | grpc_closure_init(&state->closure, start_timer_after_init, state); |
| 176 | grpc_exec_ctx_sched(exec_ctx, &state->closure, GRPC_ERROR_NONE, NULL); |
| 177 | } |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 180 | void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, |
| 181 | gpr_timespec new_deadline) { |
Mark D. Roth | f28763c | 2016-09-14 15:18:40 -0700 | [diff] [blame] | 182 | grpc_deadline_state* deadline_state = elem->call_data; |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 183 | gpr_mu_lock(&deadline_state->timer_mu); |
| 184 | cancel_timer_if_needed_locked(exec_ctx, deadline_state); |
| 185 | start_timer_if_needed_locked(exec_ctx, elem, new_deadline); |
| 186 | gpr_mu_unlock(&deadline_state->timer_mu); |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | void grpc_deadline_state_client_start_transport_stream_op( |
| 190 | grpc_exec_ctx* exec_ctx, grpc_call_element* elem, |
| 191 | grpc_transport_stream_op* op) { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 192 | grpc_deadline_state* deadline_state = elem->call_data; |
| 193 | if (op->cancel_error != GRPC_ERROR_NONE || |
| 194 | op->close_error != GRPC_ERROR_NONE) { |
| 195 | cancel_timer_if_needed(exec_ctx, deadline_state); |
| 196 | } else { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 197 | // Make sure we know when the call is complete, so that we can cancel |
| 198 | // the timer. |
| 199 | if (op->recv_trailing_metadata != NULL) { |
| 200 | inject_on_complete_cb(deadline_state, op); |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | // |
| 206 | // filter code |
| 207 | // |
| 208 | |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 209 | // Constructor for channel_data. Used for both client and server filters. |
| 210 | static void init_channel_elem(grpc_exec_ctx* exec_ctx, |
| 211 | grpc_channel_element* elem, |
| 212 | grpc_channel_element_args* args) { |
| 213 | GPR_ASSERT(!args->is_last); |
| 214 | } |
| 215 | |
| 216 | // Destructor for channel_data. Used for both client and server filters. |
| 217 | static void destroy_channel_elem(grpc_exec_ctx* exec_ctx, |
Mark D. Roth | 932b10c | 2016-09-09 08:44:30 -0700 | [diff] [blame] | 218 | grpc_channel_element* elem) {} |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 219 | |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 220 | // Call data used for both client and server filter. |
| 221 | typedef struct base_call_data { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 222 | grpc_deadline_state deadline_state; |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 223 | } base_call_data; |
| 224 | |
| 225 | // Additional call data used only for the server filter. |
| 226 | typedef struct server_call_data { |
| 227 | base_call_data base; // Must be first. |
| 228 | // The closure for receiving initial metadata. |
| 229 | grpc_closure recv_initial_metadata_ready; |
| 230 | // Received initial metadata batch. |
| 231 | grpc_metadata_batch* recv_initial_metadata; |
| 232 | // The original recv_initial_metadata_ready closure, which we chain to |
| 233 | // after our own closure is invoked. |
| 234 | grpc_closure* next_recv_initial_metadata_ready; |
| 235 | } server_call_data; |
| 236 | |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 237 | // Constructor for call_data. Used for both client and server filters. |
Mark D. Roth | 932b10c | 2016-09-09 08:44:30 -0700 | [diff] [blame] | 238 | static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 239 | grpc_call_element* elem, |
| 240 | grpc_call_element_args* args) { |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 241 | // Note: size of call data is different between client and server. |
Mark D. Roth | f28763c | 2016-09-14 15:18:40 -0700 | [diff] [blame] | 242 | memset(elem->call_data, 0, elem->filter->sizeof_call_data); |
Mark D. Roth | e40dd29 | 2016-10-05 14:58:37 -0700 | [diff] [blame] | 243 | grpc_deadline_state_init(exec_ctx, elem, args->call_stack); |
| 244 | grpc_deadline_state_start(exec_ctx, elem, args->deadline); |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 245 | return GRPC_ERROR_NONE; |
| 246 | } |
| 247 | |
| 248 | // Destructor for call_data. Used for both client and server filters. |
| 249 | static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, |
| 250 | const grpc_call_final_info* final_info, |
| 251 | void* and_free_memory) { |
Mark D. Roth | f28763c | 2016-09-14 15:18:40 -0700 | [diff] [blame] | 252 | grpc_deadline_state_destroy(exec_ctx, elem); |
Mark D. Roth | d2b4533 | 2016-08-26 11:18:00 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 255 | // Method for starting a call op for client filter. |
| 256 | static void client_start_transport_stream_op(grpc_exec_ctx* exec_ctx, |
| 257 | grpc_call_element* elem, |
| 258 | grpc_transport_stream_op* op) { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 259 | grpc_deadline_state_client_start_transport_stream_op(exec_ctx, elem, op); |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 260 | // Chain to next filter. |
| 261 | grpc_call_next_op(exec_ctx, elem, op); |
| 262 | } |
| 263 | |
| 264 | // Callback for receiving initial metadata on the server. |
Mark D. Roth | 932b10c | 2016-09-09 08:44:30 -0700 | [diff] [blame] | 265 | static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg, |
| 266 | grpc_error* error) { |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 267 | grpc_call_element* elem = arg; |
| 268 | server_call_data* calld = elem->call_data; |
| 269 | // Get deadline from metadata and start the timer if needed. |
Mark D. Roth | 932b10c | 2016-09-09 08:44:30 -0700 | [diff] [blame] | 270 | start_timer_if_needed(exec_ctx, elem, calld->recv_initial_metadata->deadline); |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 271 | // Invoke the next callback. |
| 272 | calld->next_recv_initial_metadata_ready->cb( |
| 273 | exec_ctx, calld->next_recv_initial_metadata_ready->cb_arg, error); |
| 274 | } |
| 275 | |
| 276 | // Method for starting a call op for server filter. |
| 277 | static void server_start_transport_stream_op(grpc_exec_ctx* exec_ctx, |
| 278 | grpc_call_element* elem, |
| 279 | grpc_transport_stream_op* op) { |
| 280 | server_call_data* calld = elem->call_data; |
Mark D. Roth | 1bbe6cb | 2016-08-31 08:33:37 -0700 | [diff] [blame] | 281 | if (op->cancel_error != GRPC_ERROR_NONE || |
| 282 | op->close_error != GRPC_ERROR_NONE) { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 283 | cancel_timer_if_needed(exec_ctx, &calld->base.deadline_state); |
Mark D. Roth | 1bbe6cb | 2016-08-31 08:33:37 -0700 | [diff] [blame] | 284 | } else { |
| 285 | // If we're receiving initial metadata, we need to get the deadline |
| 286 | // from the recv_initial_metadata_ready callback. So we inject our |
| 287 | // own callback into that hook. |
| 288 | if (op->recv_initial_metadata_ready != NULL) { |
| 289 | calld->next_recv_initial_metadata_ready = op->recv_initial_metadata_ready; |
| 290 | calld->recv_initial_metadata = op->recv_initial_metadata; |
| 291 | grpc_closure_init(&calld->recv_initial_metadata_ready, |
| 292 | recv_initial_metadata_ready, elem); |
| 293 | op->recv_initial_metadata_ready = &calld->recv_initial_metadata_ready; |
| 294 | } |
| 295 | // Make sure we know when the call is complete, so that we can cancel |
| 296 | // the timer. |
| 297 | // Note that we trigger this on recv_trailing_metadata, even though |
| 298 | // the client never sends trailing metadata, because this is the |
| 299 | // hook that tells us when the call is complete on the server side. |
| 300 | if (op->recv_trailing_metadata != NULL) { |
Mark D. Roth | 72f6da8 | 2016-09-02 13:42:38 -0700 | [diff] [blame] | 301 | inject_on_complete_cb(&calld->base.deadline_state, op); |
Mark D. Roth | 1bbe6cb | 2016-08-31 08:33:37 -0700 | [diff] [blame] | 302 | } |
Mark D. Roth | d2b4533 | 2016-08-26 11:18:00 -0700 | [diff] [blame] | 303 | } |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 304 | // Chain to next filter. |
| 305 | grpc_call_next_op(exec_ctx, elem, op); |
| 306 | } |
| 307 | |
| 308 | const grpc_channel_filter grpc_client_deadline_filter = { |
| 309 | client_start_transport_stream_op, |
| 310 | grpc_channel_next_op, |
| 311 | sizeof(base_call_data), |
| 312 | init_call_elem, |
| 313 | grpc_call_stack_ignore_set_pollset_or_pollset_set, |
| 314 | destroy_call_elem, |
Mark D. Roth | b3405f0a | 2016-09-09 08:46:28 -0700 | [diff] [blame] | 315 | 0, // sizeof(channel_data) |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 316 | init_channel_elem, |
| 317 | destroy_channel_elem, |
| 318 | grpc_call_next_get_peer, |
Mark D. Roth | b2d2488 | 2016-10-27 15:44:07 -0700 | [diff] [blame^] | 319 | grpc_channel_next_get_info, |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 320 | "deadline", |
| 321 | }; |
| 322 | |
| 323 | const grpc_channel_filter grpc_server_deadline_filter = { |
| 324 | server_start_transport_stream_op, |
| 325 | grpc_channel_next_op, |
| 326 | sizeof(server_call_data), |
| 327 | init_call_elem, |
| 328 | grpc_call_stack_ignore_set_pollset_or_pollset_set, |
| 329 | destroy_call_elem, |
Mark D. Roth | b3405f0a | 2016-09-09 08:46:28 -0700 | [diff] [blame] | 330 | 0, // sizeof(channel_data) |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 331 | init_channel_elem, |
| 332 | destroy_channel_elem, |
| 333 | grpc_call_next_get_peer, |
Mark D. Roth | b2d2488 | 2016-10-27 15:44:07 -0700 | [diff] [blame^] | 334 | grpc_channel_next_get_info, |
Mark D. Roth | 14c072c | 2016-08-26 08:31:34 -0700 | [diff] [blame] | 335 | "deadline", |
| 336 | }; |