Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2014, Google Inc. |
| 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 | |
| 34 | #include "src/core/surface/server.h" |
| 35 | |
| 36 | #include <stdlib.h> |
| 37 | #include <string.h> |
| 38 | |
| 39 | #include "src/core/channel/census_filter.h" |
| 40 | #include "src/core/channel/channel_args.h" |
| 41 | #include "src/core/channel/connected_channel.h" |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 42 | #include "src/core/iomgr/iomgr.h" |
Craig Tiller | 485d776 | 2015-01-23 12:54:05 -0800 | [diff] [blame] | 43 | #include "src/core/support/string.h" |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 44 | #include "src/core/surface/call.h" |
| 45 | #include "src/core/surface/channel.h" |
| 46 | #include "src/core/surface/completion_queue.h" |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 47 | #include "src/core/transport/metadata.h" |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 48 | #include <grpc/support/alloc.h> |
| 49 | #include <grpc/support/log.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 50 | #include <grpc/support/useful.h> |
| 51 | |
| 52 | typedef enum { PENDING_START, ALL_CALLS, CALL_LIST_COUNT } call_list; |
| 53 | |
| 54 | typedef struct listener { |
| 55 | void *arg; |
ctiller | 58393c2 | 2015-01-07 14:03:30 -0800 | [diff] [blame] | 56 | void (*start)(grpc_server *server, void *arg, grpc_pollset *pollset); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 57 | void (*destroy)(grpc_server *server, void *arg); |
| 58 | struct listener *next; |
| 59 | } listener; |
| 60 | |
| 61 | typedef struct call_data call_data; |
| 62 | typedef struct channel_data channel_data; |
| 63 | |
| 64 | struct channel_data { |
| 65 | grpc_server *server; |
| 66 | grpc_channel *channel; |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 67 | grpc_mdstr *path_key; |
| 68 | grpc_mdstr *authority_key; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 69 | /* linked list of all channels on a server */ |
| 70 | channel_data *next; |
| 71 | channel_data *prev; |
| 72 | }; |
| 73 | |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 74 | typedef void (*new_call_cb)(grpc_server *server, grpc_completion_queue *cq, |
| 75 | grpc_metadata_array *initial_metadata, |
| 76 | call_data *calld, void *user_data); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 77 | |
| 78 | typedef struct { |
| 79 | void *user_data; |
| 80 | grpc_completion_queue *cq; |
| 81 | grpc_metadata_array *initial_metadata; |
| 82 | new_call_cb cb; |
| 83 | } requested_call; |
| 84 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 85 | struct grpc_server { |
| 86 | size_t channel_filter_count; |
| 87 | const grpc_channel_filter **channel_filters; |
| 88 | grpc_channel_args *channel_args; |
| 89 | grpc_completion_queue *cq; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 90 | |
| 91 | gpr_mu mu; |
| 92 | |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 93 | requested_call *requested_calls; |
| 94 | size_t requested_call_count; |
| 95 | size_t requested_call_capacity; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 96 | |
| 97 | gpr_uint8 shutdown; |
Craig Tiller | 4ffdcd5 | 2015-01-16 11:34:55 -0800 | [diff] [blame] | 98 | gpr_uint8 have_shutdown_tag; |
| 99 | void *shutdown_tag; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 100 | |
| 101 | call_data *lists[CALL_LIST_COUNT]; |
| 102 | channel_data root_channel_data; |
| 103 | |
| 104 | listener *listeners; |
| 105 | gpr_refcount internal_refcount; |
| 106 | }; |
| 107 | |
| 108 | typedef struct { |
| 109 | call_data *next; |
| 110 | call_data *prev; |
| 111 | } call_link; |
| 112 | |
| 113 | typedef enum { |
| 114 | /* waiting for metadata */ |
| 115 | NOT_STARTED, |
| 116 | /* inital metadata read, not flow controlled in yet */ |
| 117 | PENDING, |
| 118 | /* flow controlled in, on completion queue */ |
| 119 | ACTIVATED, |
| 120 | /* cancelled before being queued */ |
| 121 | ZOMBIED |
| 122 | } call_state; |
| 123 | |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 124 | typedef struct legacy_data { grpc_metadata_array client_metadata; } legacy_data; |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 125 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 126 | struct call_data { |
| 127 | grpc_call *call; |
| 128 | |
| 129 | call_state state; |
| 130 | gpr_timespec deadline; |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 131 | grpc_mdstr *path; |
| 132 | grpc_mdstr *host; |
| 133 | |
| 134 | legacy_data *legacy; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 135 | |
| 136 | gpr_uint8 included[CALL_LIST_COUNT]; |
| 137 | call_link links[CALL_LIST_COUNT]; |
| 138 | }; |
| 139 | |
| 140 | #define SERVER_FROM_CALL_ELEM(elem) \ |
| 141 | (((channel_data *)(elem)->channel_data)->server) |
| 142 | |
| 143 | static void do_nothing(void *unused, grpc_op_error ignored) {} |
| 144 | |
| 145 | static int call_list_join(grpc_server *server, call_data *call, |
| 146 | call_list list) { |
| 147 | if (call->included[list]) return 0; |
| 148 | call->included[list] = 1; |
| 149 | if (!server->lists[list]) { |
| 150 | server->lists[list] = call; |
| 151 | call->links[list].next = call->links[list].prev = call; |
| 152 | } else { |
| 153 | call->links[list].next = server->lists[list]; |
| 154 | call->links[list].prev = server->lists[list]->links[list].prev; |
| 155 | call->links[list].next->links[list].prev = |
| 156 | call->links[list].prev->links[list].next = call; |
| 157 | } |
| 158 | return 1; |
| 159 | } |
| 160 | |
| 161 | static call_data *call_list_remove_head(grpc_server *server, call_list list) { |
| 162 | call_data *out = server->lists[list]; |
| 163 | if (out) { |
| 164 | out->included[list] = 0; |
| 165 | if (out->links[list].next == out) { |
| 166 | server->lists[list] = NULL; |
| 167 | } else { |
| 168 | server->lists[list] = out->links[list].next; |
| 169 | out->links[list].next->links[list].prev = out->links[list].prev; |
| 170 | out->links[list].prev->links[list].next = out->links[list].next; |
| 171 | } |
| 172 | } |
| 173 | return out; |
| 174 | } |
| 175 | |
| 176 | static int call_list_remove(grpc_server *server, call_data *call, |
| 177 | call_list list) { |
| 178 | if (!call->included[list]) return 0; |
| 179 | call->included[list] = 0; |
| 180 | if (server->lists[list] == call) { |
| 181 | server->lists[list] = call->links[list].next; |
| 182 | if (server->lists[list] == call) { |
| 183 | server->lists[list] = NULL; |
| 184 | return 1; |
| 185 | } |
| 186 | } |
| 187 | GPR_ASSERT(server->lists[list] != call); |
| 188 | call->links[list].next->links[list].prev = call->links[list].prev; |
| 189 | call->links[list].prev->links[list].next = call->links[list].next; |
| 190 | return 1; |
| 191 | } |
| 192 | |
| 193 | static void server_ref(grpc_server *server) { |
| 194 | gpr_ref(&server->internal_refcount); |
| 195 | } |
| 196 | |
| 197 | static void server_unref(grpc_server *server) { |
| 198 | if (gpr_unref(&server->internal_refcount)) { |
| 199 | grpc_channel_args_destroy(server->channel_args); |
| 200 | gpr_mu_destroy(&server->mu); |
| 201 | gpr_free(server->channel_filters); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 202 | gpr_free(server->requested_calls); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 203 | gpr_free(server); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | static int is_channel_orphaned(channel_data *chand) { |
| 208 | return chand->next == chand; |
| 209 | } |
| 210 | |
| 211 | static void orphan_channel(channel_data *chand) { |
| 212 | chand->next->prev = chand->prev; |
| 213 | chand->prev->next = chand->next; |
| 214 | chand->next = chand->prev = chand; |
| 215 | } |
| 216 | |
ctiller | 58393c2 | 2015-01-07 14:03:30 -0800 | [diff] [blame] | 217 | static void finish_destroy_channel(void *cd, int success) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 218 | channel_data *chand = cd; |
| 219 | grpc_server *server = chand->server; |
| 220 | /*gpr_log(GPR_INFO, "destroy channel %p", chand->channel);*/ |
| 221 | grpc_channel_destroy(chand->channel); |
| 222 | server_unref(server); |
| 223 | } |
| 224 | |
| 225 | static void destroy_channel(channel_data *chand) { |
| 226 | if (is_channel_orphaned(chand)) return; |
| 227 | GPR_ASSERT(chand->server != NULL); |
| 228 | orphan_channel(chand); |
| 229 | server_ref(chand->server); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 230 | grpc_iomgr_add_callback(finish_destroy_channel, chand); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 231 | } |
| 232 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 233 | static void start_new_rpc(grpc_call_element *elem) { |
| 234 | channel_data *chand = elem->channel_data; |
| 235 | call_data *calld = elem->call_data; |
| 236 | grpc_server *server = chand->server; |
| 237 | |
| 238 | gpr_mu_lock(&server->mu); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 239 | if (server->requested_call_count > 0) { |
| 240 | requested_call rc = server->requested_calls[--server->requested_call_count]; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 241 | calld->state = ACTIVATED; |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 242 | gpr_mu_unlock(&server->mu); |
| 243 | rc.cb(server, rc.cq, rc.initial_metadata, calld, rc.user_data); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 244 | } else { |
| 245 | calld->state = PENDING; |
| 246 | call_list_join(server, calld, PENDING_START); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 247 | gpr_mu_unlock(&server->mu); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 248 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 249 | } |
| 250 | |
ctiller | 58393c2 | 2015-01-07 14:03:30 -0800 | [diff] [blame] | 251 | static void kill_zombie(void *elem, int success) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 252 | grpc_call_destroy(grpc_call_from_top_element(elem)); |
| 253 | } |
| 254 | |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 255 | static void stream_closed(grpc_call_element *elem) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 256 | call_data *calld = elem->call_data; |
| 257 | channel_data *chand = elem->channel_data; |
| 258 | gpr_mu_lock(&chand->server->mu); |
| 259 | switch (calld->state) { |
| 260 | case ACTIVATED: |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 261 | grpc_call_stream_closed(elem); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 262 | break; |
| 263 | case PENDING: |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 264 | call_list_remove(chand->server, calld, PENDING_START); |
| 265 | /* fallthrough intended */ |
| 266 | case NOT_STARTED: |
| 267 | calld->state = ZOMBIED; |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 268 | grpc_iomgr_add_callback(kill_zombie, elem); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 269 | break; |
| 270 | case ZOMBIED: |
| 271 | break; |
| 272 | } |
| 273 | gpr_mu_unlock(&chand->server->mu); |
| 274 | } |
| 275 | |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 276 | static void read_closed(grpc_call_element *elem) { |
| 277 | call_data *calld = elem->call_data; |
| 278 | channel_data *chand = elem->channel_data; |
| 279 | gpr_mu_lock(&chand->server->mu); |
| 280 | switch (calld->state) { |
| 281 | case ACTIVATED: |
| 282 | case PENDING: |
| 283 | grpc_call_read_closed(elem); |
| 284 | break; |
| 285 | case NOT_STARTED: |
| 286 | calld->state = ZOMBIED; |
| 287 | grpc_iomgr_add_callback(kill_zombie, elem); |
| 288 | break; |
| 289 | case ZOMBIED: |
| 290 | break; |
| 291 | } |
| 292 | gpr_mu_unlock(&chand->server->mu); |
| 293 | } |
| 294 | |
ctiller | f962f52 | 2014-12-10 15:28:27 -0800 | [diff] [blame] | 295 | static void call_op(grpc_call_element *elem, grpc_call_element *from_elemn, |
| 296 | grpc_call_op *op) { |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 297 | channel_data *chand = elem->channel_data; |
| 298 | call_data *calld = elem->call_data; |
| 299 | grpc_mdelem *md; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 300 | GRPC_CALL_LOG_OP(GPR_INFO, elem, op); |
| 301 | switch (op->type) { |
| 302 | case GRPC_RECV_METADATA: |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 303 | md = op->data.metadata; |
| 304 | if (md->key == chand->path_key) { |
| 305 | calld->path = grpc_mdstr_ref(md->value); |
| 306 | grpc_mdelem_unref(md); |
| 307 | } else if (md->key == chand->authority_key) { |
| 308 | calld->host = grpc_mdstr_ref(md->value); |
| 309 | grpc_mdelem_unref(md); |
| 310 | } else { |
| 311 | grpc_call_recv_metadata(elem, md); |
| 312 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 313 | break; |
| 314 | case GRPC_RECV_END_OF_INITIAL_METADATA: |
| 315 | start_new_rpc(elem); |
| 316 | break; |
| 317 | case GRPC_RECV_MESSAGE: |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 318 | grpc_call_recv_message(elem, op->data.message); |
| 319 | op->done_cb(op->user_data, GRPC_OP_OK); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 320 | break; |
| 321 | case GRPC_RECV_HALF_CLOSE: |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 322 | read_closed(elem); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 323 | break; |
| 324 | case GRPC_RECV_FINISH: |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 325 | stream_closed(elem); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 326 | break; |
| 327 | case GRPC_RECV_DEADLINE: |
| 328 | grpc_call_set_deadline(elem, op->data.deadline); |
| 329 | ((call_data *)elem->call_data)->deadline = op->data.deadline; |
| 330 | break; |
| 331 | default: |
| 332 | GPR_ASSERT(op->dir == GRPC_CALL_DOWN); |
| 333 | grpc_call_next_op(elem, op); |
| 334 | break; |
| 335 | } |
| 336 | } |
| 337 | |
ctiller | f962f52 | 2014-12-10 15:28:27 -0800 | [diff] [blame] | 338 | static void channel_op(grpc_channel_element *elem, |
| 339 | grpc_channel_element *from_elem, grpc_channel_op *op) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 340 | channel_data *chand = elem->channel_data; |
| 341 | |
| 342 | switch (op->type) { |
| 343 | case GRPC_ACCEPT_CALL: |
| 344 | /* create a call */ |
| 345 | grpc_call_create(chand->channel, |
| 346 | op->data.accept_call.transport_server_data); |
| 347 | break; |
| 348 | case GRPC_TRANSPORT_CLOSED: |
| 349 | /* if the transport is closed for a server channel, we destroy the |
| 350 | channel */ |
| 351 | gpr_mu_lock(&chand->server->mu); |
| 352 | server_ref(chand->server); |
| 353 | destroy_channel(chand); |
| 354 | gpr_mu_unlock(&chand->server->mu); |
| 355 | server_unref(chand->server); |
| 356 | break; |
nnoble | 0c475f0 | 2014-12-05 15:37:39 -0800 | [diff] [blame] | 357 | case GRPC_TRANSPORT_GOAWAY: |
| 358 | gpr_slice_unref(op->data.goaway.message); |
| 359 | break; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 360 | default: |
| 361 | GPR_ASSERT(op->dir == GRPC_CALL_DOWN); |
| 362 | grpc_channel_next_op(elem, op); |
| 363 | break; |
| 364 | } |
| 365 | } |
| 366 | |
ctiller | 58393c2 | 2015-01-07 14:03:30 -0800 | [diff] [blame] | 367 | static void finish_shutdown_channel(void *cd, int success) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 368 | channel_data *chand = cd; |
| 369 | grpc_channel_op op; |
nnoble | 0c475f0 | 2014-12-05 15:37:39 -0800 | [diff] [blame] | 370 | op.type = GRPC_CHANNEL_DISCONNECT; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 371 | op.dir = GRPC_CALL_DOWN; |
| 372 | channel_op(grpc_channel_stack_element( |
| 373 | grpc_channel_get_channel_stack(chand->channel), 0), |
ctiller | f962f52 | 2014-12-10 15:28:27 -0800 | [diff] [blame] | 374 | NULL, &op); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 375 | grpc_channel_internal_unref(chand->channel); |
| 376 | } |
| 377 | |
| 378 | static void shutdown_channel(channel_data *chand) { |
| 379 | grpc_channel_internal_ref(chand->channel); |
ctiller | 18b49ab | 2014-12-09 14:39:16 -0800 | [diff] [blame] | 380 | grpc_iomgr_add_callback(finish_shutdown_channel, chand); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | static void init_call_elem(grpc_call_element *elem, |
| 384 | const void *server_transport_data) { |
| 385 | call_data *calld = elem->call_data; |
| 386 | channel_data *chand = elem->channel_data; |
| 387 | memset(calld, 0, sizeof(call_data)); |
| 388 | calld->deadline = gpr_inf_future; |
| 389 | calld->call = grpc_call_from_top_element(elem); |
| 390 | |
| 391 | gpr_mu_lock(&chand->server->mu); |
| 392 | call_list_join(chand->server, calld, ALL_CALLS); |
| 393 | gpr_mu_unlock(&chand->server->mu); |
| 394 | |
| 395 | server_ref(chand->server); |
| 396 | } |
| 397 | |
| 398 | static void destroy_call_elem(grpc_call_element *elem) { |
| 399 | channel_data *chand = elem->channel_data; |
| 400 | int i; |
| 401 | |
| 402 | gpr_mu_lock(&chand->server->mu); |
| 403 | for (i = 0; i < CALL_LIST_COUNT; i++) { |
| 404 | call_list_remove(chand->server, elem->call_data, i); |
| 405 | } |
Craig Tiller | 4ffdcd5 | 2015-01-16 11:34:55 -0800 | [diff] [blame] | 406 | if (chand->server->shutdown && chand->server->have_shutdown_tag && |
| 407 | chand->server->lists[ALL_CALLS] == NULL) { |
| 408 | grpc_cq_end_server_shutdown(chand->server->cq, chand->server->shutdown_tag); |
| 409 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 410 | gpr_mu_unlock(&chand->server->mu); |
| 411 | |
| 412 | server_unref(chand->server); |
| 413 | } |
| 414 | |
| 415 | static void init_channel_elem(grpc_channel_element *elem, |
| 416 | const grpc_channel_args *args, |
| 417 | grpc_mdctx *metadata_context, int is_first, |
| 418 | int is_last) { |
| 419 | channel_data *chand = elem->channel_data; |
| 420 | GPR_ASSERT(is_first); |
| 421 | GPR_ASSERT(!is_last); |
| 422 | chand->server = NULL; |
| 423 | chand->channel = NULL; |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 424 | chand->path_key = grpc_mdstr_from_string(metadata_context, ":path"); |
| 425 | chand->authority_key = grpc_mdstr_from_string(metadata_context, ":authority"); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 426 | chand->next = chand->prev = chand; |
| 427 | } |
| 428 | |
| 429 | static void destroy_channel_elem(grpc_channel_element *elem) { |
| 430 | channel_data *chand = elem->channel_data; |
| 431 | if (chand->server) { |
| 432 | gpr_mu_lock(&chand->server->mu); |
| 433 | chand->next->prev = chand->prev; |
| 434 | chand->prev->next = chand->next; |
| 435 | chand->next = chand->prev = chand; |
| 436 | gpr_mu_unlock(&chand->server->mu); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 437 | grpc_mdstr_unref(chand->path_key); |
| 438 | grpc_mdstr_unref(chand->authority_key); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 439 | server_unref(chand->server); |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | static const grpc_channel_filter server_surface_filter = { |
Yang Gao | 5fd0d29 | 2015-01-26 00:19:48 -0800 | [diff] [blame] | 444 | call_op, channel_op, sizeof(call_data), |
| 445 | init_call_elem, destroy_call_elem, sizeof(channel_data), |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 446 | init_channel_elem, destroy_channel_elem, "server", |
| 447 | }; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 448 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 449 | grpc_server *grpc_server_create_from_filters(grpc_completion_queue *cq, |
| 450 | grpc_channel_filter **filters, |
| 451 | size_t filter_count, |
| 452 | const grpc_channel_args *args) { |
| 453 | size_t i; |
| 454 | int census_enabled = grpc_channel_args_is_census_enabled(args); |
| 455 | |
| 456 | grpc_server *server = gpr_malloc(sizeof(grpc_server)); |
| 457 | memset(server, 0, sizeof(grpc_server)); |
| 458 | |
| 459 | gpr_mu_init(&server->mu); |
| 460 | |
| 461 | server->cq = cq; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 462 | /* decremented by grpc_server_destroy */ |
| 463 | gpr_ref_init(&server->internal_refcount, 1); |
| 464 | server->root_channel_data.next = server->root_channel_data.prev = |
| 465 | &server->root_channel_data; |
| 466 | |
| 467 | /* Server filter stack is: |
| 468 | |
| 469 | server_surface_filter - for making surface API calls |
| 470 | grpc_server_census_filter (optional) - for stats collection and tracing |
| 471 | {passed in filter stack} |
| 472 | grpc_connected_channel_filter - for interfacing with transports */ |
| 473 | server->channel_filter_count = filter_count + 1 + census_enabled; |
| 474 | server->channel_filters = |
| 475 | gpr_malloc(server->channel_filter_count * sizeof(grpc_channel_filter *)); |
| 476 | server->channel_filters[0] = &server_surface_filter; |
| 477 | if (census_enabled) { |
| 478 | server->channel_filters[1] = &grpc_server_census_filter; |
| 479 | } |
| 480 | for (i = 0; i < filter_count; i++) { |
| 481 | server->channel_filters[i + 1 + census_enabled] = filters[i]; |
| 482 | } |
| 483 | |
| 484 | server->channel_args = grpc_channel_args_copy(args); |
| 485 | |
| 486 | return server; |
| 487 | } |
| 488 | |
| 489 | void grpc_server_start(grpc_server *server) { |
| 490 | listener *l; |
| 491 | |
| 492 | for (l = server->listeners; l; l = l->next) { |
ctiller | 58393c2 | 2015-01-07 14:03:30 -0800 | [diff] [blame] | 493 | l->start(server, l->arg, grpc_cq_pollset(server->cq)); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 494 | } |
| 495 | } |
| 496 | |
| 497 | grpc_transport_setup_result grpc_server_setup_transport( |
| 498 | grpc_server *s, grpc_transport *transport, |
| 499 | grpc_channel_filter const **extra_filters, size_t num_extra_filters, |
| 500 | grpc_mdctx *mdctx) { |
| 501 | size_t num_filters = s->channel_filter_count + num_extra_filters + 1; |
| 502 | grpc_channel_filter const **filters = |
| 503 | gpr_malloc(sizeof(grpc_channel_filter *) * num_filters); |
| 504 | size_t i; |
| 505 | grpc_channel *channel; |
| 506 | channel_data *chand; |
| 507 | |
| 508 | for (i = 0; i < s->channel_filter_count; i++) { |
| 509 | filters[i] = s->channel_filters[i]; |
| 510 | } |
| 511 | for (; i < s->channel_filter_count + num_extra_filters; i++) { |
| 512 | filters[i] = extra_filters[i - s->channel_filter_count]; |
| 513 | } |
| 514 | filters[i] = &grpc_connected_channel_filter; |
| 515 | |
ctiller | d79b486 | 2014-12-17 16:36:59 -0800 | [diff] [blame] | 516 | grpc_transport_add_to_pollset(transport, grpc_cq_pollset(s->cq)); |
| 517 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 518 | channel = grpc_channel_create_from_filters(filters, num_filters, |
| 519 | s->channel_args, mdctx, 0); |
| 520 | chand = (channel_data *)grpc_channel_stack_element( |
| 521 | grpc_channel_get_channel_stack(channel), 0)->channel_data; |
| 522 | chand->server = s; |
| 523 | server_ref(s); |
| 524 | chand->channel = channel; |
| 525 | |
| 526 | gpr_mu_lock(&s->mu); |
| 527 | chand->next = &s->root_channel_data; |
| 528 | chand->prev = chand->next->prev; |
| 529 | chand->next->prev = chand->prev->next = chand; |
| 530 | gpr_mu_unlock(&s->mu); |
| 531 | |
| 532 | gpr_free(filters); |
| 533 | |
| 534 | return grpc_connected_channel_bind_transport( |
| 535 | grpc_channel_get_channel_stack(channel), transport); |
| 536 | } |
| 537 | |
Craig Tiller | 4ffdcd5 | 2015-01-16 11:34:55 -0800 | [diff] [blame] | 538 | void shutdown_internal(grpc_server *server, gpr_uint8 have_shutdown_tag, |
| 539 | void *shutdown_tag) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 540 | listener *l; |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 541 | requested_call *requested_calls; |
| 542 | size_t requested_call_count; |
nnoble | 0c475f0 | 2014-12-05 15:37:39 -0800 | [diff] [blame] | 543 | channel_data **channels; |
| 544 | channel_data *c; |
| 545 | size_t nchannels; |
| 546 | size_t i; |
| 547 | grpc_channel_op op; |
| 548 | grpc_channel_element *elem; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 549 | |
| 550 | /* lock, and gather up some stuff to do */ |
| 551 | gpr_mu_lock(&server->mu); |
| 552 | if (server->shutdown) { |
| 553 | gpr_mu_unlock(&server->mu); |
| 554 | return; |
| 555 | } |
| 556 | |
nnoble | 0c475f0 | 2014-12-05 15:37:39 -0800 | [diff] [blame] | 557 | nchannels = 0; |
| 558 | for (c = server->root_channel_data.next; c != &server->root_channel_data; |
| 559 | c = c->next) { |
| 560 | nchannels++; |
| 561 | } |
| 562 | channels = gpr_malloc(sizeof(channel_data *) * nchannels); |
| 563 | i = 0; |
| 564 | for (c = server->root_channel_data.next; c != &server->root_channel_data; |
| 565 | c = c->next) { |
| 566 | grpc_channel_internal_ref(c->channel); |
| 567 | channels[i] = c; |
| 568 | i++; |
| 569 | } |
| 570 | |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 571 | requested_calls = server->requested_calls; |
| 572 | requested_call_count = server->requested_call_count; |
| 573 | server->requested_calls = NULL; |
| 574 | server->requested_call_count = 0; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 575 | |
| 576 | server->shutdown = 1; |
Craig Tiller | 4ffdcd5 | 2015-01-16 11:34:55 -0800 | [diff] [blame] | 577 | server->have_shutdown_tag = have_shutdown_tag; |
| 578 | server->shutdown_tag = shutdown_tag; |
| 579 | if (have_shutdown_tag) { |
| 580 | grpc_cq_begin_op(server->cq, NULL, GRPC_SERVER_SHUTDOWN); |
| 581 | if (server->lists[ALL_CALLS] == NULL) { |
| 582 | grpc_cq_end_server_shutdown(server->cq, shutdown_tag); |
| 583 | } |
| 584 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 585 | gpr_mu_unlock(&server->mu); |
| 586 | |
nnoble | 0c475f0 | 2014-12-05 15:37:39 -0800 | [diff] [blame] | 587 | for (i = 0; i < nchannels; i++) { |
| 588 | c = channels[i]; |
| 589 | elem = grpc_channel_stack_element( |
| 590 | grpc_channel_get_channel_stack(c->channel), 0); |
| 591 | |
| 592 | op.type = GRPC_CHANNEL_GOAWAY; |
| 593 | op.dir = GRPC_CALL_DOWN; |
| 594 | op.data.goaway.status = GRPC_STATUS_OK; |
| 595 | op.data.goaway.message = gpr_slice_from_copied_string("Server shutdown"); |
ctiller | f962f52 | 2014-12-10 15:28:27 -0800 | [diff] [blame] | 596 | elem->filter->channel_op(elem, NULL, &op); |
nnoble | 0c475f0 | 2014-12-05 15:37:39 -0800 | [diff] [blame] | 597 | |
| 598 | grpc_channel_internal_unref(c->channel); |
| 599 | } |
| 600 | gpr_free(channels); |
| 601 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 602 | /* terminate all the requested calls */ |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 603 | for (i = 0; i < requested_call_count; i++) { |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 604 | requested_calls[i].cb(server, requested_calls[i].cq, |
| 605 | requested_calls[i].initial_metadata, NULL, |
| 606 | requested_calls[i].user_data); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 607 | } |
| 608 | gpr_free(requested_calls); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 609 | |
| 610 | /* Shutdown listeners */ |
| 611 | for (l = server->listeners; l; l = l->next) { |
| 612 | l->destroy(server, l->arg); |
| 613 | } |
| 614 | while (server->listeners) { |
| 615 | l = server->listeners; |
| 616 | server->listeners = l->next; |
| 617 | gpr_free(l); |
| 618 | } |
| 619 | } |
| 620 | |
Craig Tiller | 4ffdcd5 | 2015-01-16 11:34:55 -0800 | [diff] [blame] | 621 | void grpc_server_shutdown(grpc_server *server) { |
| 622 | shutdown_internal(server, 0, NULL); |
| 623 | } |
| 624 | |
| 625 | void grpc_server_shutdown_and_notify(grpc_server *server, void *tag) { |
| 626 | shutdown_internal(server, 1, tag); |
| 627 | } |
| 628 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 629 | void grpc_server_destroy(grpc_server *server) { |
| 630 | channel_data *c; |
| 631 | gpr_mu_lock(&server->mu); |
| 632 | for (c = server->root_channel_data.next; c != &server->root_channel_data; |
| 633 | c = c->next) { |
| 634 | shutdown_channel(c); |
| 635 | } |
| 636 | gpr_mu_unlock(&server->mu); |
| 637 | |
| 638 | server_unref(server); |
| 639 | } |
| 640 | |
| 641 | void grpc_server_add_listener(grpc_server *server, void *arg, |
ctiller | 58393c2 | 2015-01-07 14:03:30 -0800 | [diff] [blame] | 642 | void (*start)(grpc_server *server, void *arg, |
| 643 | grpc_pollset *pollset), |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 644 | void (*destroy)(grpc_server *server, void *arg)) { |
| 645 | listener *l = gpr_malloc(sizeof(listener)); |
| 646 | l->arg = arg; |
| 647 | l->start = start; |
| 648 | l->destroy = destroy; |
| 649 | l->next = server->listeners; |
| 650 | server->listeners = l; |
| 651 | } |
| 652 | |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 653 | static grpc_call_error queue_call_request(grpc_server *server, |
| 654 | grpc_completion_queue *cq, |
| 655 | grpc_metadata_array *initial_metadata, |
| 656 | new_call_cb cb, void *user_data) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 657 | call_data *calld; |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 658 | requested_call *rc; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 659 | gpr_mu_lock(&server->mu); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 660 | if (server->shutdown) { |
| 661 | gpr_mu_unlock(&server->mu); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 662 | cb(server, cq, initial_metadata, NULL, user_data); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 663 | return GRPC_CALL_OK; |
| 664 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 665 | calld = call_list_remove_head(server, PENDING_START); |
| 666 | if (calld) { |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 667 | calld->state = ACTIVATED; |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 668 | GPR_ASSERT(calld->state == PENDING); |
| 669 | gpr_mu_unlock(&server->mu); |
| 670 | cb(server, cq, initial_metadata, calld, user_data); |
| 671 | return GRPC_CALL_OK; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 672 | } else { |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 673 | if (server->requested_call_count == server->requested_call_capacity) { |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 674 | server->requested_call_capacity = |
| 675 | GPR_MAX(server->requested_call_capacity + 8, |
| 676 | server->requested_call_capacity * 2); |
| 677 | server->requested_calls = |
| 678 | gpr_realloc(server->requested_calls, |
| 679 | sizeof(requested_call) * server->requested_call_capacity); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 680 | } |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 681 | rc = &server->requested_calls[server->requested_call_count++]; |
| 682 | rc->cb = cb; |
| 683 | rc->cq = cq; |
| 684 | rc->user_data = user_data; |
| 685 | rc->initial_metadata = initial_metadata; |
| 686 | gpr_mu_unlock(&server->mu); |
| 687 | return GRPC_CALL_OK; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 688 | } |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 689 | } |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 690 | |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 691 | static void begin_request(grpc_server *server, grpc_completion_queue *cq, |
| 692 | grpc_metadata_array *initial_metadata, |
| 693 | call_data *call_data, void *tag) { |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 694 | abort(); |
| 695 | } |
| 696 | |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 697 | grpc_call_error grpc_server_request_call(grpc_server *server, |
| 698 | grpc_completion_queue *cq, |
| 699 | grpc_call_details *details, |
| 700 | grpc_metadata_array *initial_metadata, |
| 701 | void *tag) { |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 702 | grpc_cq_begin_op(cq, NULL, GRPC_IOREQ); |
| 703 | return queue_call_request(server, cq, initial_metadata, begin_request, tag); |
| 704 | } |
| 705 | |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 706 | static void publish_legacy_request(grpc_call *call, grpc_op_error status, |
| 707 | void *tag) { |
| 708 | grpc_call_element *elem = |
| 709 | grpc_call_stack_element(grpc_call_get_call_stack(call), 0); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 710 | call_data *calld = elem->call_data; |
| 711 | channel_data *chand = elem->channel_data; |
| 712 | grpc_server *server = chand->server; |
| 713 | |
| 714 | if (status == GRPC_OP_OK) { |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 715 | grpc_cq_end_new_rpc(server->cq, tag, call, do_nothing, NULL, |
| 716 | grpc_mdstr_as_c_string(calld->path), |
| 717 | grpc_mdstr_as_c_string(calld->host), calld->deadline, |
| 718 | calld->legacy->client_metadata.count, |
| 719 | calld->legacy->client_metadata.metadata); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 720 | } |
| 721 | } |
| 722 | |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 723 | static void begin_legacy_request(grpc_server *server, grpc_completion_queue *cq, |
| 724 | grpc_metadata_array *initial_metadata, |
| 725 | call_data *calld, void *tag) { |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 726 | grpc_ioreq req; |
| 727 | if (!calld) { |
| 728 | gpr_free(initial_metadata); |
| 729 | grpc_cq_end_new_rpc(cq, tag, NULL, do_nothing, NULL, NULL, NULL, |
| 730 | gpr_inf_past, 0, NULL); |
| 731 | return; |
| 732 | } |
| 733 | req.op = GRPC_IOREQ_RECV_INITIAL_METADATA; |
| 734 | req.data.recv_metadata = initial_metadata; |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 735 | grpc_call_start_ioreq_and_call_back(calld->call, &req, 1, |
| 736 | publish_legacy_request, tag); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 737 | } |
| 738 | |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 739 | grpc_call_error grpc_server_request_call_old(grpc_server *server, |
| 740 | void *tag_new) { |
| 741 | grpc_metadata_array *client_metadata = |
| 742 | gpr_malloc(sizeof(grpc_metadata_array)); |
Craig Tiller | cce17ac | 2015-01-20 09:29:28 -0800 | [diff] [blame] | 743 | memset(client_metadata, 0, sizeof(*client_metadata)); |
| 744 | grpc_cq_begin_op(server->cq, NULL, GRPC_SERVER_RPC_NEW); |
Craig Tiller | 9f28ac2 | 2015-01-27 17:01:29 -0800 | [diff] [blame^] | 745 | return queue_call_request(server, server->cq, client_metadata, |
| 746 | begin_legacy_request, tag_new); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server) { |
| 750 | return server->channel_args; |
| 751 | } |