Merge pull request #908 from ctiller/ssl
Hookup TSI tracer
diff --git a/.travis.yml b/.travis.yml
index b51d2c0..de320b5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,7 @@
- CONFIG=opt TEST=c++
- CONFIG=opt TEST=node
- CONFIG=opt TEST=ruby
+ - CONFIG=opt TEST=python
script:
- rvm use $RUBY_VERSION
- gem install bundler
diff --git a/build.json b/build.json
index e8ecd8e..cfba961 100644
--- a/build.json
+++ b/build.json
@@ -578,6 +578,7 @@
},
{
"name": "census_statistics_multiple_writers_circular_buffer_test",
+ "flaky": true,
"build": "test",
"language": "c",
"src": [
@@ -588,8 +589,7 @@
"grpc",
"gpr_test_util",
"gpr"
- ],
- "flaky": true
+ ]
},
{
"name": "census_statistics_multiple_writers_test",
@@ -635,6 +635,7 @@
},
{
"name": "census_statistics_small_log_test",
+ "flaky": true,
"build": "test",
"language": "c",
"src": [
@@ -645,8 +646,7 @@
"grpc",
"gpr_test_util",
"gpr"
- ],
- "flaky": true
+ ]
},
{
"name": "census_stats_store_test",
@@ -874,8 +874,7 @@
"grpc",
"gpr_test_util",
"gpr"
- ],
- "flaky": true
+ ]
},
{
"name": "fling_test",
@@ -889,8 +888,7 @@
"grpc",
"gpr_test_util",
"gpr"
- ],
- "flaky": true
+ ]
},
{
"name": "gen_hpack_tables",
diff --git a/include/grpc++/status_code_enum.h b/include/grpc++/status_code_enum.h
index 2728fb0..2211c96 100644
--- a/include/grpc++/status_code_enum.h
+++ b/include/grpc++/status_code_enum.h
@@ -37,51 +37,37 @@
namespace grpc {
enum StatusCode {
- /* Not an error; returned on success
-
- HTTP Mapping: 200 OK */
+ /* Not an error; returned on success */
OK = 0,
- /* The operation was cancelled (typically by the caller).
-
- HTTP Mapping: 499 Client Closed Request */
+ /* The operation was cancelled (typically by the caller). */
CANCELLED = 1,
/* Unknown error. An example of where this error may be returned is
if a Status value received from another address space belongs to
an error-space that is not known in this address space. Also
errors raised by APIs that do not return enough error information
- may be converted to this error.
-
- HTTP Mapping: 500 Internal Server Error */
+ may be converted to this error. */
UNKNOWN = 2,
/* Client specified an invalid argument. Note that this differs
from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
that are problematic regardless of the state of the system
- (e.g., a malformed file name).
-
- HTTP Mapping: 400 Bad Request */
+ (e.g., a malformed file name). */
INVALID_ARGUMENT = 3,
/* Deadline expired before operation could complete. For operations
that change the state of the system, this error may be returned
even if the operation has completed successfully. For example, a
successful response from a server could have been delayed long
- enough for the deadline to expire.
-
- HTTP Mapping: 504 Gateway Timeout */
+ enough for the deadline to expire. */
DEADLINE_EXCEEDED = 4,
- /* Some requested entity (e.g., file or directory) was not found.
-
- HTTP Mapping: 404 Not Found */
+ /* Some requested entity (e.g., file or directory) was not found. */
NOT_FOUND = 5,
/* Some entity that we attempted to create (e.g., file or directory)
- already exists.
-
- HTTP Mapping: 409 Conflict */
+ already exists. */
ALREADY_EXISTS = 6,
/* The caller does not have permission to execute the specified
@@ -89,21 +75,15 @@
caused by exhausting some resource (use RESOURCE_EXHAUSTED
instead for those errors). PERMISSION_DENIED must not be
used if the caller can not be identified (use UNAUTHENTICATED
- instead for those errors).
-
- HTTP Mapping: 403 Forbidden */
+ instead for those errors). */
PERMISSION_DENIED = 7,
/* The request does not have valid authentication credentials for the
- operation.
-
- HTTP Mapping: 401 Unauthorized */
+ operation. */
UNAUTHENTICATED = 16,
/* Some resource has been exhausted, perhaps a per-user quota, or
- perhaps the entire file system is out of space.
-
- HTTP Mapping: 429 Too Many Requests */
+ perhaps the entire file system is out of space. */
RESOURCE_EXHAUSTED = 8,
/* Operation was rejected because the system is not in a state
@@ -124,23 +104,14 @@
(d) Use FAILED_PRECONDITION if the client performs conditional
REST Get/Update/Delete on a resource and the resource on the
server does not match the condition. E.g., conflicting
- read-modify-write on the same resource.
-
- HTTP Mapping: 400 Bad Request
-
- NOTE: HTTP spec says 412 Precondition Failed should only be used if
- the request contains Etag related headers. So if the server does see
- Etag related headers in the request, it may choose to return 412
- instead of 400 for this error code. */
+ read-modify-write on the same resource. */
FAILED_PRECONDITION = 9,
/* The operation was aborted, typically due to a concurrency issue
like sequencer check failures, transaction aborts, etc.
See litmus test above for deciding between FAILED_PRECONDITION,
- ABORTED, and UNAVAILABLE.
-
- HTTP Mapping: 409 Conflict */
+ ABORTED, and UNAVAILABLE. */
ABORTED = 10,
/* Operation was attempted past the valid range. E.g., seeking or
@@ -157,21 +128,15 @@
OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific
error) when it applies so that callers who are iterating through
a space can easily look for an OUT_OF_RANGE error to detect when
- they are done.
-
- HTTP Mapping: 400 Bad Request */
+ they are done. */
OUT_OF_RANGE = 11,
- /* Operation is not implemented or not supported/enabled in this service.
-
- HTTP Mapping: 501 Not Implemented */
+ /* Operation is not implemented or not supported/enabled in this service. */
UNIMPLEMENTED = 12,
/* Internal errors. Means some invariants expected by underlying
system has been broken. If you see one of these errors,
- something is very broken.
-
- HTTP Mapping: 500 Internal Server Error */
+ something is very broken. */
INTERNAL = 13,
/* The service is currently unavailable. This is a most likely a
@@ -179,14 +144,10 @@
a backoff.
See litmus test above for deciding between FAILED_PRECONDITION,
- ABORTED, and UNAVAILABLE.
-
- HTTP Mapping: 503 Service Unavailable */
+ ABORTED, and UNAVAILABLE. */
UNAVAILABLE = 14,
- /* Unrecoverable data loss or corruption.
-
- HTTP Mapping: 500 Internal Server Error */
+ /* Unrecoverable data loss or corruption. */
DATA_LOSS = 15,
/* Force users to include a default branch: */
diff --git a/include/grpc/status.h b/include/grpc/status.h
index a1a4d2f..456b900 100644
--- a/include/grpc/status.h
+++ b/include/grpc/status.h
@@ -39,51 +39,37 @@
#endif
typedef enum {
- /* Not an error; returned on success
-
- HTTP Mapping: 200 OK */
+ /* Not an error; returned on success */
GRPC_STATUS_OK = 0,
- /* The operation was cancelled (typically by the caller).
-
- HTTP Mapping: 499 Client Closed Request */
+ /* The operation was cancelled (typically by the caller). */
GRPC_STATUS_CANCELLED = 1,
/* Unknown error. An example of where this error may be returned is
if a Status value received from another address space belongs to
an error-space that is not known in this address space. Also
errors raised by APIs that do not return enough error information
- may be converted to this error.
-
- HTTP Mapping: 500 Internal Server Error */
+ may be converted to this error. */
GRPC_STATUS_UNKNOWN = 2,
/* Client specified an invalid argument. Note that this differs
from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
that are problematic regardless of the state of the system
- (e.g., a malformed file name).
-
- HTTP Mapping: 400 Bad Request */
+ (e.g., a malformed file name). */
GRPC_STATUS_INVALID_ARGUMENT = 3,
/* Deadline expired before operation could complete. For operations
that change the state of the system, this error may be returned
even if the operation has completed successfully. For example, a
successful response from a server could have been delayed long
- enough for the deadline to expire.
-
- HTTP Mapping: 504 Gateway Timeout */
+ enough for the deadline to expire. */
GRPC_STATUS_DEADLINE_EXCEEDED = 4,
- /* Some requested entity (e.g., file or directory) was not found.
-
- HTTP Mapping: 404 Not Found */
+ /* Some requested entity (e.g., file or directory) was not found. */
GRPC_STATUS_NOT_FOUND = 5,
/* Some entity that we attempted to create (e.g., file or directory)
- already exists.
-
- HTTP Mapping: 409 Conflict */
+ already exists. */
GRPC_STATUS_ALREADY_EXISTS = 6,
/* The caller does not have permission to execute the specified
@@ -91,21 +77,15 @@
caused by exhausting some resource (use RESOURCE_EXHAUSTED
instead for those errors). PERMISSION_DENIED must not be
used if the caller can not be identified (use UNAUTHENTICATED
- instead for those errors).
-
- HTTP Mapping: 403 Forbidden */
+ instead for those errors). */
GRPC_STATUS_PERMISSION_DENIED = 7,
/* The request does not have valid authentication credentials for the
- operation.
-
- HTTP Mapping: 401 Unauthorized */
+ operation. */
GRPC_STATUS_UNAUTHENTICATED = 16,
/* Some resource has been exhausted, perhaps a per-user quota, or
- perhaps the entire file system is out of space.
-
- HTTP Mapping: 429 Too Many Requests */
+ perhaps the entire file system is out of space. */
GRPC_STATUS_RESOURCE_EXHAUSTED = 8,
/* Operation was rejected because the system is not in a state
@@ -126,23 +106,14 @@
(d) Use FAILED_PRECONDITION if the client performs conditional
REST Get/Update/Delete on a resource and the resource on the
server does not match the condition. E.g., conflicting
- read-modify-write on the same resource.
-
- HTTP Mapping: 400 Bad Request
-
- NOTE: HTTP spec says 412 Precondition Failed should only be used if
- the request contains Etag related headers. So if the server does see
- Etag related headers in the request, it may choose to return 412
- instead of 400 for this error code. */
+ read-modify-write on the same resource. */
GRPC_STATUS_FAILED_PRECONDITION = 9,
/* The operation was aborted, typically due to a concurrency issue
like sequencer check failures, transaction aborts, etc.
See litmus test above for deciding between FAILED_PRECONDITION,
- ABORTED, and UNAVAILABLE.
-
- HTTP Mapping: 409 Conflict */
+ ABORTED, and UNAVAILABLE. */
GRPC_STATUS_ABORTED = 10,
/* Operation was attempted past the valid range. E.g., seeking or
@@ -159,21 +130,15 @@
OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific
error) when it applies so that callers who are iterating through
a space can easily look for an OUT_OF_RANGE error to detect when
- they are done.
-
- HTTP Mapping: 400 Bad Request */
+ they are done. */
GRPC_STATUS_OUT_OF_RANGE = 11,
- /* Operation is not implemented or not supported/enabled in this service.
-
- HTTP Mapping: 501 Not Implemented */
+ /* Operation is not implemented or not supported/enabled in this service. */
GRPC_STATUS_UNIMPLEMENTED = 12,
/* Internal errors. Means some invariants expected by underlying
system has been broken. If you see one of these errors,
- something is very broken.
-
- HTTP Mapping: 500 Internal Server Error */
+ something is very broken. */
GRPC_STATUS_INTERNAL = 13,
/* The service is currently unavailable. This is a most likely a
@@ -181,14 +146,10 @@
a backoff.
See litmus test above for deciding between FAILED_PRECONDITION,
- ABORTED, and UNAVAILABLE.
-
- HTTP Mapping: 503 Service Unavailable */
+ ABORTED, and UNAVAILABLE. */
GRPC_STATUS_UNAVAILABLE = 14,
- /* Unrecoverable data loss or corruption.
-
- HTTP Mapping: 500 Internal Server Error */
+ /* Unrecoverable data loss or corruption. */
GRPC_STATUS_DATA_LOSS = 15,
/* Force users to include a default branch: */
diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index b8d4aa5..b217c0d 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -237,54 +237,70 @@
"Service", service->name());
{
IndentScope raii_create_server_indent(out);
- map<string, pair<string, string>> method_to_module_and_message;
- out->Print("method_implementations = {\n");
+ map<string, string> method_description_constructors;
+ map<string, pair<string, string>> input_message_modules_and_classes;
+ map<string, pair<string, string>> output_message_modules_and_classes;
for (int i = 0; i < service->method_count(); ++i) {
- IndentScope raii_implementations_indent(out);
- const MethodDescriptor* meth = service->method(i);
- string meth_type =
- string(meth->client_streaming() ? "stream" : "unary") +
- string(meth->server_streaming() ? "_stream" : "_unary") + "_inline";
- out->Print("\"$Method$\": utilities.$Type$(servicer.$Method$),\n",
- "Method", meth->name(),
- "Type", meth_type);
- // Maintain information on the input type of the service method for later
- // use in constructing the service assembly's activated fore link.
- const Descriptor* input_type = meth->input_type();
- pair<string, string> module_and_message;
- if (!GetModuleAndMessagePath(input_type, &module_and_message)) {
+ const MethodDescriptor* method = service->method(i);
+ const string method_description_constructor =
+ string(method->client_streaming() ? "stream_" : "unary_") +
+ string(method->server_streaming() ? "stream_" : "unary_") +
+ "service_description";
+ pair<string, string> input_message_module_and_class;
+ if (!GetModuleAndMessagePath(method->input_type(),
+ &input_message_module_and_class)) {
return false;
}
- method_to_module_and_message.insert(
- make_pair(meth->name(), module_and_message));
+ pair<string, string> output_message_module_and_class;
+ if (!GetModuleAndMessagePath(method->output_type(),
+ &output_message_module_and_class)) {
+ return false;
+ }
+ // Import the modules that define the messages used in RPCs.
+ out->Print("import $Module$\n", "Module",
+ input_message_module_and_class.first);
+ out->Print("import $Module$\n", "Module",
+ output_message_module_and_class.first);
+ method_description_constructors.insert(
+ make_pair(method->name(), method_description_constructor));
+ input_message_modules_and_classes.insert(
+ make_pair(method->name(), input_message_module_and_class));
+ output_message_modules_and_classes.insert(
+ make_pair(method->name(), output_message_module_and_class));
+ }
+ out->Print("method_service_descriptions = {\n");
+ for (auto& name_and_description_constructor :
+ method_description_constructors) {
+ IndentScope raii_descriptions_indent(out);
+ const string method_name = name_and_description_constructor.first;
+ auto input_message_module_and_class =
+ input_message_modules_and_classes.find(method_name);
+ auto output_message_module_and_class =
+ output_message_modules_and_classes.find(method_name);
+ out->Print("\"$Method$\": utilities.$Constructor$(\n", "Method",
+ method_name, "Constructor",
+ name_and_description_constructor.second);
+ {
+ IndentScope raii_description_arguments_indent(out);
+ out->Print("servicer.$Method$,\n", "Method", method_name);
+ out->Print(
+ "$InputTypeModule$.$InputTypeClass$.FromString,\n",
+ "InputTypeModule", input_message_module_and_class->second.first,
+ "InputTypeClass", input_message_module_and_class->second.second);
+ out->Print(
+ "$OutputTypeModule$.$OutputTypeClass$.SerializeToString,\n",
+ "OutputTypeModule", output_message_module_and_class->second.first,
+ "OutputTypeClass", output_message_module_and_class->second.second);
+ }
+ out->Print("),\n");
}
out->Print("}\n");
- // Ensure that we've imported all of the relevant messages.
- for (auto& meth_vals : method_to_module_and_message) {
- out->Print("import $Module$\n",
- "Module", meth_vals.second.first);
- }
- out->Print("request_deserializers = {\n");
- for (auto& meth_vals : method_to_module_and_message) {
- IndentScope raii_serializers_indent(out);
- string full_input_type_path = meth_vals.second.first + "." +
- meth_vals.second.second;
- out->Print("\"$Method$\": $Type$.FromString,\n",
- "Method", meth_vals.first,
- "Type", full_input_type_path);
- }
- out->Print("}\n");
- out->Print("response_serializers = {\n");
- for (auto& meth_vals : method_to_module_and_message) {
- IndentScope raii_serializers_indent(out);
- out->Print("\"$Method$\": lambda x: x.SerializeToString(),\n",
- "Method", meth_vals.first);
- }
- out->Print("}\n");
- out->Print("link = fore.activated_fore_link(port, request_deserializers, "
- "response_serializers, root_certificates, key_chain_pairs)\n");
- out->Print("return implementations.assemble_service("
- "method_implementations, link)\n");
+ // out->Print("return implementations.insecure_server("
+ // "method_service_descriptions, port)\n");
+ out->Print(
+ "return implementations.secure_server("
+ "method_service_descriptions, port, root_certificates,"
+ " key_chain_pairs)\n");
}
return true;
}
@@ -296,66 +312,74 @@
out->Print(dict, "def early_adopter_create_$Service$_stub(host, port):\n");
{
IndentScope raii_create_server_indent(out);
- map<string, pair<string, string>> method_to_module_and_message;
- out->Print("method_implementations = {\n");
+ map<string, string> method_description_constructors;
+ map<string, pair<string, string>> input_message_modules_and_classes;
+ map<string, pair<string, string>> output_message_modules_and_classes;
for (int i = 0; i < service->method_count(); ++i) {
- IndentScope raii_implementations_indent(out);
- const MethodDescriptor* meth = service->method(i);
- string meth_type =
- string(meth->client_streaming() ? "stream" : "unary") +
- string(meth->server_streaming() ? "_stream" : "_unary") + "_inline";
- // TODO(atash): once the expected input to assemble_dynamic_inline_stub is
- // cleaned up, change this to the expected argument's dictionary values.
- out->Print("\"$Method$\": utilities.$Type$(None),\n",
- "Method", meth->name(),
- "Type", meth_type);
- // Maintain information on the input type of the service method for later
- // use in constructing the service assembly's activated fore link.
- const Descriptor* output_type = meth->output_type();
- pair<string, string> module_and_message;
- if (!GetModuleAndMessagePath(output_type, &module_and_message)) {
+ const MethodDescriptor* method = service->method(i);
+ const string method_description_constructor =
+ string(method->client_streaming() ? "stream_" : "unary_") +
+ string(method->server_streaming() ? "stream_" : "unary_") +
+ "invocation_description";
+ pair<string, string> input_message_module_and_class;
+ if (!GetModuleAndMessagePath(method->input_type(),
+ &input_message_module_and_class)) {
return false;
}
- method_to_module_and_message.insert(
- make_pair(meth->name(), module_and_message));
+ pair<string, string> output_message_module_and_class;
+ if (!GetModuleAndMessagePath(method->output_type(),
+ &output_message_module_and_class)) {
+ return false;
+ }
+ // Import the modules that define the messages used in RPCs.
+ out->Print("import $Module$\n", "Module",
+ input_message_module_and_class.first);
+ out->Print("import $Module$\n", "Module",
+ output_message_module_and_class.first);
+ method_description_constructors.insert(
+ make_pair(method->name(), method_description_constructor));
+ input_message_modules_and_classes.insert(
+ make_pair(method->name(), input_message_module_and_class));
+ output_message_modules_and_classes.insert(
+ make_pair(method->name(), output_message_module_and_class));
+ }
+ out->Print("method_invocation_descriptions = {\n");
+ for (auto& name_and_description_constructor :
+ method_description_constructors) {
+ IndentScope raii_descriptions_indent(out);
+ const string method_name = name_and_description_constructor.first;
+ auto input_message_module_and_class =
+ input_message_modules_and_classes.find(method_name);
+ auto output_message_module_and_class =
+ output_message_modules_and_classes.find(method_name);
+ out->Print("\"$Method$\": utilities.$Constructor$(\n", "Method",
+ method_name, "Constructor",
+ name_and_description_constructor.second);
+ {
+ IndentScope raii_description_arguments_indent(out);
+ out->Print(
+ "$InputTypeModule$.$InputTypeClass$.SerializeToString,\n",
+ "InputTypeModule", input_message_module_and_class->second.first,
+ "InputTypeClass", input_message_module_and_class->second.second);
+ out->Print(
+ "$OutputTypeModule$.$OutputTypeClass$.FromString,\n",
+ "OutputTypeModule", output_message_module_and_class->second.first,
+ "OutputTypeClass", output_message_module_and_class->second.second);
+ }
+ out->Print("),\n");
}
out->Print("}\n");
- // Ensure that we've imported all of the relevant messages.
- for (auto& meth_vals : method_to_module_and_message) {
- out->Print("import $Module$\n",
- "Module", meth_vals.second.first);
- }
- out->Print("response_deserializers = {\n");
- for (auto& meth_vals : method_to_module_and_message) {
- IndentScope raii_serializers_indent(out);
- string full_output_type_path = meth_vals.second.first + "." +
- meth_vals.second.second;
- out->Print("\"$Method$\": $Type$.FromString,\n",
- "Method", meth_vals.first,
- "Type", full_output_type_path);
- }
- out->Print("}\n");
- out->Print("request_serializers = {\n");
- for (auto& meth_vals : method_to_module_and_message) {
- IndentScope raii_serializers_indent(out);
- out->Print("\"$Method$\": lambda x: x.SerializeToString(),\n",
- "Method", meth_vals.first);
- }
- out->Print("}\n");
- out->Print("link = rear.activated_rear_link("
- "host, port, request_serializers, response_deserializers)\n");
- out->Print("return implementations.assemble_dynamic_inline_stub("
- "method_implementations, link)\n");
+ out->Print(
+ "return implementations.insecure_stub("
+ "method_invocation_descriptions, host, port)\n");
}
return true;
}
bool PrintPreamble(const FileDescriptor* file, Printer* out) {
out->Print("import abc\n");
- out->Print("from grpc._adapter import fore\n");
- out->Print("from grpc._adapter import rear\n");
- out->Print("from grpc.framework.assembly import implementations\n");
- out->Print("from grpc.framework.assembly import utilities\n");
+ out->Print("from grpc.early_adopter import implementations\n");
+ out->Print("from grpc.early_adopter import utilities\n");
return true;
}
diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c
index fa18655..62611e0 100644
--- a/src/core/channel/connected_channel.c
+++ b/src/core/channel/connected_channel.c
@@ -48,12 +48,12 @@
/* the protobuf library will (by default) start warning at 100megs */
#define DEFAULT_MAX_MESSAGE_LENGTH (100 * 1024 * 1024)
-typedef struct {
+typedef struct connected_channel_channel_data {
grpc_transport *transport;
gpr_uint32 max_message_length;
} channel_data;
-typedef struct {
+typedef struct connected_channel_call_data {
grpc_call_element *elem;
grpc_stream_op_buffer outgoing_sopb;
diff --git a/src/core/surface/completion_queue.c b/src/core/surface/completion_queue.c
index c4b8d60..6a1d83c 100644
--- a/src/core/surface/completion_queue.c
+++ b/src/core/surface/completion_queue.c
@@ -71,6 +71,7 @@
grpc_pollset pollset;
/* 0 initially, 1 once we've begun shutting down */
int shutdown;
+ int shutdown_called;
/* Head of a linked list of queued events (prev points to the last element) */
event *queue;
/* Fixed size chained hash table of events for pluck() */
@@ -107,7 +108,6 @@
grpc_event_finish_func on_finish, void *user_data) {
event *ev = gpr_malloc(sizeof(event));
gpr_uintptr bucket = ((gpr_uintptr)tag) % NUM_TAG_BUCKETS;
- GPR_ASSERT(!cc->shutdown);
ev->base.type = type;
ev->base.tag = tag;
ev->base.call = call;
@@ -150,6 +150,7 @@
#endif
if (gpr_unref(&cc->refs)) {
GPR_ASSERT(!cc->shutdown);
+ GPR_ASSERT(cc->shutdown_called);
cc->shutdown = 1;
gpr_cv_broadcast(GRPC_POLLSET_CV(&cc->pollset));
}
@@ -380,6 +381,10 @@
/* Shutdown simply drops a ref that we reserved at creation time; if we drop
to zero here, then enter shutdown mode and wake up any waiters */
void grpc_completion_queue_shutdown(grpc_completion_queue *cc) {
+ gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset));
+ cc->shutdown_called = 1;
+ gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset));
+
if (gpr_unref(&cc->refs)) {
gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset));
GPR_ASSERT(!cc->shutdown);
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index 1c5efca..0d01a37 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -310,6 +310,7 @@
static int prepare_callbacks(transport *t);
static void run_callbacks(transport *t, const grpc_transport_callbacks *cb);
+static void call_cb_closed(transport *t, const grpc_transport_callbacks *cb);
static int prepare_write(transport *t);
static void perform_write(transport *t, grpc_endpoint *ep);
@@ -517,13 +518,29 @@
static void destroy_transport(grpc_transport *gt) {
transport *t = (transport *)gt;
- gpr_mu_lock(&t->mu);
+ lock(t);
t->destroying = 1;
- while (t->calling_back) {
+ /* Wait for pending stuff to finish.
+ We need to be not calling back to ensure that closed() gets a chance to
+ trigger if needed during unlock() before we die.
+ We need to be not writing as cancellation finalization may produce some
+ callbacks that NEED to be made to close out some streams when t->writing
+ becomes 0. */
+ while (t->calling_back || t->writing) {
gpr_cv_wait(&t->cv, &t->mu, gpr_inf_future);
}
- t->cb = NULL;
- gpr_mu_unlock(&t->mu);
+ drop_connection(t);
+ unlock(t);
+
+ /* The drop_connection() above puts the transport into an error state, and
+ the follow-up unlock should then (as part of the cleanup work it does)
+ ensure that cb is NULL, and therefore not call back anything further.
+ This check validates this very subtle behavior.
+ It's shutdown path, so I don't believe an extra lock pair is going to be
+ problematic for performance. */
+ lock(t);
+ GPR_ASSERT(!t->cb);
+ unlock(t);
unref_transport(t);
}
@@ -681,6 +698,7 @@
}
static void stream_list_join(transport *t, stream *s, stream_list_id id) {
+ if (id == PENDING_CALLBACKS) GPR_ASSERT(t->cb != NULL || t->error_state == ERROR_STATE_NONE);
if (s->included[id]) {
return;
}
@@ -739,7 +757,7 @@
if (perform_callbacks) {
t->calling_back = 1;
}
- if (t->error_state == ERROR_STATE_SEEN) {
+ if (t->error_state == ERROR_STATE_SEEN && !t->writing) {
call_closed = 1;
t->calling_back = 1;
t->cb = NULL; /* no more callbacks */
@@ -773,7 +791,7 @@
}
if (call_closed) {
- cb->closed(t->cb_user_data, &t->base);
+ call_cb_closed(t, cb);
}
/* write some bytes if necessary */
@@ -904,13 +922,16 @@
}
while ((s = stream_list_remove_head(t, WRITTEN_CLOSED))) {
s->sent_write_closed = 1;
- stream_list_join(t, s, PENDING_CALLBACKS);
+ if (!s->cancelled) stream_list_join(t, s, PENDING_CALLBACKS);
}
t->outbuf.count = 0;
t->outbuf.length = 0;
/* leave the writing flag up on shutdown to prevent further writes in unlock()
from starting */
t->writing = 0;
+ if (t->destroying) {
+ gpr_cv_signal(&t->cv);
+ }
if (!t->reading) {
grpc_endpoint_destroy(t->ep);
t->ep = NULL;
@@ -980,7 +1001,8 @@
} else {
grpc_sopb_append(&t->nuke_later_sopb, ops, ops_count);
}
- if (is_last && s->outgoing_sopb.nops == 0 && s->read_closed) {
+ if (is_last && s->outgoing_sopb.nops == 0 && s->read_closed &&
+ !s->published_close) {
stream_list_join(t, s, PENDING_CALLBACKS);
}
@@ -1766,6 +1788,10 @@
}
}
+static void call_cb_closed(transport *t, const grpc_transport_callbacks *cb) {
+ cb->closed(t->cb_user_data, &t->base);
+}
+
static void add_to_pollset(grpc_transport *gt, grpc_pollset *pollset) {
transport *t = (transport *)gt;
lock(t);
diff --git a/src/csharp/Grpc.Core/StatusCode.cs b/src/csharp/Grpc.Core/StatusCode.cs
index 1fbf9c1..1987e52 100644
--- a/src/csharp/Grpc.Core/StatusCode.cs
+++ b/src/csharp/Grpc.Core/StatusCode.cs
@@ -41,64 +41,44 @@
/// </summary>
public enum StatusCode
{
- /* Not an error; returned on success
-
- HTTP Mapping: 200 OK */
+ /* Not an error; returned on success */
OK = 0,
- /* The operation was cancelled (typically by the caller).
-
- HTTP Mapping: 499 Client Closed Request */
+ /* The operation was cancelled (typically by the caller). */
Cancelled = 1,
/* Unknown error. An example of where this error may be returned is
if a Status value received from another address space belongs to
an error-space that is not known in this address space. Also
errors raised by APIs that do not return enough error information
- may be converted to this error.
-
- HTTP Mapping: 500 Internal Server Error */
+ may be converted to this error. */
Unknown = 2,
/* Client specified an invalid argument. Note that this differs
from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
that are problematic regardless of the state of the system
- (e.g., a malformed file name).
-
- HTTP Mapping: 400 Bad Request */
+ (e.g., a malformed file name). */
InvalidArgument = 3,
/* Deadline expired before operation could complete. For operations
that change the state of the system, this error may be returned
even if the operation has completed successfully. For example, a
successful response from a server could have been delayed long
- enough for the deadline to expire.
-
- HTTP Mapping: 504 Gateway Timeout */
+ enough for the deadline to expire. */
DeadlineExceeded = 4,
- /* Some requested entity (e.g., file or directory) was not found.
-
- HTTP Mapping: 404 Not Found */
+ /* Some requested entity (e.g., file or directory) was not found. */
NotFound = 5,
/* Some entity that we attempted to create (e.g., file or directory)
- already exists.
-
- HTTP Mapping: 409 Conflict */
+ already exists. */
AlreadyExists = 6,
/* The caller does not have permission to execute the specified
operation. PERMISSION_DENIED must not be used for rejections
caused by exhausting some resource (use RESOURCE_EXHAUSTED
instead for those errors). PERMISSION_DENIED must not be
used if the caller can not be identified (use UNAUTHENTICATED
- instead for those errors).
-
- HTTP Mapping: 403 Forbidden */
+ instead for those errors). */
PermissionDenied = 7,
/* The request does not have valid authentication credentials for the
- operation.
-
- HTTP Mapping: 401 Unauthorized */
+ operation. */
Unauthenticated = 16,
/* Some resource has been exhausted, perhaps a per-user quota, or
- perhaps the entire file system is out of space.
-
- HTTP Mapping: 429 Too Many Requests */
+ perhaps the entire file system is out of space. */
ResourceExhausted = 8,
/* Operation was rejected because the system is not in a state
required for the operation's execution. For example, directory
@@ -118,22 +98,13 @@
(d) Use FAILED_PRECONDITION if the client performs conditional
REST Get/Update/Delete on a resource and the resource on the
server does not match the condition. E.g., conflicting
- read-modify-write on the same resource.
-
- HTTP Mapping: 400 Bad Request
-
- NOTE: HTTP spec says 412 Precondition Failed should only be used if
- the request contains Etag related headers. So if the server does see
- Etag related headers in the request, it may choose to return 412
- instead of 400 for this error code. */
+ read-modify-write on the same resource. */
FailedPrecondition = 9,
/* The operation was aborted, typically due to a concurrency issue
like sequencer check failures, transaction aborts, etc.
See litmus test above for deciding between FAILED_PRECONDITION,
- ABORTED, and UNAVAILABLE.
-
- HTTP Mapping: 409 Conflict */
+ ABORTED, and UNAVAILABLE. */
Aborted = 10,
/* Operation was attempted past the valid range. E.g., seeking or
reading past end of file.
@@ -149,32 +120,22 @@
OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific
error) when it applies so that callers who are iterating through
a space can easily look for an OUT_OF_RANGE error to detect when
- they are done.
-
- HTTP Mapping: 400 Bad Request */
+ they are done. */
OutOfRange = 11,
- /* Operation is not implemented or not supported/enabled in this service.
-
- HTTP Mapping: 501 Not Implemented */
+ /* Operation is not implemented or not supported/enabled in this service. */
Unimplemented = 12,
/* Internal errors. Means some invariants expected by underlying
system has been broken. If you see one of these errors,
- something is very broken.
-
- HTTP Mapping: 500 Internal Server Error */
+ something is very broken. */
Internal = 13,
/* The service is currently unavailable. This is a most likely a
transient condition and may be corrected by retrying with
a backoff.
See litmus test above for deciding between FAILED_PRECONDITION,
- ABORTED, and UNAVAILABLE.
-
- HTTP Mapping: 503 Service Unavailable */
+ ABORTED, and UNAVAILABLE. */
Unavailable = 14,
- /* Unrecoverable data loss or corruption.
-
- HTTP Mapping: 500 Internal Server Error */
+ /* Unrecoverable data loss or corruption. */
DataLoss = 15
}
}
diff --git a/src/csharp/README.md b/src/csharp/README.md
old mode 100755
new mode 100644
diff --git a/src/php/README.md b/src/php/README.md
old mode 100755
new mode 100644
diff --git a/src/php/tests/data/README b/src/php/tests/data/README
old mode 100755
new mode 100644
diff --git a/src/python/README.md b/src/python/README.md
old mode 100755
new mode 100644
diff --git a/src/python/interop/interop/credentials/README b/src/python/interop/interop/credentials/README
old mode 100755
new mode 100644
diff --git a/src/python/src/setup.py b/src/python/src/setup.py
index 26121dc..cdb82a9 100644
--- a/src/python/src/setup.py
+++ b/src/python/src/setup.py
@@ -47,8 +47,9 @@
)
_EXTENSION_LIBRARIES = (
- 'gpr',
'grpc',
+ 'gpr',
+ 'rt',
)
_EXTENSION_MODULE = _core.Extension(
diff --git a/src/ruby/README.md b/src/ruby/README.md
old mode 100755
new mode 100644
diff --git a/src/ruby/bin/interop/README.md b/src/ruby/bin/interop/README.md
old mode 100755
new mode 100644
diff --git a/src/ruby/spec/testdata/README b/src/ruby/spec/testdata/README
old mode 100755
new mode 100644
diff --git a/test/compiler/python_plugin_test.py b/test/compiler/python_plugin_test.py
index 1981f49..f166828 100644
--- a/test/compiler/python_plugin_test.py
+++ b/test/compiler/python_plugin_test.py
@@ -37,7 +37,7 @@
import time
import unittest
-from grpc.framework.face import exceptions
+from grpc.early_adopter import exceptions
from grpc.framework.foundation import future
# Identifiers of entities we expect to find in the generated module.
diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c
index d953552..ffc651a 100644
--- a/test/core/end2end/no_server_test.c
+++ b/test/core/end2end/no_server_test.c
@@ -41,7 +41,7 @@
int main(int argc, char **argv) {
grpc_channel *chan;
grpc_call *call;
- gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5);
+ gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2);
grpc_completion_queue *cq;
cq_verifier *cqv;
grpc_event *ev;
diff --git a/test/core/fling/server.c b/test/core/fling/server.c
index 59c3030..5c1ab14 100644
--- a/test/core/fling/server.c
+++ b/test/core/fling/server.c
@@ -275,7 +275,7 @@
case FLING_SERVER_SEND_STATUS_FOR_STREAMING:
/* Send status and close completed at server */
grpc_call_destroy(call);
- request_call();
+ if (!shutdown_started) request_call();
break;
case FLING_SERVER_READ_FOR_UNARY:
/* Finished payload read for unary. Start all reamaining
@@ -288,7 +288,7 @@
grpc_byte_buffer_destroy(payload_buffer);
payload_buffer = NULL;
grpc_call_destroy(call);
- request_call();
+ if (!shutdown_started) request_call();
break;
}
break;
diff --git a/tools/buildgen/build-cleaner.py b/tools/buildgen/build-cleaner.py
index 880f3e2..1d9157a 100755
--- a/tools/buildgen/build-cleaner.py
+++ b/tools/buildgen/build-cleaner.py
@@ -41,6 +41,7 @@
_VERSION_KEYS = ['major', 'minor', 'micro', 'build']
_ELEM_KEYS = [
'name',
+ 'flaky',
'build',
'run',
'language',
diff --git a/tools/dockerfile/grpc_csharp_mono/Dockerfile b/tools/dockerfile/grpc_csharp_mono/Dockerfile
new file mode 100644
index 0000000..d0e2d2b
--- /dev/null
+++ b/tools/dockerfile/grpc_csharp_mono/Dockerfile
@@ -0,0 +1,59 @@
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Dockerfile for gRPC C# (on Mono).
+FROM grpc/csharp_mono_base
+
+# Pull the latest sources
+RUN cd /var/local/git/grpc \
+ && git pull --recurse-submodules \
+ && git submodule update --init --recursive
+
+# Install the gRPC C# extension library
+RUN make install_grpc_csharp_ext -j12 -C /var/local/git/grpc
+
+# TODO: download NuGet from web. The problem is there seems to be no direct link
+# we could use :-)
+ADD NuGet.exe NuGet.exe
+
+# Restore the NuGet dependencies
+RUN cd /var/local/git/grpc/src/csharp && mono /NuGet.exe restore Grpc.sln
+
+# Build gRPC solution
+RUN cd /var/local/git/grpc/src/csharp && xbuild Grpc.sln
+
+# Add a cacerts directory containing the Google root pem file, allowing the
+# ruby client to access the production test instance
+ADD cacerts cacerts
+
+# Add a service_account directory containing the auth creds file
+ADD service_account service_account
+
+# TODO: add command to run the interop server
+CMD ["/bin/bash", "-l"]
diff --git a/tools/dockerfile/grpc_csharp_mono_base/Dockerfile b/tools/dockerfile/grpc_csharp_mono_base/Dockerfile
new file mode 100644
index 0000000..74919a7
--- /dev/null
+++ b/tools/dockerfile/grpc_csharp_mono_base/Dockerfile
@@ -0,0 +1,53 @@
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Base Dockerfile for gRPC C# (on Mono).
+#
+# Includes gRPC C# installation dependencies, things that are unlikely to vary.
+FROM grpc/base
+
+# Update to a newer version of mono
+RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
+RUN echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list
+
+# Install dependencies
+RUN apt-get update && apt-get install -y \
+ mono-devel \
+ nunit \
+ nunit-console \
+ monodevelop
+
+# Get the source from GitHub
+RUN git clone git@github.com:grpc/grpc.git /var/local/git/grpc
+RUN cd /var/local/git/grpc && \
+ git pull --recurse-submodules && \
+ git submodule update --init --recursive
+
+# Define the default command.
+CMD ["bash","-l"]
diff --git a/tools/dockerfile/grpc_go/Dockerfile b/tools/dockerfile/grpc_go/Dockerfile
index 06bb3e2..ada2208 100644
--- a/tools/dockerfile/grpc_go/Dockerfile
+++ b/tools/dockerfile/grpc_go/Dockerfile
@@ -37,8 +37,8 @@
ADD service_account service_account
# Build the interop client and server
-RUN cd src/google.golang.org/grpc/interop/client && go install
-RUN cd src/google.golang.org/grpc/interop/server && go install
+RUN go install google.golang.org/grpc/interop/client
+RUN go install google.golang.org/grpc/interop/server
# Specify the default command such that the interop server runs on its known testing port
-CMD ["/bin/bash", "-c", "cd src/google.golang.org/grpc/interop/server && go run server.go --use_tls=true --port=8020"]
+CMD ["server", "--use_tls=true", "--port=8020"]
diff --git a/tools/run_tests/build_python.sh b/tools/run_tests/build_python.sh
index 5a3c720..de63308 100755
--- a/tools/run_tests/build_python.sh
+++ b/tools/run_tests/build_python.sh
@@ -33,10 +33,9 @@
# change to grpc repo root
cd $(dirname $0)/../..
-make -j6
-
root=`pwd`
-virtualenv python2.7_virtual_environment
+rm -rf python2.7_virtual_environment
+virtualenv -p /usr/bin/python2.7 python2.7_virtual_environment
source python2.7_virtual_environment/bin/activate
pip install enum34==1.0.4 futures==2.2.0 protobuf==3.0.0-alpha-1
CFLAGS=-I$root/include LDFLAGS=-L$root/libs/opt pip install src/python/src
diff --git a/tools/run_tests/run_lcov.sh b/tools/run_tests/run_lcov.sh
index 292aec4..69b1de6 100755
--- a/tools/run_tests/run_lcov.sh
+++ b/tools/run_tests/run_lcov.sh
@@ -35,7 +35,7 @@
root=`realpath $(dirname $0)/../..`
tmp=`mktemp`
cd $root
-tools/run_tests/run_tests.py -c gcov -l c c++
+tools/run_tests/run_tests.py -c gcov -l c c++ || true
lcov --capture --directory . --output-file $tmp
genhtml $tmp --output-directory $out
rm $tmp
diff --git a/tools/run_tests/run_python.sh b/tools/run_tests/run_python.sh
index 06ddb8e..9c7dea0 100755
--- a/tools/run_tests/run_python.sh
+++ b/tools/run_tests/run_python.sh
@@ -38,7 +38,8 @@
source python2.7_virtual_environment/bin/activate
# TODO(issue 215): Properly itemize these in run_tests.py so that they can be parallelized.
# TODO(atash): Enable dynamic unused port discovery for this test.
-python2.7 -B test/compiler/python_plugin_test.py --build_mode=opt
+# TODO(mlumish): Re-enable this test when we can install protoc
+# python2.7 -B test/compiler/python_plugin_test.py --build_mode=opt
python2.7 -B -m grpc._adapter._blocking_invocation_inline_service_test
python2.7 -B -m grpc._adapter._c_test
python2.7 -B -m grpc._adapter._event_invocation_synchronous_event_service_test
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index b737032..e949670 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -135,7 +135,7 @@
return [config.job_spec('tools/run_tests/run_python.sh', None)]
def make_targets(self):
- return[]
+ return ['static_c']
def build_steps(self):
return [['tools/run_tests/build_python.sh']]
diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json
index 772856b..06bf58f 100644
--- a/tools/run_tests/tests.json
+++ b/tools/run_tests/tests.json
@@ -102,12 +102,12 @@
"name": "fd_posix_test"
},
{
- "flaky": true,
+ "flaky": false,
"language": "c",
"name": "fling_stream_test"
},
{
- "flaky": true,
+ "flaky": false,
"language": "c",
"name": "fling_test"
},