From 0c475f0ad78e5848438e1a690b826fe0b6eb26fe Mon Sep 17 00:00:00 2001 From: nnoble Date: Fri, 5 Dec 2014 15:37:39 -0800 Subject: Updating moe_db.txt with the latest equivalence since the ruby import changed the exported structure. Change on 2014/12/01 by nnoble ------------- new [] file for grpc testing. Change on 2014/12/02 by donnadionne ------------- Fix unfinished calls in thread_stress_test. Previously we had an early return if we cancelled a stream part way through a message. Correct this, so that half close and full close signals are propagated up the stack correctly so that higher level state machines can see the termination. Change on 2014/12/02 by ctiller ------------- Remove dependency on internal C code. Change on 2014/12/02 by ctiller ------------- Turn off the flaky bit from thread_stress_test. Change on 2014/12/02 by ctiller ------------- Add test cases of empty request/response, request streaming, response streaming, and half duplex streaming. Bring up the GFE/ESF for mannual test: [] build java/com/google/net/[]/testing/integration/hexa:server_components_env []-bin/java/com/google/net/[]/testing/integration/hexa/server_components_env --manual --rpc_port=25000 --use_autobahn Change on 2014/12/02 by chenw ------------- Make echo/server.c and fling/server.c shutdown cleanly on SIGINT, and update the relevant tests to exercise this mechanism. Now "[] coverage" and the memory leak detector are able to see into the server processes. Change on 2014/12/02 by pmarks ------------- Allow the # of channels to be configurable in this performance test. The threads will use the channels in statically-defined round-robin order (not based on when RPCs complete on any channel). The interesting cases are #channels=1 or #channels=#threads (we previously only had the latter case) Change on 2014/12/02 by vpai ------------- Fixed a typo and reworded a comment. Change on 2014/12/02 by gnezdo ------------- Require the grpc_call in this ClientContext to be NULL before allowing set_call to be invoked. Otherwise, it's an indication of a leak somewhere. Change on 2014/12/02 by vpai ------------- Correctly return status other than ok and add a test for it. Change on 2014/12/02 by yangg ------------- Better C++ guards for grpc_security.h Change on 2014/12/02 by nnoble ------------- Use nullptr instead of NULL for consistency. Change on 2014/12/02 by vpai ------------- Updates the ruby gRPC service class to require the serialization method to be a static method - this brings it inline with the proto3 ruby API - it adds a monkey patch to allow existing proto (beefcake) to continue working. Change on 2014/12/02 by temiola ------------- Adding a buildable unit to the blue print file. Added the buildable unit as its name will be usesd as tap project id. This test will fail right away in tap until tests are actually added. Change on 2014/12/02 by donnadionne ------------- Move interop ESF C++ server from Java to grpc directory. Tests passed: [] test javatests/com/google/net/[]/testing/integration/hexa/... [] test net/grpc/testing/interop/esf_server/... Change on 2014/12/02 by chenw ------------- Return a lame channel as opposed to NULL when secure channel creation fails. - Looks like we're going to need something similar server-side. - I changed the prototype of the lame client channel factory to take an explicit void as I think this is better practice in C. Let me know if you disagree and I will revert these changes. Change on 2014/12/02 by jboeuf ------------- Putting ALPN support where it belongs. Change on 2014/12/02 by jboeuf ------------- GOAWAY send path. Sends a GOAWAY frame when shutting down. This is not read and understood yet. Change on 2014/12/03 by ctiller ------------- Adds support for secure channels and servers. - wraps new C apis (credentials, server_credentials) and Server#add_secure_http_port - adds tests to ensure credentials and server credentials can be created - updates client_server_spec to run the client_server wrapper layer end-to-end tests using a secure channel Change on 2014/12/03 by temiola ------------- Fix existing issues regarding out of order events. At the client side, using pluck as the client_metadata_read can happen anytime after invoke. At the server side, allow halfclose_ok and rpc_end to come in reverse order. Change on 2014/12/03 by yangg ------------- Don't track coverage of tests. Change on 2014/12/03 by ctiller ------------- Change UnaryCall to conform standard test requirement of LargeUnaryCall. Change on 2014/12/03 by yangg ------------- updating alpn version to h2-15 ensure all interop are on the same version and working. Java and go are not ready for h2-16 yet. Change on 2014/12/03 by donnadionne ------------- Add config to bring echo server in []. This is used to test production GFE as its bckend. Change on 2014/12/03 by chenw ------------- In preparation for fixing shutdown race issues, change em to take ownership of the file descriptor. Add an API to grpc_tcp to take an already created grpc_em_fd object, and change tcp_client to use that API. This is needed because otherwise an em user's close() of the file descriptor may race with libevent internals. That's not an issue yet because destroy() frees the events inline, but that can't be done safely if there is a concurrent poller. Change on 2014/12/03 by klempner ------------- Fixing TAP opensource build We don't want to compile and run C++ tests in the C target. Change on 2014/12/03 by nnoble ------------- Move and separate interop tests by languages. Small fixes to the test runner. Improving logging. Change on 2014/12/03 by donnadionne ------------- Fixing the opensource build: -) The C/C++ split wasn't done up to the 'dep' target level -) The alpn.c file was missing from build.json Change on 2014/12/03 by nnoble ------------- Adding blue print files after projects exist Change on 2014/12/03 by donnadionne ------------- Refactor StreamContext using the new completion_queue_pluck API. The dedicated the poller thread has been removed. This CL keeps the current behavior to make it short. There is one following to make it usable for both client and server. The tags for pluck is based on the address of this StreamContext object for potential debug use. The Read/Write and Wait cannot be called concurrently now and this might need to be fixed. Change on 2014/12/03 by yangg ------------- Binary encoding utilities. Support base64 encoding, HPACK static huffman encoding, and doing both at once. Change on 2014/12/03 by ctiller ------------- Enforce Makefile regeneration in presubmits. Change on 2014/12/03 by ctiller ------------- Make CloseSend() send a real zero-length control message to indicate EOS. Change on 2014/12/03 by zhaoq ------------- Prefer to create dualstack sockets for TCP clients and servers, with automatic fallback for environments where IPV6_V6ONLY can't be turned off. Change on 2014/12/03 by pmarks ------------- Add opensource path to build targets. Ensure that MOE is going to run. Change on 2014/12/03 by ctiller ------------- Add PingPong test case. Delete FullDuplex test case. The latter is not specified for client in https://docs.google.com/document/d/1dwrPpIu5EqiKVsquZfoOqTj7vP8fa1i49gornJo50Qw/edit# Change on 2014/12/03 by chenw ------------- Make generate_projects.sh check out the generated targets. Change on 2014/12/03 by ctiller ------------- rspec cleanup - stops declaring specs within the GRPC module - splits Bidi streaming specs into a separate test suite adding tests in the GRPC module was a mistake, it pollutes the module and can affect other tests that run later by the test runner the bidi tests are currently flaky, having them run in their own test suite allows having two separate continuous builds (once ruby gRPC is on GitHub), one that includes bidi where we tolerate flakiness, and another that does not, where there should be no flakiness at all Change on 2014/12/03 by temiola ------------- Adding support for composite and IAM credentials. - For now, we don't do any checks on credentials compatibility in the composite credentials. Maybe we'll add that later. - Refactored the end to end security tests so that we always use the public API (except for the fake security context which is not exposed). Change on 2014/12/03 by jboeuf ------------- Make GPR library buildable in Visual Studio 2013. Change on 2014/12/04 by jtattermusch ------------- Adds codegen for ruby This is being added now that ruby's proto and grpc apis are defined and stable Change on 2014/12/04 by temiola ------------- Prevent NewStream() from sending negative or 0 timeout. Change on 2014/12/04 by zhaoq ------------- Add a grpc_sockaddr_to_string() function, and use it when logging bind failures. Also improve const-correctness in some earlier code. I'm not certain whether inet_ntop() will need any platform-specific implementations, but for now the compiler offers no complaints. Demo: $ []-bin/net/grpc/c/echo_server 1.2.3.4:80 ... tcp_server.c:139] bind addr=[::ffff:1.2.3.4]:80: Permission denied Change on 2014/12/04 by pmarks ------------- Refactoring - moves c wrapped classes to a submodule Google::RPC::Core - this allows for an explicit rule when reading through gRPC ruby code for telling when an object is pure ruby or wrapped C Change on 2014/12/04 by temiola ------------- Fixes the bidi_call [] Change on 2014/12/04 by temiola ------------- Fixing dev build when activating surface traces. Change on 2014/12/04 by nnoble ------------- Updates the tests to reflect that fact that some Credentials compose works. Change on 2014/12/04 by temiola ------------- Making the generate_project_test actually do something. Change on 2014/12/04 by nnoble ------------- Rename "esf_server" to "[]4_server". Delete "test_sever" from Java directory. Change on 2014/12/04 by chenw ------------- Added PHP client interop tests. Tested large_unary against the C++ server. Change on 2014/12/04 by mlumish ------------- Refactor grpc_create_dualstack_socket() by pulling the setsockopt into its own function. This separates the magic test flag from the real fallback logic. Change on 2014/12/04 by pmarks ------------- Fixes the type of the constant used for test cert hostname Change on 2014/12/04 by temiola ------------- Disabling these tests as they're causing flakiness. Change on 2014/12/04 by ctiller ------------- Change intptr --> uintptr. Handles the case where a void* turns into a negative number, which then gets hashed into a negative bucket and segfaults. Change on 2014/12/04 by ctiller ------------- Add a test fixture to force parsers to handle one byte at a time. This should expand coverage and hopefully prevent errors at some point (it seems to pass out of the box for now though). Change on 2014/12/04 by ctiller ------------- The code generator isn't +x. Change on 2014/12/04 by ctiller ------------- Updates math_client and math_server to allow construction using crednetials By: - Extending rpc_server constructor so that it takes a credentials keyword param - Extending client_stub constructor so that it takes a credentials keyword param Change on 2014/12/04 by temiola ------------- Format output a little more nicely. Print each line of output separately - previously logging.info was truncating this at some maximum length, and logs were getting lost. Change on 2014/12/04 by ctiller ------------- Up timeout for this test. Under TSAN, if we process one byte at a time, this timeout can be reached - and I think this is the cause of the following flake: [] Change on 2014/12/05 by ctiller ------------- Adding more error logging for ssl. Change on 2014/12/05 by jboeuf ------------- Read path for goaway. Still need to add hooks to deprecate a channel on the client side when goaway is received. Change on 2014/12/05 by ctiller ------------- Separate accept() into server_accept() and server_end_of_initial_metadata(). This allows servers to initiate reads before finishing writing metadata. Change on 2014/12/05 by ctiller ------------- Fix for breakage 11512317 - adding missing test files. Change on 2014/12/05 by nnoble ------------- grpc c++ server side streaming support. This is based on [] There is a lot of room to clean up the internal implementation which may require refactoring of CompletionQueue. The current cl serves as a working implementation with the missing interfaces. The sample generated files are included and will be removed before submitting. Change on 2014/12/05 by yangg ------------- Changed to the latest timeout format again (search "grpc-timeout" in [] for the spec). Change on 2014/12/05 by zhaoq ------------- Fixing opensource build. Change on 2014/12/05 by nnoble ------------- Making absolutely sure we can do the moe export by adding a sh_test for it. Change on 2014/12/05 by nnoble ------------- Change :scheme psuedo-header from "grpc" to "http" or "https". Change on 2014/12/05 by zhaoq ------------- Add server credential wrapping for c++ server. It only wraps ssl and []2 for now. The ServerCredentials class and the factory class are in a similar fashion as client side wrapping. The difference is the factory method returns shared_ptr instead of unique_ptr as the server builder needs to keep a reference to it for actually creating the server later. The integration will happen in a following cl. Change on 2014/12/05 by yangg ------------- Fixed bugs in new_grpc_docker_builder.sh Change on 2014/12/05 by mlumish ------------- In secure endpoint, hold a refcount for the life of a write callback if the write does not complete immediately. Change on 2014/12/05 by klempner ------------- Add migration support to MOE and have TAP verify it doesn't break. Migration support allows mirroring commits from [] into the git repo, instead of just a dump of the current source. Change on 2014/12/05 by ejona ------------- Change initial window size to 65535 according http2 draft 15. Change on 2014/12/05 by zhaoq ------------- Re-enable the flaky cases in dualstack_socket_test, with additional logging to help track down the problem if it surfaces again. This also seems like a good opportunity to make grpc_socket_utils a separate library, as it's not really specific to TCP. Example output: logspam: [], 26570) resolved 2 addrs in 37ms: logspam: [0] [::1]:26570 logspam: [1] 127.0.0.1:26570 Change on 2014/12/05 by pmarks ------------- Opensource build fixes. -) A function that has a return type should actually return something. -) Don't pass unsigned chars to strlen and strncmp. Change on 2014/12/05 by nnoble ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=81458281 --- src/core/surface/call.c | 68 +++++++++++++++++++++++++++++-------- src/core/surface/channel.c | 11 ++++-- src/core/surface/client.c | 3 ++ src/core/surface/completion_queue.c | 8 ++--- src/core/surface/lame_client.c | 12 +++++-- src/core/surface/lame_client.h | 2 +- src/core/surface/server.c | 41 ++++++++++++++++++++-- src/core/surface/server_chttp2.c | 2 +- 8 files changed, 121 insertions(+), 26 deletions(-) (limited to 'src/core/surface') diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 02c224dabd..a731c7cab7 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -154,7 +154,12 @@ static int prq_pop_to_cq(pending_read_queue *q, void *tag, grpc_call *call, /* the state of a call, based upon which functions have been called against said call */ -typedef enum { CALL_CREATED, CALL_STARTED, CALL_FINISHED } call_state; +typedef enum { + CALL_CREATED, + CALL_BOUNDCQ, + CALL_STARTED, + CALL_FINISHED +} call_state; struct grpc_call { grpc_completion_queue *cq; @@ -404,24 +409,18 @@ grpc_call_error grpc_call_start_invoke(grpc_call *call, return GRPC_CALL_OK; } -grpc_call_error grpc_call_accept(grpc_call *call, grpc_completion_queue *cq, - void *finished_tag, gpr_uint32 flags) { - grpc_call_element *elem; - grpc_call_op op; - +grpc_call_error grpc_call_server_accept(grpc_call *call, + grpc_completion_queue *cq, + void *finished_tag) { /* validate preconditions */ if (call->is_client) { gpr_log(GPR_ERROR, "can only call %s on servers", __FUNCTION__); return GRPC_CALL_ERROR_NOT_ON_CLIENT; } - if (call->state >= CALL_STARTED) { - gpr_log(GPR_ERROR, "call is already invoked"); - return GRPC_CALL_ERROR_ALREADY_INVOKED; - } - - if (flags & GRPC_WRITE_NO_COMPRESS) { - return GRPC_CALL_ERROR_INVALID_FLAGS; + if (call->state >= CALL_BOUNDCQ) { + gpr_log(GPR_ERROR, "call is already accepted"); + return GRPC_CALL_ERROR_ALREADY_ACCEPTED; } /* inform the completion queue of an incoming operation (corresponding to @@ -430,7 +429,7 @@ grpc_call_error grpc_call_accept(grpc_call *call, grpc_completion_queue *cq, /* update state */ gpr_mu_lock(&call->read_mu); - call->state = CALL_STARTED; + call->state = CALL_BOUNDCQ; call->cq = cq; call->finished_tag = finished_tag; if (prq_is_empty(&call->prq) && call->received_finish) { @@ -442,6 +441,32 @@ grpc_call_error grpc_call_accept(grpc_call *call, grpc_completion_queue *cq, } gpr_mu_unlock(&call->read_mu); + return GRPC_CALL_OK; +} + +grpc_call_error grpc_call_server_end_initial_metadata(grpc_call *call, + gpr_uint32 flags) { + grpc_call_element *elem; + grpc_call_op op; + + /* validate preconditions */ + if (call->is_client) { + gpr_log(GPR_ERROR, "can only call %s on servers", __FUNCTION__); + return GRPC_CALL_ERROR_NOT_ON_CLIENT; + } + + if (call->state >= CALL_STARTED) { + gpr_log(GPR_ERROR, "call is already started"); + return GRPC_CALL_ERROR_ALREADY_INVOKED; + } + + if (flags & GRPC_WRITE_NO_COMPRESS) { + return GRPC_CALL_ERROR_INVALID_FLAGS; + } + + /* update state */ + call->state = CALL_STARTED; + /* call down */ op.type = GRPC_SEND_START; op.dir = GRPC_CALL_DOWN; @@ -455,6 +480,17 @@ grpc_call_error grpc_call_accept(grpc_call *call, grpc_completion_queue *cq, return GRPC_CALL_OK; } +grpc_call_error grpc_call_accept(grpc_call *call, grpc_completion_queue *cq, + void *finished_tag, gpr_uint32 flags) { + grpc_call_error err; + + err = grpc_call_server_accept(call, cq, finished_tag); + if (err != GRPC_CALL_OK) return err; + err = grpc_call_server_end_initial_metadata(call, flags); + if (err != GRPC_CALL_OK) return err; + return GRPC_CALL_OK; +} + static void done_writes_done(void *user_data, grpc_op_error error) { grpc_call *call = user_data; void *tag = call->write_tag; @@ -515,6 +551,7 @@ grpc_call_error grpc_call_start_read(grpc_call *call, void *tag) { switch (call->state) { case CALL_CREATED: return GRPC_CALL_ERROR_NOT_INVOKED; + case CALL_BOUNDCQ: case CALL_STARTED: break; case CALL_FINISHED: @@ -559,6 +596,7 @@ grpc_call_error grpc_call_start_write(grpc_call *call, switch (call->state) { case CALL_CREATED: + case CALL_BOUNDCQ: return GRPC_CALL_ERROR_NOT_INVOKED; case CALL_STARTED: break; @@ -607,6 +645,7 @@ grpc_call_error grpc_call_writes_done(grpc_call *call, void *tag) { switch (call->state) { case CALL_CREATED: + case CALL_BOUNDCQ: return GRPC_CALL_ERROR_NOT_INVOKED; case CALL_FINISHED: return GRPC_CALL_ERROR_ALREADY_FINISHED; @@ -646,6 +685,7 @@ grpc_call_error grpc_call_start_write_status(grpc_call *call, switch (call->state) { case CALL_CREATED: + case CALL_BOUNDCQ: return GRPC_CALL_ERROR_NOT_INVOKED; case CALL_FINISHED: return GRPC_CALL_ERROR_ALREADY_FINISHED; diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index ff994257f4..dfb47b3a53 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -127,9 +127,16 @@ void grpc_channel_destroy(grpc_channel *channel) { grpc_channel_op op; grpc_channel_element *elem; - op.type = GRPC_CHANNEL_SHUTDOWN; - op.dir = GRPC_CALL_DOWN; elem = grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0); + + op.type = GRPC_CHANNEL_GOAWAY; + op.dir = GRPC_CALL_DOWN; + op.data.goaway.status = GRPC_STATUS_OK; + op.data.goaway.message = gpr_slice_from_copied_string("Client disconnect"); + elem->filter->channel_op(elem, &op); + + op.type = GRPC_CHANNEL_DISCONNECT; + op.dir = GRPC_CALL_DOWN; elem->filter->channel_op(elem, &op); grpc_channel_internal_unref(channel); diff --git a/src/core/surface/client.c b/src/core/surface/client.c index 26abffa817..f78a45f073 100644 --- a/src/core/surface/client.c +++ b/src/core/surface/client.c @@ -83,6 +83,9 @@ static void channel_op(grpc_channel_element *elem, grpc_channel_op *op) { case GRPC_TRANSPORT_CLOSED: gpr_log(GPR_ERROR, "Transport closed"); break; + case GRPC_TRANSPORT_GOAWAY: + gpr_slice_unref(op->data.goaway.message); + break; default: GPR_ASSERT(op->dir == GRPC_CALL_DOWN); grpc_channel_next_op(elem, op); diff --git a/src/core/surface/completion_queue.c b/src/core/surface/completion_queue.c index a7d611579f..2002476777 100644 --- a/src/core/surface/completion_queue.c +++ b/src/core/surface/completion_queue.c @@ -105,7 +105,7 @@ static event *add_locked(grpc_completion_queue *cc, grpc_completion_type type, void *tag, grpc_call *call, grpc_event_finish_func on_finish, void *user_data) { event *ev = gpr_malloc(sizeof(event)); - gpr_intptr bucket = ((gpr_intptr)tag) % NUM_TAG_BUCKETS; + gpr_uintptr bucket = ((gpr_uintptr)tag) % NUM_TAG_BUCKETS; GPR_ASSERT(!cc->shutdown); ev->base.type = type; ev->base.tag = tag; @@ -260,9 +260,9 @@ grpc_event *grpc_completion_queue_next(grpc_completion_queue *cc, gpr_mu_lock(&cc->em->mu); for (;;) { if (cc->queue != NULL) { - gpr_intptr bucket; + gpr_uintptr bucket; ev = cc->queue; - bucket = ((gpr_intptr)ev->base.tag) % NUM_TAG_BUCKETS; + bucket = ((gpr_uintptr)ev->base.tag) % NUM_TAG_BUCKETS; cc->queue = ev->queue_next; ev->queue_next->queue_prev = ev->queue_prev; ev->queue_prev->queue_next = ev->queue_next; @@ -297,7 +297,7 @@ grpc_event *grpc_completion_queue_next(grpc_completion_queue *cc, } static event *pluck_event(grpc_completion_queue *cc, void *tag) { - gpr_intptr bucket = ((gpr_intptr)tag) % NUM_TAG_BUCKETS; + gpr_uintptr bucket = ((gpr_uintptr)tag) % NUM_TAG_BUCKETS; event *ev = cc->buckets[bucket]; if (ev == NULL) return NULL; do { diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index 18921c44dd..3744b5b6db 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -61,7 +61,15 @@ static void call_op(grpc_call_element *elem, grpc_call_op *op) { op->done_cb(op->user_data, GRPC_OP_ERROR); } -static void channel_op(grpc_channel_element *elem, grpc_channel_op *op) {} +static void channel_op(grpc_channel_element *elem, grpc_channel_op *op) { + switch (op->type) { + case GRPC_CHANNEL_GOAWAY: + gpr_slice_unref(op->data.goaway.message); + break; + default: + break; + } +} static void init_call_elem(grpc_call_element *elem, const void *transport_server_data) {} @@ -87,7 +95,7 @@ static const grpc_channel_filter lame_filter = { "lame-client", }; -grpc_channel *grpc_lame_client_channel_create() { +grpc_channel *grpc_lame_client_channel_create(void) { static const grpc_channel_filter *filters[] = {&lame_filter}; return grpc_channel_create_from_filters(filters, 1, NULL, grpc_mdctx_create(), 1); diff --git a/src/core/surface/lame_client.h b/src/core/surface/lame_client.h index 74b9707202..3cfbf7b954 100644 --- a/src/core/surface/lame_client.h +++ b/src/core/surface/lame_client.h @@ -37,6 +37,6 @@ #include /* Create a lame client: this client fails every operation attempted on it. */ -grpc_channel *grpc_lame_client_channel_create(); +grpc_channel *grpc_lame_client_channel_create(void); #endif /* __GRPC_INTERNAL_SURFACE_LAME_CLIENT_H_ */ diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 99d66ffb2d..d8d5a7adf1 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -331,6 +331,9 @@ static void channel_op(grpc_channel_element *elem, grpc_channel_op *op) { gpr_mu_unlock(&chand->server->mu); server_unref(chand->server); break; + case GRPC_TRANSPORT_GOAWAY: + gpr_slice_unref(op->data.goaway.message); + break; default: GPR_ASSERT(op->dir == GRPC_CALL_DOWN); grpc_channel_next_op(elem, op); @@ -341,7 +344,7 @@ static void channel_op(grpc_channel_element *elem, grpc_channel_op *op) { static void finish_shutdown_channel(void *cd, grpc_em_cb_status status) { channel_data *chand = cd; grpc_channel_op op; - op.type = GRPC_CHANNEL_SHUTDOWN; + op.type = GRPC_CHANNEL_DISCONNECT; op.dir = GRPC_CALL_DOWN; channel_op(grpc_channel_stack_element( grpc_channel_get_channel_stack(chand->channel), 0), @@ -515,10 +518,15 @@ grpc_transport_setup_result grpc_server_setup_transport( } void grpc_server_shutdown(grpc_server *server) { - /* TODO(ctiller): send goaway, etc */ listener *l; void **tags; size_t ntags; + channel_data **channels; + channel_data *c; + size_t nchannels; + size_t i; + grpc_channel_op op; + grpc_channel_element *elem; /* lock, and gather up some stuff to do */ gpr_mu_lock(&server->mu); @@ -527,6 +535,20 @@ void grpc_server_shutdown(grpc_server *server) { return; } + nchannels = 0; + for (c = server->root_channel_data.next; c != &server->root_channel_data; + c = c->next) { + nchannels++; + } + channels = gpr_malloc(sizeof(channel_data *) * nchannels); + i = 0; + for (c = server->root_channel_data.next; c != &server->root_channel_data; + c = c->next) { + grpc_channel_internal_ref(c->channel); + channels[i] = c; + i++; + } + tags = server->tags; ntags = server->ntags; server->tags = NULL; @@ -535,6 +557,21 @@ void grpc_server_shutdown(grpc_server *server) { server->shutdown = 1; gpr_mu_unlock(&server->mu); + for (i = 0; i < nchannels; i++) { + c = channels[i]; + elem = grpc_channel_stack_element( + grpc_channel_get_channel_stack(c->channel), 0); + + op.type = GRPC_CHANNEL_GOAWAY; + op.dir = GRPC_CALL_DOWN; + op.data.goaway.status = GRPC_STATUS_OK; + op.data.goaway.message = gpr_slice_from_copied_string("Server shutdown"); + elem->filter->channel_op(elem, &op); + + grpc_channel_internal_unref(c->channel); + } + gpr_free(channels); + /* terminate all the requested calls */ early_terminate_requested_calls(server->cq, tags, ntags); gpr_free(tags); diff --git a/src/core/surface/server_chttp2.c b/src/core/surface/server_chttp2.c index 24c5757166..db8924efea 100644 --- a/src/core/surface/server_chttp2.c +++ b/src/core/surface/server_chttp2.c @@ -91,7 +91,7 @@ int grpc_server_add_http2_port(grpc_server *server, const char *addr) { for (i = 0; i < resolved->naddrs; i++) { if (grpc_tcp_server_add_port(tcp, (struct sockaddr *)&resolved->addrs[i].addr, - resolved->addrs[i].len) >= 0) { + resolved->addrs[i].len)) { count++; } } -- cgit v1.2.3