From 27f59afecb04b63b7c83a842d400efb1ad09049a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 28 Apr 2016 14:19:48 -0700 Subject: Unifying error handling within core --- gRPC.podspec | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gRPC.podspec') diff --git a/gRPC.podspec b/gRPC.podspec index d66e03354b..7becccebb4 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -178,6 +178,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/closure.h', 'src/core/lib/iomgr/endpoint.h', 'src/core/lib/iomgr/endpoint_pair.h', + 'src/core/lib/iomgr/error.h', 'src/core/lib/iomgr/ev_poll_and_epoll_posix.h', 'src/core/lib/iomgr/ev_posix.h', 'src/core/lib/iomgr/exec_ctx.h', @@ -343,6 +344,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/endpoint.c', 'src/core/lib/iomgr/endpoint_pair_posix.c', 'src/core/lib/iomgr/endpoint_pair_windows.c', + 'src/core/lib/iomgr/error.c', 'src/core/lib/iomgr/ev_poll_and_epoll_posix.c', 'src/core/lib/iomgr/ev_posix.c', 'src/core/lib/iomgr/exec_ctx.c', @@ -520,6 +522,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/closure.h', 'src/core/lib/iomgr/endpoint.h', 'src/core/lib/iomgr/endpoint_pair.h', + 'src/core/lib/iomgr/error.h', 'src/core/lib/iomgr/ev_poll_and_epoll_posix.h', 'src/core/lib/iomgr/ev_posix.h', 'src/core/lib/iomgr/exec_ctx.h', -- cgit v1.2.3 From ddad97899654c1eb3805ec165e842f8f465702a1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 5 May 2016 17:11:31 -0700 Subject: API fuzzer compiles with new error handling --- BUILD | 4 ++++ Makefile | 2 ++ binding.gyp | 1 + build.yaml | 2 ++ config.m4 | 1 + gRPC.podspec | 3 +++ grpc.gemspec | 2 ++ package.xml | 2 ++ src/core/lib/iomgr/error.c | 11 +++++++++ src/python/grpcio/grpc_core_dependencies.py | 1 + test/core/end2end/fuzzers/api_fuzzer.c | 36 ++++++++++++++++------------ test/core/iomgr/endpoint_tests.c | 16 ++++++------- test/core/security/oauth2_utils.c | 3 ++- test/core/util/mock_endpoint.c | 9 +++---- test/core/util/passthru_endpoint.c | 19 ++++++++------- test/core/util/port_server_client.c | 34 ++++++++++++++++---------- tools/doxygen/Doxyfile.core.internal | 2 ++ tools/run_tests/sources_and_headers.json | 3 +++ vsprojects/vcxproj/grpc/grpc.vcxproj | 3 +++ vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 6 +++++ 20 files changed, 112 insertions(+), 48 deletions(-) (limited to 'gRPC.podspec') diff --git a/BUILD b/BUILD index c28d0e7d57..080498987b 100644 --- a/BUILD +++ b/BUILD @@ -272,6 +272,7 @@ cc_library( "src/core/lib/security/transport/handshake.h", "src/core/lib/security/transport/secure_endpoint.h", "src/core/lib/security/transport/security_connector.h", + "src/core/lib/security/transport/tsi_error.h", "src/core/lib/security/util/b64.h", "src/core/lib/security/util/json_util.h", "src/core/lib/tsi/fake_transport_security.h", @@ -430,6 +431,7 @@ cc_library( "src/core/lib/security/transport/secure_endpoint.c", "src/core/lib/security/transport/security_connector.c", "src/core/lib/security/transport/server_auth_filter.c", + "src/core/lib/security/transport/tsi_error.c", "src/core/lib/security/util/b64.c", "src/core/lib/security/util/json_util.c", "src/core/lib/surface/init_secure.c", @@ -1462,6 +1464,7 @@ objc_library( "src/core/lib/security/transport/secure_endpoint.c", "src/core/lib/security/transport/security_connector.c", "src/core/lib/security/transport/server_auth_filter.c", + "src/core/lib/security/transport/tsi_error.c", "src/core/lib/security/util/b64.c", "src/core/lib/security/util/json_util.c", "src/core/lib/surface/init_secure.c", @@ -1648,6 +1651,7 @@ objc_library( "src/core/lib/security/transport/handshake.h", "src/core/lib/security/transport/secure_endpoint.h", "src/core/lib/security/transport/security_connector.h", + "src/core/lib/security/transport/tsi_error.h", "src/core/lib/security/util/b64.h", "src/core/lib/security/util/json_util.h", "src/core/lib/tsi/fake_transport_security.h", diff --git a/Makefile b/Makefile index 44108196d4..6e1c3b6fd4 100644 --- a/Makefile +++ b/Makefile @@ -2604,6 +2604,7 @@ LIBGRPC_SRC = \ src/core/lib/security/transport/secure_endpoint.c \ src/core/lib/security/transport/security_connector.c \ src/core/lib/security/transport/server_auth_filter.c \ + src/core/lib/security/transport/tsi_error.c \ src/core/lib/security/util/b64.c \ src/core/lib/security/util/json_util.c \ src/core/lib/surface/init_secure.c \ @@ -14348,6 +14349,7 @@ src/core/lib/security/transport/handshake.c: $(OPENSSL_DEP) src/core/lib/security/transport/secure_endpoint.c: $(OPENSSL_DEP) src/core/lib/security/transport/security_connector.c: $(OPENSSL_DEP) src/core/lib/security/transport/server_auth_filter.c: $(OPENSSL_DEP) +src/core/lib/security/transport/tsi_error.c: $(OPENSSL_DEP) src/core/lib/security/util/b64.c: $(OPENSSL_DEP) src/core/lib/security/util/json_util.c: $(OPENSSL_DEP) src/core/lib/surface/init_secure.c: $(OPENSSL_DEP) diff --git a/binding.gyp b/binding.gyp index 5029f087bc..3efec93257 100644 --- a/binding.gyp +++ b/binding.gyp @@ -690,6 +690,7 @@ 'src/core/lib/security/transport/secure_endpoint.c', 'src/core/lib/security/transport/security_connector.c', 'src/core/lib/security/transport/server_auth_filter.c', + 'src/core/lib/security/transport/tsi_error.c', 'src/core/lib/security/util/b64.c', 'src/core/lib/security/util/json_util.c', 'src/core/lib/surface/init_secure.c', diff --git a/build.yaml b/build.yaml index 4c5d0e903b..78c1aaf704 100644 --- a/build.yaml +++ b/build.yaml @@ -421,6 +421,7 @@ filegroups: - src/core/lib/security/transport/handshake.h - src/core/lib/security/transport/secure_endpoint.h - src/core/lib/security/transport/security_connector.h + - src/core/lib/security/transport/tsi_error.h - src/core/lib/security/util/b64.h - src/core/lib/security/util/json_util.h src: @@ -445,6 +446,7 @@ filegroups: - src/core/lib/security/transport/secure_endpoint.c - src/core/lib/security/transport/security_connector.c - src/core/lib/security/transport/server_auth_filter.c + - src/core/lib/security/transport/tsi_error.c - src/core/lib/security/util/b64.c - src/core/lib/security/util/json_util.c - src/core/lib/surface/init_secure.c diff --git a/config.m4 b/config.m4 index aa6d9fd3eb..7639c4eea0 100644 --- a/config.m4 +++ b/config.m4 @@ -209,6 +209,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/security/transport/secure_endpoint.c \ src/core/lib/security/transport/security_connector.c \ src/core/lib/security/transport/server_auth_filter.c \ + src/core/lib/security/transport/tsi_error.c \ src/core/lib/security/util/b64.c \ src/core/lib/security/util/json_util.c \ src/core/lib/surface/init_secure.c \ diff --git a/gRPC.podspec b/gRPC.podspec index 84841b8300..da147e393d 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -274,6 +274,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/transport/handshake.h', 'src/core/lib/security/transport/secure_endpoint.h', 'src/core/lib/security/transport/security_connector.h', + 'src/core/lib/security/transport/tsi_error.h', 'src/core/lib/security/util/b64.h', 'src/core/lib/security/util/json_util.h', 'src/core/lib/tsi/fake_transport_security.h', @@ -465,6 +466,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/transport/secure_endpoint.c', 'src/core/lib/security/transport/security_connector.c', 'src/core/lib/security/transport/server_auth_filter.c', + 'src/core/lib/security/transport/tsi_error.c', 'src/core/lib/security/util/b64.c', 'src/core/lib/security/util/json_util.c', 'src/core/lib/surface/init_secure.c', @@ -636,6 +638,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/transport/handshake.h', 'src/core/lib/security/transport/secure_endpoint.h', 'src/core/lib/security/transport/security_connector.h', + 'src/core/lib/security/transport/tsi_error.h', 'src/core/lib/security/util/b64.h', 'src/core/lib/security/util/json_util.h', 'src/core/lib/tsi/fake_transport_security.h', diff --git a/grpc.gemspec b/grpc.gemspec index 49b2b79d84..bad5834259 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -283,6 +283,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/transport/handshake.h ) s.files += %w( src/core/lib/security/transport/secure_endpoint.h ) s.files += %w( src/core/lib/security/transport/security_connector.h ) + s.files += %w( src/core/lib/security/transport/tsi_error.h ) s.files += %w( src/core/lib/security/util/b64.h ) s.files += %w( src/core/lib/security/util/json_util.h ) s.files += %w( src/core/lib/tsi/fake_transport_security.h ) @@ -445,6 +446,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/transport/secure_endpoint.c ) s.files += %w( src/core/lib/security/transport/security_connector.c ) s.files += %w( src/core/lib/security/transport/server_auth_filter.c ) + s.files += %w( src/core/lib/security/transport/tsi_error.c ) s.files += %w( src/core/lib/security/util/b64.c ) s.files += %w( src/core/lib/security/util/json_util.c ) s.files += %w( src/core/lib/surface/init_secure.c ) diff --git a/package.xml b/package.xml index 57e04245d9..79713e45d5 100644 --- a/package.xml +++ b/package.xml @@ -290,6 +290,7 @@ + @@ -452,6 +453,7 @@ + diff --git a/src/core/lib/iomgr/error.c b/src/core/lib/iomgr/error.c index 2c5f9f6cbd..fb8decb8d3 100644 --- a/src/core/lib/iomgr/error.c +++ b/src/core/lib/iomgr/error.c @@ -229,6 +229,10 @@ grpc_error *grpc_error_set_int(grpc_error *src, grpc_error_ints which, return new; } +const intptr_t *grpc_error_get_int(grpc_error *err, grpc_error_ints which) { + return gpr_avl_get(err->ints, (void *)(uintptr_t)which); +} + grpc_error *grpc_error_set_str(grpc_error *src, grpc_error_strs which, const char *value) { grpc_error *new = copy_error_and_unref(src); @@ -419,6 +423,13 @@ static const char *finish_kvs(kv_pairs *kvs) { return s; } +void grpc_error_free_string(const char *str) { + if (str == no_error_string) return; + if (str == oom_error_string) return; + if (str == cancelled_error_string) return; + gpr_free((char *)str); +} + const char *grpc_error_string(grpc_error *err) { if (err == GRPC_ERROR_NONE) return no_error_string; if (err == GRPC_ERROR_OOM) return oom_error_string; diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 119382cd45..5d39cef772 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -203,6 +203,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/security/transport/secure_endpoint.c', 'src/core/lib/security/transport/security_connector.c', 'src/core/lib/security/transport/server_auth_filter.c', + 'src/core/lib/security/transport/tsi_error.c', 'src/core/lib/security/util/b64.c', 'src/core/lib/security/util/json_util.c', 'src/core/lib/surface/init_secure.c', diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index b133a948ee..858ebd9683 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -186,21 +186,26 @@ static gpr_timespec now_impl(gpr_clock_type clock_type) { typedef struct addr_req { grpc_timer timer; char *addr; - grpc_resolve_cb cb; - void *arg; + grpc_closure *on_done; + grpc_resolved_addresses **addrs; } addr_req; -static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg, bool success) { +static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg, + grpc_error *error) { addr_req *r = arg; - if (success && 0 == strcmp(r->addr, "server")) { + if (error == GRPC_ERROR_NONE && 0 == strcmp(r->addr, "server")) { grpc_resolved_addresses *addrs = gpr_malloc(sizeof(*addrs)); addrs->naddrs = 1; addrs->addrs = gpr_malloc(sizeof(*addrs->addrs)); addrs->addrs[0].len = 0; - r->cb(exec_ctx, r->arg, addrs); + *r->addrs = addrs; + grpc_exec_ctx_push(exec_ctx, r->on_done, GRPC_ERROR_NONE, NULL); } else { - r->cb(exec_ctx, r->arg, NULL); + grpc_error_ref(error); + grpc_exec_ctx_push( + exec_ctx, r->on_done, + GRPC_ERROR_CREATE_REFERENCING("Resolution failed", &error, 1), NULL); } gpr_free(r->addr); @@ -208,12 +213,12 @@ static void finish_resolve(grpc_exec_ctx *exec_ctx, void *arg, bool success) { } void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, - const char *default_port, grpc_resolve_cb cb, - void *arg) { + const char *default_port, grpc_closure *on_done, + grpc_resolved_addresses **addresses) { addr_req *r = gpr_malloc(sizeof(*r)); r->addr = gpr_strdup(addr); - r->cb = cb; - r->arg = arg; + r->on_done = on_done; + r->addrs = addresses; grpc_timer_init(exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(1, GPR_TIMESPAN)), @@ -239,11 +244,11 @@ typedef struct { gpr_timespec deadline; } future_connect; -static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, bool success) { +static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { future_connect *fc = arg; - if (!success) { + if (error != GRPC_ERROR_NONE) { *fc->ep = NULL; - grpc_exec_ctx_enqueue(exec_ctx, fc->closure, false, NULL); + grpc_exec_ctx_push(exec_ctx, fc->closure, grpc_error_ref(error), NULL); } else if (g_server != NULL) { grpc_endpoint *client; grpc_endpoint *server; @@ -255,7 +260,7 @@ static void do_connect(grpc_exec_ctx *exec_ctx, void *arg, bool success) { grpc_server_setup_transport(exec_ctx, g_server, transport, NULL); grpc_chttp2_transport_start_reading(exec_ctx, transport, NULL, 0); - grpc_exec_ctx_enqueue(exec_ctx, fc->closure, false, NULL); + grpc_exec_ctx_push(exec_ctx, fc->closure, GRPC_ERROR_NONE, NULL); } else { sched_connect(exec_ctx, fc->closure, fc->ep, fc->deadline); } @@ -266,7 +271,8 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, gpr_timespec deadline) { if (gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) < 0) { *ep = NULL; - grpc_exec_ctx_enqueue(exec_ctx, closure, false, NULL); + grpc_exec_ctx_push(exec_ctx, closure, + GRPC_ERROR_CREATE("Connect deadline exceeded"), NULL); return; } diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index 52082c3c6b..ded76bccec 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -128,30 +128,30 @@ struct read_and_write_test_state { }; static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx, - void *data, bool success) { + void *data, grpc_error *error) { struct read_and_write_test_state *state = data; state->bytes_read += count_slices( state->incoming.slices, state->incoming.count, &state->current_read_data); - if (state->bytes_read == state->target_bytes || !success) { + if (state->bytes_read == state->target_bytes || error != GRPC_ERROR_NONE) { gpr_log(GPR_INFO, "Read handler done"); gpr_mu_lock(g_mu); - state->read_done = 1 + success; + state->read_done = 1 + (error == GRPC_ERROR_NONE); grpc_pollset_kick(g_pollset, NULL); gpr_mu_unlock(g_mu); - } else if (success) { + } else if (error == GRPC_ERROR_NONE) { grpc_endpoint_read(exec_ctx, state->read_ep, &state->incoming, &state->done_read); } } static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx, - void *data, bool success) { + void *data, grpc_error *error) { struct read_and_write_test_state *state = data; gpr_slice *slices = NULL; size_t nslices; - if (success) { + if (error != GRPC_ERROR_NONE) { state->bytes_written += state->current_write_size; if (state->target_bytes - state->bytes_written < state->current_write_size) { @@ -171,7 +171,7 @@ static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx, gpr_log(GPR_INFO, "Write handler done"); gpr_mu_lock(g_mu); - state->write_done = 1 + success; + state->write_done = 1 + (error != GRPC_ERROR_NONE); grpc_pollset_kick(g_pollset, NULL); gpr_mu_unlock(g_mu); } @@ -219,7 +219,7 @@ static void read_and_write_test(grpc_endpoint_test_config config, for the first iteration as for later iterations. It does the right thing even when bytes_written is unsigned. */ state.bytes_written -= state.current_write_size; - read_and_write_test_write_handler(&exec_ctx, &state, 1); + read_and_write_test_write_handler(&exec_ctx, &state, GRPC_ERROR_NONE); grpc_exec_ctx_finish(&exec_ctx); grpc_endpoint_read(&exec_ctx, state.read_ep, &state.incoming, diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c index 80d21cc602..e55ce5c7b4 100644 --- a/test/core/security/oauth2_utils.c +++ b/test/core/security/oauth2_utils.c @@ -74,7 +74,8 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data, gpr_mu_unlock(request->mu); } -static void do_nothing(grpc_exec_ctx *exec_ctx, void *unused, bool success) {} +static void do_nothing(grpc_exec_ctx *exec_ctx, void *unused, + grpc_error *error) {} char *grpc_test_fetch_oauth2_token_with_credentials( grpc_call_credentials *creds) { diff --git a/test/core/util/mock_endpoint.c b/test/core/util/mock_endpoint.c index 7768413095..deef68ef59 100644 --- a/test/core/util/mock_endpoint.c +++ b/test/core/util/mock_endpoint.c @@ -51,7 +51,7 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_mu_lock(&m->mu); if (m->read_buffer.count > 0) { gpr_slice_buffer_swap(&m->read_buffer, slices); - grpc_exec_ctx_enqueue(exec_ctx, cb, true, NULL); + grpc_exec_ctx_push(exec_ctx, cb, GRPC_ERROR_NONE, NULL); } else { m->on_read = cb; m->on_read_out = slices; @@ -65,7 +65,7 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, for (size_t i = 0; i < slices->count; i++) { m->on_write(slices->slices[i]); } - grpc_exec_ctx_enqueue(exec_ctx, cb, true, NULL); + grpc_exec_ctx_push(exec_ctx, cb, GRPC_ERROR_NONE, NULL); } static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, @@ -78,7 +78,8 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; gpr_mu_lock(&m->mu); if (m->on_read) { - grpc_exec_ctx_enqueue(exec_ctx, m->on_read, false, NULL); + grpc_exec_ctx_push(exec_ctx, m->on_read, + GRPC_ERROR_CREATE("Endpoint Shutdown"), NULL); m->on_read = NULL; } gpr_mu_unlock(&m->mu); @@ -115,7 +116,7 @@ void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_mu_lock(&m->mu); if (m->on_read != NULL) { gpr_slice_buffer_add(m->on_read_out, slice); - grpc_exec_ctx_enqueue(exec_ctx, m->on_read, true, NULL); + grpc_exec_ctx_push(exec_ctx, m->on_read, GRPC_ERROR_NONE, NULL); m->on_read = NULL; } else { gpr_slice_buffer_add(&m->read_buffer, slice); diff --git a/test/core/util/passthru_endpoint.c b/test/core/util/passthru_endpoint.c index ae955b1f68..93753be251 100644 --- a/test/core/util/passthru_endpoint.c +++ b/test/core/util/passthru_endpoint.c @@ -59,10 +59,11 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, half *m = (half *)ep; gpr_mu_lock(&m->parent->mu); if (m->parent->shutdown) { - grpc_exec_ctx_enqueue(exec_ctx, cb, false, NULL); + grpc_exec_ctx_push(exec_ctx, cb, GRPC_ERROR_CREATE("Already shutdown"), + NULL); } else if (m->read_buffer.count > 0) { gpr_slice_buffer_swap(&m->read_buffer, slices); - grpc_exec_ctx_enqueue(exec_ctx, cb, true, NULL); + grpc_exec_ctx_push(exec_ctx, cb, GRPC_ERROR_NONE, NULL); } else { m->on_read = cb; m->on_read_out = slices; @@ -79,14 +80,14 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_slice_buffer *slices, grpc_closure *cb) { half *m = other_half((half *)ep); gpr_mu_lock(&m->parent->mu); - bool ok = true; + grpc_error *error = GRPC_ERROR_NONE; if (m->parent->shutdown) { - ok = false; + error = GRPC_ERROR_CREATE("Endpoint already shutdown"); } else if (m->on_read != NULL) { for (size_t i = 0; i < slices->count; i++) { gpr_slice_buffer_add(m->on_read_out, gpr_slice_ref(slices->slices[i])); } - grpc_exec_ctx_enqueue(exec_ctx, m->on_read, true, NULL); + grpc_exec_ctx_push(exec_ctx, m->on_read, GRPC_ERROR_NONE, NULL); m->on_read = NULL; } else { for (size_t i = 0; i < slices->count; i++) { @@ -94,7 +95,7 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, } } gpr_mu_unlock(&m->parent->mu); - grpc_exec_ctx_enqueue(exec_ctx, cb, ok, NULL); + grpc_exec_ctx_push(exec_ctx, cb, error, NULL); } static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, @@ -108,12 +109,14 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { gpr_mu_lock(&m->parent->mu); m->parent->shutdown = true; if (m->on_read) { - grpc_exec_ctx_enqueue(exec_ctx, m->on_read, false, NULL); + grpc_exec_ctx_push(exec_ctx, m->on_read, GRPC_ERROR_CREATE("Shutdown"), + NULL); m->on_read = NULL; } m = other_half(m); if (m->on_read) { - grpc_exec_ctx_enqueue(exec_ctx, m->on_read, false, NULL); + grpc_exec_ctx_push(exec_ctx, m->on_read, GRPC_ERROR_CREATE("Shutdown"), + NULL); m->on_read = NULL; } gpr_mu_unlock(&m->parent->mu); diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c index 84e90547aa..a03dc0c83f 100644 --- a/test/core/util/port_server_client.c +++ b/test/core/util/port_server_client.c @@ -56,14 +56,14 @@ typedef struct freereq { } freereq; static void destroy_pollset_and_shutdown(grpc_exec_ctx *exec_ctx, void *p, - bool success) { + grpc_error *error) { grpc_pollset_destroy(p); gpr_free(p); grpc_shutdown(); } static void freed_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, - const grpc_httpcli_response *response) { + grpc_error *error) { freereq *pr = arg; gpr_mu_lock(pr->mu); pr->done = 1; @@ -74,6 +74,7 @@ static void freed_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, void grpc_free_port_using_server(char *server, int port) { grpc_httpcli_context context; grpc_httpcli_request req; + grpc_httpcli_response rsp; freereq pr; char *path; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -83,6 +84,7 @@ void grpc_free_port_using_server(char *server, int port) { memset(&pr, 0, sizeof(pr)); memset(&req, 0, sizeof(req)); + memset(&rsp, 0, sizeof(rsp)); pr.pollset = gpr_malloc(grpc_pollset_size()); grpc_pollset_init(pr.pollset, &pr.mu); @@ -95,8 +97,8 @@ void grpc_free_port_using_server(char *server, int port) { grpc_httpcli_context_init(&context); grpc_httpcli_get(&exec_ctx, &context, pr.pollset, &req, - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), freed_port_from_server, - &pr); + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), + grpc_closure_create(freed_port_from_server, &pr), &rsp); gpr_mu_lock(pr.mu); while (!pr.done) { grpc_pollset_worker *worker = NULL; @@ -120,19 +122,22 @@ typedef struct portreq { int retries; char *server; grpc_httpcli_context *ctx; + grpc_httpcli_response response; } portreq; static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, - const grpc_httpcli_response *response) { + grpc_error *error) { size_t i; int port = 0; portreq *pr = arg; int failed = 0; + grpc_httpcli_response *response = &pr->response; - if (!response) { + if (error != GRPC_ERROR_NONE) { failed = 1; - gpr_log(GPR_DEBUG, - "failed port pick from server: retrying [response=NULL]"); + const char *msg = grpc_error_string(error); + gpr_log(GPR_DEBUG, "failed port pick from server: retrying [%s]", msg); + grpc_error_free_string(msg); } else if (response->status != 200) { failed = 1; gpr_log(GPR_DEBUG, "failed port pick from server: status=%d", @@ -151,9 +156,12 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, pr->retries++; req.host = pr->server; req.http.path = "/get"; + grpc_http_response_destroy(&pr->response); + memset(&pr->response, 0, sizeof(pr->response)); grpc_httpcli_get(exec_ctx, pr->ctx, pr->pollset, &req, - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), got_port_from_server, - pr); + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), + grpc_closure_create(got_port_from_server, pr), + &pr->response); return; } GPR_ASSERT(response); @@ -193,8 +201,9 @@ int grpc_pick_port_using_server(char *server) { grpc_httpcli_context_init(&context); grpc_httpcli_get(&exec_ctx, &context, pr.pollset, &req, - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), got_port_from_server, - &pr); + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10), + grpc_closure_create(got_port_from_server, &pr), + &pr.response); grpc_exec_ctx_finish(&exec_ctx); gpr_mu_lock(pr.mu); while (pr.port == -1) { @@ -205,6 +214,7 @@ int grpc_pick_port_using_server(char *server) { } gpr_mu_unlock(pr.mu); + grpc_http_response_destroy(&pr.response); grpc_httpcli_context_destroy(&context); grpc_pollset_shutdown(&exec_ctx, pr.pollset, shutdown_closure); grpc_exec_ctx_finish(&exec_ctx); diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index b45e73050c..39ea15c458 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -900,6 +900,7 @@ src/core/lib/security/transport/auth_filters.h \ src/core/lib/security/transport/handshake.h \ src/core/lib/security/transport/secure_endpoint.h \ src/core/lib/security/transport/security_connector.h \ +src/core/lib/security/transport/tsi_error.h \ src/core/lib/security/util/b64.h \ src/core/lib/security/util/json_util.h \ src/core/lib/tsi/fake_transport_security.h \ @@ -1062,6 +1063,7 @@ src/core/lib/security/transport/handshake.c \ src/core/lib/security/transport/secure_endpoint.c \ src/core/lib/security/transport/security_connector.c \ src/core/lib/security/transport/server_auth_filter.c \ +src/core/lib/security/transport/tsi_error.c \ src/core/lib/security/util/b64.c \ src/core/lib/security/util/json_util.c \ src/core/lib/surface/init_secure.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 8b521a5dae..143f78f468 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -6035,6 +6035,7 @@ "src/core/lib/security/transport/handshake.h", "src/core/lib/security/transport/secure_endpoint.h", "src/core/lib/security/transport/security_connector.h", + "src/core/lib/security/transport/tsi_error.h", "src/core/lib/security/util/b64.h", "src/core/lib/security/util/json_util.h" ], @@ -6080,6 +6081,8 @@ "src/core/lib/security/transport/security_connector.c", "src/core/lib/security/transport/security_connector.h", "src/core/lib/security/transport/server_auth_filter.c", + "src/core/lib/security/transport/tsi_error.c", + "src/core/lib/security/transport/tsi_error.h", "src/core/lib/security/util/b64.c", "src/core/lib/security/util/b64.h", "src/core/lib/security/util/json_util.c", diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index d594cd18a9..331ba04f52 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -409,6 +409,7 @@ + @@ -700,6 +701,8 @@ + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index ece040e519..a435d7901c 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -382,6 +382,9 @@ src\core\lib\security\transport + + src\core\lib\security\transport + src\core\lib\security\util @@ -947,6 +950,9 @@ src\core\lib\security\transport + + src\core\lib\security\transport + src\core\lib\security\util -- cgit v1.2.3 From 8517886c6a52d44aab151babae49f482e30f67fc Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 18 May 2016 16:09:16 -0700 Subject: Move load_file into iomgr --- BUILD | 10 +- Makefile | 75 ++++---- binding.gyp | 2 +- build.yaml | 23 +-- config.m4 | 2 +- gRPC.podspec | 6 +- grpc.gemspec | 4 +- package.xml | 4 +- src/core/lib/iomgr/load_file.c | 89 +++++++++ src/core/lib/iomgr/load_file.h | 56 ++++++ .../google_default/google_default_credentials.c | 4 +- .../lib/security/transport/security_connector.c | 6 +- src/core/lib/support/load_file.c | 89 --------- src/core/lib/support/load_file.h | 56 ------ src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/bad_ssl/servers/cert.c | 10 +- test/core/internal_api_canaries/support.c | 4 +- test/core/iomgr/load_file_test.c | 175 ++++++++++++++++++ test/core/security/create_jwt.c | 4 +- test/core/security/fetch_oauth2.c | 4 +- test/core/support/load_file_test.c | 175 ------------------ test/core/util/one_corpus_entry_fuzzer.c | 4 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/sources_and_headers.json | 37 ++-- tools/run_tests/tests.json | 42 ++--- vsprojects/buildtests_c.sln | 53 +++--- vsprojects/vcxproj/gpr/gpr.vcxproj | 3 - vsprojects/vcxproj/gpr/gpr.vcxproj.filters | 6 - vsprojects/vcxproj/grpc/grpc.vcxproj | 3 + vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 6 + .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 3 + .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 6 + .../gpr_load_file_test/gpr_load_file_test.vcxproj | 196 -------------------- .../gpr_load_file_test.vcxproj.filters | 21 --- .../test/load_file_test/load_file_test.vcxproj | 199 +++++++++++++++++++++ .../load_file_test/load_file_test.vcxproj.filters | 21 +++ 36 files changed, 711 insertions(+), 693 deletions(-) create mode 100644 src/core/lib/iomgr/load_file.c create mode 100644 src/core/lib/iomgr/load_file.h delete mode 100644 src/core/lib/support/load_file.c delete mode 100644 src/core/lib/support/load_file.h create mode 100644 test/core/iomgr/load_file_test.c delete mode 100644 test/core/support/load_file_test.c delete mode 100644 vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj delete mode 100644 vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj.filters create mode 100644 vsprojects/vcxproj/test/load_file_test/load_file_test.vcxproj create mode 100644 vsprojects/vcxproj/test/load_file_test/load_file_test.vcxproj.filters (limited to 'gRPC.podspec') diff --git a/BUILD b/BUILD index 9d2d90cf4b..8d071bb118 100644 --- a/BUILD +++ b/BUILD @@ -49,7 +49,6 @@ cc_library( "src/core/lib/support/backoff.h", "src/core/lib/support/block_annotate.h", "src/core/lib/support/env.h", - "src/core/lib/support/load_file.h", "src/core/lib/support/murmur_hash.h", "src/core/lib/support/stack_lockfree.h", "src/core/lib/support/string.h", @@ -72,7 +71,6 @@ cc_library( "src/core/lib/support/env_win32.c", "src/core/lib/support/histogram.c", "src/core/lib/support/host_port.c", - "src/core/lib/support/load_file.c", "src/core/lib/support/log.c", "src/core/lib/support/log_android.c", "src/core/lib/support/log_linux.c", @@ -188,6 +186,7 @@ cc_library( "src/core/lib/iomgr/iomgr.h", "src/core/lib/iomgr/iomgr_internal.h", "src/core/lib/iomgr/iomgr_posix.h", + "src/core/lib/iomgr/load_file.h", "src/core/lib/iomgr/pollset.h", "src/core/lib/iomgr/pollset_set.h", "src/core/lib/iomgr/pollset_set_windows.h", @@ -334,6 +333,7 @@ cc_library( "src/core/lib/iomgr/iomgr.c", "src/core/lib/iomgr/iomgr_posix.c", "src/core/lib/iomgr/iomgr_windows.c", + "src/core/lib/iomgr/load_file.c", "src/core/lib/iomgr/pollset_set_windows.c", "src/core/lib/iomgr/pollset_windows.c", "src/core/lib/iomgr/resolve_address_posix.c", @@ -562,6 +562,7 @@ cc_library( "src/core/lib/iomgr/iomgr.h", "src/core/lib/iomgr/iomgr_internal.h", "src/core/lib/iomgr/iomgr_posix.h", + "src/core/lib/iomgr/load_file.h", "src/core/lib/iomgr/pollset.h", "src/core/lib/iomgr/pollset_set.h", "src/core/lib/iomgr/pollset_set_windows.h", @@ -684,6 +685,7 @@ cc_library( "src/core/lib/iomgr/iomgr.c", "src/core/lib/iomgr/iomgr_posix.c", "src/core/lib/iomgr/iomgr_windows.c", + "src/core/lib/iomgr/load_file.c", "src/core/lib/iomgr/pollset_set_windows.c", "src/core/lib/iomgr/pollset_windows.c", "src/core/lib/iomgr/resolve_address_posix.c", @@ -1229,7 +1231,6 @@ objc_library( "src/core/lib/support/env_win32.c", "src/core/lib/support/histogram.c", "src/core/lib/support/host_port.c", - "src/core/lib/support/load_file.c", "src/core/lib/support/log.c", "src/core/lib/support/log_android.c", "src/core/lib/support/log_linux.c", @@ -1308,7 +1309,6 @@ objc_library( "src/core/lib/support/backoff.h", "src/core/lib/support/block_annotate.h", "src/core/lib/support/env.h", - "src/core/lib/support/load_file.h", "src/core/lib/support/murmur_hash.h", "src/core/lib/support/stack_lockfree.h", "src/core/lib/support/string.h", @@ -1358,6 +1358,7 @@ objc_library( "src/core/lib/iomgr/iomgr.c", "src/core/lib/iomgr/iomgr_posix.c", "src/core/lib/iomgr/iomgr_windows.c", + "src/core/lib/iomgr/load_file.c", "src/core/lib/iomgr/pollset_set_windows.c", "src/core/lib/iomgr/pollset_windows.c", "src/core/lib/iomgr/resolve_address_posix.c", @@ -1565,6 +1566,7 @@ objc_library( "src/core/lib/iomgr/iomgr.h", "src/core/lib/iomgr/iomgr_internal.h", "src/core/lib/iomgr/iomgr_posix.h", + "src/core/lib/iomgr/load_file.h", "src/core/lib/iomgr/pollset.h", "src/core/lib/iomgr/pollset_set.h", "src/core/lib/iomgr/pollset_set_windows.h", diff --git a/Makefile b/Makefile index c0908c0698..abb8ad6592 100644 --- a/Makefile +++ b/Makefile @@ -919,7 +919,6 @@ gpr_cpu_test: $(BINDIR)/$(CONFIG)/gpr_cpu_test gpr_env_test: $(BINDIR)/$(CONFIG)/gpr_env_test gpr_histogram_test: $(BINDIR)/$(CONFIG)/gpr_histogram_test gpr_host_port_test: $(BINDIR)/$(CONFIG)/gpr_host_port_test -gpr_load_file_test: $(BINDIR)/$(CONFIG)/gpr_load_file_test gpr_log_test: $(BINDIR)/$(CONFIG)/gpr_log_test gpr_slice_buffer_test: $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test gpr_slice_test: $(BINDIR)/$(CONFIG)/gpr_slice_test @@ -966,6 +965,7 @@ json_stream_error_test: $(BINDIR)/$(CONFIG)/json_stream_error_test json_test: $(BINDIR)/$(CONFIG)/json_test lame_client_test: $(BINDIR)/$(CONFIG)/lame_client_test lb_policies_test: $(BINDIR)/$(CONFIG)/lb_policies_test +load_file_test: $(BINDIR)/$(CONFIG)/load_file_test low_level_ping_pong_benchmark: $(BINDIR)/$(CONFIG)/low_level_ping_pong_benchmark message_compress_test: $(BINDIR)/$(CONFIG)/message_compress_test mlog_test: $(BINDIR)/$(CONFIG)/mlog_test @@ -1255,7 +1255,6 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/gpr_env_test \ $(BINDIR)/$(CONFIG)/gpr_histogram_test \ $(BINDIR)/$(CONFIG)/gpr_host_port_test \ - $(BINDIR)/$(CONFIG)/gpr_load_file_test \ $(BINDIR)/$(CONFIG)/gpr_log_test \ $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test \ $(BINDIR)/$(CONFIG)/gpr_slice_test \ @@ -1294,6 +1293,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/json_test \ $(BINDIR)/$(CONFIG)/lame_client_test \ $(BINDIR)/$(CONFIG)/lb_policies_test \ + $(BINDIR)/$(CONFIG)/load_file_test \ $(BINDIR)/$(CONFIG)/message_compress_test \ $(BINDIR)/$(CONFIG)/mlog_test \ $(BINDIR)/$(CONFIG)/multiple_server_queues_test \ @@ -1534,8 +1534,6 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/gpr_histogram_test || ( echo test gpr_histogram_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_host_port_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_host_port_test || ( echo test gpr_host_port_test failed ; exit 1 ) - $(E) "[RUN] Testing gpr_load_file_test" - $(Q) $(BINDIR)/$(CONFIG)/gpr_load_file_test || ( echo test gpr_load_file_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_log_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_log_test || ( echo test gpr_log_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_slice_buffer_test" @@ -1602,6 +1600,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/json_test || ( echo test json_test failed ; exit 1 ) $(E) "[RUN] Testing lame_client_test" $(Q) $(BINDIR)/$(CONFIG)/lame_client_test || ( echo test lame_client_test failed ; exit 1 ) + $(E) "[RUN] Testing load_file_test" + $(Q) $(BINDIR)/$(CONFIG)/load_file_test || ( echo test load_file_test failed ; exit 1 ) $(E) "[RUN] Testing message_compress_test" $(Q) $(BINDIR)/$(CONFIG)/message_compress_test || ( echo test message_compress_test failed ; exit 1 ) $(E) "[RUN] Testing multiple_server_queues_test" @@ -2338,7 +2338,6 @@ LIBGPR_SRC = \ src/core/lib/support/env_win32.c \ src/core/lib/support/histogram.c \ src/core/lib/support/host_port.c \ - src/core/lib/support/load_file.c \ src/core/lib/support/log.c \ src/core/lib/support/log_android.c \ src/core/lib/support/log_linux.c \ @@ -2505,6 +2504,7 @@ LIBGRPC_SRC = \ src/core/lib/iomgr/iomgr.c \ src/core/lib/iomgr/iomgr_posix.c \ src/core/lib/iomgr/iomgr_windows.c \ + src/core/lib/iomgr/load_file.c \ src/core/lib/iomgr/pollset_set_windows.c \ src/core/lib/iomgr/pollset_windows.c \ src/core/lib/iomgr/resolve_address_posix.c \ @@ -2862,6 +2862,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/iomgr/iomgr.c \ src/core/lib/iomgr/iomgr_posix.c \ src/core/lib/iomgr/iomgr_windows.c \ + src/core/lib/iomgr/load_file.c \ src/core/lib/iomgr/pollset_set_windows.c \ src/core/lib/iomgr/pollset_windows.c \ src/core/lib/iomgr/resolve_address_posix.c \ @@ -7056,38 +7057,6 @@ endif endif -GPR_LOAD_FILE_TEST_SRC = \ - test/core/support/load_file_test.c \ - -GPR_LOAD_FILE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_LOAD_FILE_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/gpr_load_file_test: openssl_dep_error - -else - - - -$(BINDIR)/$(CONFIG)/gpr_load_file_test: $(GPR_LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_load_file_test - -endif - -$(OBJDIR)/$(CONFIG)/test/core/support/load_file_test.o: $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_gpr_load_file_test: $(GPR_LOAD_FILE_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(GPR_LOAD_FILE_TEST_OBJS:.o=.dep) -endif -endif - - GPR_LOG_TEST_SRC = \ test/core/support/log_test.c \ @@ -8560,6 +8529,38 @@ endif endif +LOAD_FILE_TEST_SRC = \ + test/core/iomgr/load_file_test.c \ + +LOAD_FILE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LOAD_FILE_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/load_file_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/load_file_test: $(LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(LOAD_FILE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/load_file_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/iomgr/load_file_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_load_file_test: $(LOAD_FILE_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(LOAD_FILE_TEST_OBJS:.o=.dep) +endif +endif + + LOW_LEVEL_PING_PONG_BENCHMARK_SRC = \ test/core/network_benchmarks/low_level_ping_pong.c \ diff --git a/binding.gyp b/binding.gyp index cfc509f0d7..5cf1081836 100644 --- a/binding.gyp +++ b/binding.gyp @@ -510,7 +510,6 @@ 'src/core/lib/support/env_win32.c', 'src/core/lib/support/histogram.c', 'src/core/lib/support/host_port.c', - 'src/core/lib/support/load_file.c', 'src/core/lib/support/log.c', 'src/core/lib/support/log_android.c', 'src/core/lib/support/log_linux.c', @@ -591,6 +590,7 @@ 'src/core/lib/iomgr/iomgr.c', 'src/core/lib/iomgr/iomgr_posix.c', 'src/core/lib/iomgr/iomgr_windows.c', + 'src/core/lib/iomgr/load_file.c', 'src/core/lib/iomgr/pollset_set_windows.c', 'src/core/lib/iomgr/pollset_windows.c', 'src/core/lib/iomgr/resolve_address_posix.c', diff --git a/build.yaml b/build.yaml index c87641652f..9425832c7d 100644 --- a/build.yaml +++ b/build.yaml @@ -67,7 +67,6 @@ filegroups: - src/core/lib/support/backoff.h - src/core/lib/support/block_annotate.h - src/core/lib/support/env.h - - src/core/lib/support/load_file.h - src/core/lib/support/murmur_hash.h - src/core/lib/support/stack_lockfree.h - src/core/lib/support/string.h @@ -91,7 +90,6 @@ filegroups: - src/core/lib/support/env_win32.c - src/core/lib/support/histogram.c - src/core/lib/support/host_port.c - - src/core/lib/support/load_file.c - src/core/lib/support/log.c - src/core/lib/support/log_android.c - src/core/lib/support/log_linux.c @@ -175,6 +173,7 @@ filegroups: - src/core/lib/iomgr/iomgr.h - src/core/lib/iomgr/iomgr_internal.h - src/core/lib/iomgr/iomgr_posix.h + - src/core/lib/iomgr/load_file.h - src/core/lib/iomgr/pollset.h - src/core/lib/iomgr/pollset_set.h - src/core/lib/iomgr/pollset_set_windows.h @@ -251,6 +250,7 @@ filegroups: - src/core/lib/iomgr/iomgr.c - src/core/lib/iomgr/iomgr_posix.c - src/core/lib/iomgr/iomgr_windows.c + - src/core/lib/iomgr/load_file.c - src/core/lib/iomgr/pollset_set_windows.c - src/core/lib/iomgr/pollset_windows.c - src/core/lib/iomgr/resolve_address_posix.c @@ -1473,15 +1473,6 @@ targets: deps: - gpr_test_util - gpr -- name: gpr_load_file_test - build: test - language: c - src: - - test/core/support/load_file_test.c - deps: - - grpc - - gpr_test_util - - gpr - name: gpr_log_test build: test language: c @@ -1954,6 +1945,16 @@ targets: - grpc - gpr_test_util - gpr +- name: load_file_test + build: test + language: c + src: + - test/core/iomgr/load_file_test.c + deps: + - grpc_test_util + - grpc + - gpr_test_util + - gpr - name: low_level_ping_pong_benchmark build: benchmark language: c diff --git a/config.m4 b/config.m4 index 0230353991..cb314e1eda 100644 --- a/config.m4 +++ b/config.m4 @@ -51,7 +51,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/support/env_win32.c \ src/core/lib/support/histogram.c \ src/core/lib/support/host_port.c \ - src/core/lib/support/load_file.c \ src/core/lib/support/log.c \ src/core/lib/support/log_android.c \ src/core/lib/support/log_linux.c \ @@ -110,6 +109,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/iomgr/iomgr.c \ src/core/lib/iomgr/iomgr_posix.c \ src/core/lib/iomgr/iomgr_windows.c \ + src/core/lib/iomgr/load_file.c \ src/core/lib/iomgr/pollset_set_windows.c \ src/core/lib/iomgr/pollset_windows.c \ src/core/lib/iomgr/resolve_address_posix.c \ diff --git a/gRPC.podspec b/gRPC.podspec index d8c6abc5ee..68cd1bda94 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -68,7 +68,6 @@ Pod::Spec.new do |s| 'src/core/lib/support/backoff.h', 'src/core/lib/support/block_annotate.h', 'src/core/lib/support/env.h', - 'src/core/lib/support/load_file.h', 'src/core/lib/support/murmur_hash.h', 'src/core/lib/support/stack_lockfree.h', 'src/core/lib/support/string.h', @@ -133,7 +132,6 @@ Pod::Spec.new do |s| 'src/core/lib/support/env_win32.c', 'src/core/lib/support/histogram.c', 'src/core/lib/support/host_port.c', - 'src/core/lib/support/load_file.c', 'src/core/lib/support/log.c', 'src/core/lib/support/log_android.c', 'src/core/lib/support/log_linux.c', @@ -191,6 +189,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/iomgr.h', 'src/core/lib/iomgr/iomgr_internal.h', 'src/core/lib/iomgr/iomgr_posix.h', + 'src/core/lib/iomgr/load_file.h', 'src/core/lib/iomgr/pollset.h', 'src/core/lib/iomgr/pollset_set.h', 'src/core/lib/iomgr/pollset_set_windows.h', @@ -371,6 +370,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/iomgr.c', 'src/core/lib/iomgr/iomgr_posix.c', 'src/core/lib/iomgr/iomgr_windows.c', + 'src/core/lib/iomgr/load_file.c', 'src/core/lib/iomgr/pollset_set_windows.c', 'src/core/lib/iomgr/pollset_windows.c', 'src/core/lib/iomgr/resolve_address_posix.c', @@ -527,7 +527,6 @@ Pod::Spec.new do |s| 'src/core/lib/support/backoff.h', 'src/core/lib/support/block_annotate.h', 'src/core/lib/support/env.h', - 'src/core/lib/support/load_file.h', 'src/core/lib/support/murmur_hash.h', 'src/core/lib/support/stack_lockfree.h', 'src/core/lib/support/string.h', @@ -562,6 +561,7 @@ Pod::Spec.new do |s| 'src/core/lib/iomgr/iomgr.h', 'src/core/lib/iomgr/iomgr_internal.h', 'src/core/lib/iomgr/iomgr_posix.h', + 'src/core/lib/iomgr/load_file.h', 'src/core/lib/iomgr/pollset.h', 'src/core/lib/iomgr/pollset_set.h', 'src/core/lib/iomgr/pollset_set_windows.h', diff --git a/grpc.gemspec b/grpc.gemspec index 2ab0514a35..05c5cc9f8d 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -89,7 +89,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/support/backoff.h ) s.files += %w( src/core/lib/support/block_annotate.h ) s.files += %w( src/core/lib/support/env.h ) - s.files += %w( src/core/lib/support/load_file.h ) s.files += %w( src/core/lib/support/murmur_hash.h ) s.files += %w( src/core/lib/support/stack_lockfree.h ) s.files += %w( src/core/lib/support/string.h ) @@ -112,7 +111,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/support/env_win32.c ) s.files += %w( src/core/lib/support/histogram.c ) s.files += %w( src/core/lib/support/host_port.c ) - s.files += %w( src/core/lib/support/load_file.c ) s.files += %w( src/core/lib/support/log.c ) s.files += %w( src/core/lib/support/log_android.c ) s.files += %w( src/core/lib/support/log_linux.c ) @@ -200,6 +198,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/iomgr.h ) s.files += %w( src/core/lib/iomgr/iomgr_internal.h ) s.files += %w( src/core/lib/iomgr/iomgr_posix.h ) + s.files += %w( src/core/lib/iomgr/load_file.h ) s.files += %w( src/core/lib/iomgr/pollset.h ) s.files += %w( src/core/lib/iomgr/pollset_set.h ) s.files += %w( src/core/lib/iomgr/pollset_set_windows.h ) @@ -350,6 +349,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/iomgr/iomgr.c ) s.files += %w( src/core/lib/iomgr/iomgr_posix.c ) s.files += %w( src/core/lib/iomgr/iomgr_windows.c ) + s.files += %w( src/core/lib/iomgr/load_file.c ) s.files += %w( src/core/lib/iomgr/pollset_set_windows.c ) s.files += %w( src/core/lib/iomgr/pollset_windows.c ) s.files += %w( src/core/lib/iomgr/resolve_address_posix.c ) diff --git a/package.xml b/package.xml index ee7cc1fcae..80cf67fde7 100644 --- a/package.xml +++ b/package.xml @@ -96,7 +96,6 @@ - @@ -119,7 +118,6 @@ - @@ -207,6 +205,7 @@ + @@ -357,6 +356,7 @@ + diff --git a/src/core/lib/iomgr/load_file.c b/src/core/lib/iomgr/load_file.c new file mode 100644 index 0000000000..b62ecbc534 --- /dev/null +++ b/src/core/lib/iomgr/load_file.c @@ -0,0 +1,89 @@ +/* + * + * 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. + * + */ + +#include "src/core/lib/iomgr/load_file.h" + +#include +#include + +#include +#include +#include + +#include "src/core/lib/support/block_annotate.h" +#include "src/core/lib/support/string.h" + +grpc_error *grpc_load_file(const char *filename, int add_null_terminator, + gpr_slice *output) { + unsigned char *contents = NULL; + size_t contents_size = 0; + gpr_slice result = gpr_empty_slice(); + FILE *file; + size_t bytes_read = 0; + grpc_error *error = GRPC_ERROR_NONE; + + GRPC_SCHEDULING_START_BLOCKING_REGION; + file = fopen(filename, "rb"); + if (file == NULL) { + error = GRPC_OS_ERROR(errno, "fopen"); + goto end; + } + fseek(file, 0, SEEK_END); + /* Converting to size_t on the assumption that it will not fail */ + contents_size = (size_t)ftell(file); + fseek(file, 0, SEEK_SET); + contents = gpr_malloc(contents_size + (add_null_terminator ? 1 : 0)); + bytes_read = fread(contents, 1, contents_size, file); + if (bytes_read < contents_size) { + error = GRPC_OS_ERROR(errno, "fread"); + GPR_ASSERT(ferror(file)); + goto end; + } + if (add_null_terminator) { + contents[contents_size++] = 0; + } + result = gpr_slice_new(contents, contents_size, gpr_free); + +end: + *output = result; + if (file != NULL) fclose(file); + if (error != GRPC_ERROR_NONE) { + grpc_error *error_out = grpc_error_set_str( + GRPC_ERROR_CREATE_REFERENCING("Failed to load file", &error, 1), + GRPC_ERROR_STR_FILENAME, filename); + GRPC_ERROR_UNREF(error); + error = error_out; + } + GRPC_SCHEDULING_END_BLOCKING_REGION; + return error; +} diff --git a/src/core/lib/iomgr/load_file.h b/src/core/lib/iomgr/load_file.h new file mode 100644 index 0000000000..961ef4867f --- /dev/null +++ b/src/core/lib/iomgr/load_file.h @@ -0,0 +1,56 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_SUPPORT_LOAD_FILE_H +#define GRPC_CORE_LIB_SUPPORT_LOAD_FILE_H + +#include + +#include + +#include "src/core/lib/iomgr/error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Loads the content of a file into a slice. add_null_terminator will add + a NULL terminator if non-zero. */ +grpc_error *grpc_load_file(const char *filename, int add_null_terminator, + gpr_slice *slice); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_CORE_LIB_SUPPORT_LOAD_FILE_H */ diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.c b/src/core/lib/security/credentials/google_default/google_default_credentials.c index 778773d6c8..29f818b8c8 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.c +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.c @@ -41,10 +41,10 @@ #include "src/core/lib/http/httpcli.h" #include "src/core/lib/http/parser.h" +#include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" #include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h" #include "src/core/lib/support/env.h" -#include "src/core/lib/support/load_file.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/api_trace.h" @@ -169,7 +169,7 @@ static grpc_error *create_default_creds_from_path( error = GRPC_ERROR_CREATE("creds_path unset"); goto end; } - error = gpr_load_file(creds_path, 0, &creds_data); + error = grpc_load_file(creds_path, 0, &creds_data); if (error != GRPC_ERROR_NONE) { goto end; } diff --git a/src/core/lib/security/transport/security_connector.c b/src/core/lib/security/transport/security_connector.c index 1803dbe824..03b64c5121 100644 --- a/src/core/lib/security/transport/security_connector.c +++ b/src/core/lib/security/transport/security_connector.c @@ -43,12 +43,12 @@ #include #include "src/core/ext/transport/chttp2/alpn/alpn.h" +#include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/transport/handshake.h" #include "src/core/lib/security/transport/secure_endpoint.h" #include "src/core/lib/support/env.h" -#include "src/core/lib/support/load_file.h" #include "src/core/lib/support/string.h" #include "src/core/lib/tsi/fake_transport_security.h" #include "src/core/lib/tsi/ssl_transport_security.h" @@ -636,7 +636,7 @@ static gpr_slice compute_default_pem_root_certs_once(void) { gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR); if (default_root_certs_path != NULL) { GRPC_LOG_IF_ERROR("load_file", - gpr_load_file(default_root_certs_path, 0, &result)); + grpc_load_file(default_root_certs_path, 0, &result)); gpr_free(default_root_certs_path); } @@ -655,7 +655,7 @@ static gpr_slice compute_default_pem_root_certs_once(void) { if (GPR_SLICE_IS_EMPTY(result) && ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) { GRPC_LOG_IF_ERROR("load_file", - gpr_load_file(installed_roots_path, 0, &result)); + grpc_load_file(installed_roots_path, 0, &result)); } return result; } diff --git a/src/core/lib/support/load_file.c b/src/core/lib/support/load_file.c deleted file mode 100644 index a78bb33a0c..0000000000 --- a/src/core/lib/support/load_file.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * 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. - * - */ - -#include "src/core/lib/support/load_file.h" - -#include -#include - -#include -#include -#include - -#include "src/core/lib/support/block_annotate.h" -#include "src/core/lib/support/string.h" - -grpc_error *gpr_load_file(const char *filename, int add_null_terminator, - gpr_slice *output) { - unsigned char *contents = NULL; - size_t contents_size = 0; - gpr_slice result = gpr_empty_slice(); - FILE *file; - size_t bytes_read = 0; - grpc_error *error = GRPC_ERROR_NONE; - - GRPC_SCHEDULING_START_BLOCKING_REGION; - file = fopen(filename, "rb"); - if (file == NULL) { - error = GRPC_OS_ERROR(errno, "fopen"); - goto end; - } - fseek(file, 0, SEEK_END); - /* Converting to size_t on the assumption that it will not fail */ - contents_size = (size_t)ftell(file); - fseek(file, 0, SEEK_SET); - contents = gpr_malloc(contents_size + (add_null_terminator ? 1 : 0)); - bytes_read = fread(contents, 1, contents_size, file); - if (bytes_read < contents_size) { - error = GRPC_OS_ERROR(errno, "fread"); - GPR_ASSERT(ferror(file)); - goto end; - } - if (add_null_terminator) { - contents[contents_size++] = 0; - } - result = gpr_slice_new(contents, contents_size, gpr_free); - -end: - *output = result; - if (file != NULL) fclose(file); - if (error != GRPC_ERROR_NONE) { - grpc_error *error_out = grpc_error_set_str( - GRPC_ERROR_CREATE_REFERENCING("Failed to load file", &error, 1), - GRPC_ERROR_STR_FILENAME, filename); - GRPC_ERROR_UNREF(error); - error = error_out; - } - GRPC_SCHEDULING_END_BLOCKING_REGION; - return error; -} diff --git a/src/core/lib/support/load_file.h b/src/core/lib/support/load_file.h deleted file mode 100644 index d4008a442f..0000000000 --- a/src/core/lib/support/load_file.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * 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. - * - */ - -#ifndef GRPC_CORE_LIB_SUPPORT_LOAD_FILE_H -#define GRPC_CORE_LIB_SUPPORT_LOAD_FILE_H - -#include - -#include - -#include "src/core/lib/iomgr/error.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Loads the content of a file into a slice. add_null_terminator will add - a NULL terminator if non-zero. */ -grpc_error *gpr_load_file(const char *filename, int add_null_terminator, - gpr_slice *slice); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_CORE_LIB_SUPPORT_LOAD_FILE_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index f6db376a28..4509f79d72 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -45,7 +45,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/support/env_win32.c', 'src/core/lib/support/histogram.c', 'src/core/lib/support/host_port.c', - 'src/core/lib/support/load_file.c', 'src/core/lib/support/log.c', 'src/core/lib/support/log_android.c', 'src/core/lib/support/log_linux.c', @@ -104,6 +103,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/iomgr/iomgr.c', 'src/core/lib/iomgr/iomgr_posix.c', 'src/core/lib/iomgr/iomgr_windows.c', + 'src/core/lib/iomgr/load_file.c', 'src/core/lib/iomgr/pollset_set_windows.c', 'src/core/lib/iomgr/pollset_windows.c', 'src/core/lib/iomgr/resolve_address_posix.c', diff --git a/test/core/bad_ssl/servers/cert.c b/test/core/bad_ssl/servers/cert.c index 67c3e29ce0..91dd9de81b 100644 --- a/test/core/bad_ssl/servers/cert.c +++ b/test/core/bad_ssl/servers/cert.c @@ -38,7 +38,7 @@ #include #include -#include "src/core/lib/support/load_file.h" +#include "src/core/lib/iomgr/load_file.h" #include "test/core/bad_ssl/server_common.h" #include "test/core/end2end/data/ssl_test_data.h" @@ -56,11 +56,11 @@ int main(int argc, char **argv) { grpc_init(); GPR_ASSERT(GRPC_LOG_IF_ERROR( - "load_file", gpr_load_file("src/core/lib/tsi/test_creds/badserver.pem", 1, - &cert_slice))); + "load_file", grpc_load_file("src/core/lib/tsi/test_creds/badserver.pem", + 1, &cert_slice))); GPR_ASSERT(GRPC_LOG_IF_ERROR( - "load_file", gpr_load_file("src/core/lib/tsi/test_creds/badserver.key", 1, - &key_slice))); + "load_file", grpc_load_file("src/core/lib/tsi/test_creds/badserver.key", + 1, &key_slice))); pem_key_cert_pair.private_key = (const char *)GPR_SLICE_START_PTR(key_slice); pem_key_cert_pair.cert_chain = (const char *)GPR_SLICE_START_PTR(cert_slice); diff --git a/test/core/internal_api_canaries/support.c b/test/core/internal_api_canaries/support.c index c51cbf2522..e992d2a66a 100644 --- a/test/core/internal_api_canaries/support.c +++ b/test/core/internal_api_canaries/support.c @@ -39,15 +39,15 @@ * This test is NOT expected to be run directly. ******************************************************************************/ +#include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/support/env.h" -#include "src/core/lib/support/load_file.h" #include "src/core/lib/support/tmpfile.h" static void test_code(void) { /* env.h */ gpr_set_env("abc", gpr_getenv("xyz")); /* load_file.h */ - gpr_load_file("abc", 1, NULL); + grpc_load_file("abc", 1, NULL); /* tmpfile.h */ fclose(gpr_tmpfile("foo", NULL)); } diff --git a/test/core/iomgr/load_file_test.c b/test/core/iomgr/load_file_test.c new file mode 100644 index 0000000000..f70295a81c --- /dev/null +++ b/test/core/iomgr/load_file_test.c @@ -0,0 +1,175 @@ +/* + * + * 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. + * + */ + +#include +#include + +#include +#include +#include + +#include "src/core/lib/iomgr/load_file.h" +#include "src/core/lib/support/string.h" +#include "src/core/lib/support/tmpfile.h" +#include "test/core/util/test_config.h" + +#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x) + +static const char prefix[] = "file_test"; + +static void test_load_empty_file(void) { + FILE *tmp = NULL; + gpr_slice slice; + gpr_slice slice_with_null_term; + grpc_error *error; + char *tmp_name; + + LOG_TEST_NAME("test_load_empty_file"); + + tmp = gpr_tmpfile(prefix, &tmp_name); + GPR_ASSERT(tmp_name != NULL); + GPR_ASSERT(tmp != NULL); + fclose(tmp); + + error = grpc_load_file(tmp_name, 0, &slice); + GPR_ASSERT(error == GRPC_ERROR_NONE); + GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0); + + error = grpc_load_file(tmp_name, 1, &slice_with_null_term); + GPR_ASSERT(error == GRPC_ERROR_NONE); + GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == 1); + GPR_ASSERT(GPR_SLICE_START_PTR(slice_with_null_term)[0] == 0); + + remove(tmp_name); + gpr_free(tmp_name); + gpr_slice_unref(slice); + gpr_slice_unref(slice_with_null_term); +} + +static void test_load_failure(void) { + FILE *tmp = NULL; + gpr_slice slice; + grpc_error *error; + char *tmp_name; + + LOG_TEST_NAME("test_load_failure"); + + tmp = gpr_tmpfile(prefix, &tmp_name); + GPR_ASSERT(tmp_name != NULL); + GPR_ASSERT(tmp != NULL); + fclose(tmp); + remove(tmp_name); + + error = grpc_load_file(tmp_name, 0, &slice); + GPR_ASSERT(error != GRPC_ERROR_NONE); + GRPC_ERROR_UNREF(error); + GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0); + gpr_free(tmp_name); + gpr_slice_unref(slice); +} + +static void test_load_small_file(void) { + FILE *tmp = NULL; + gpr_slice slice; + gpr_slice slice_with_null_term; + grpc_error *error; + char *tmp_name; + const char *blah = "blah"; + + LOG_TEST_NAME("test_load_small_file"); + + tmp = gpr_tmpfile(prefix, &tmp_name); + GPR_ASSERT(tmp_name != NULL); + GPR_ASSERT(tmp != NULL); + GPR_ASSERT(fwrite(blah, 1, strlen(blah), tmp) == strlen(blah)); + fclose(tmp); + + error = grpc_load_file(tmp_name, 0, &slice); + GPR_ASSERT(error == GRPC_ERROR_NONE); + GPR_ASSERT(GPR_SLICE_LENGTH(slice) == strlen(blah)); + GPR_ASSERT(!memcmp(GPR_SLICE_START_PTR(slice), blah, strlen(blah))); + + error = grpc_load_file(tmp_name, 1, &slice_with_null_term); + GPR_ASSERT(error == GRPC_ERROR_NONE); + GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1)); + GPR_ASSERT(strcmp((const char *)GPR_SLICE_START_PTR(slice_with_null_term), + blah) == 0); + + remove(tmp_name); + gpr_free(tmp_name); + gpr_slice_unref(slice); + gpr_slice_unref(slice_with_null_term); +} + +static void test_load_big_file(void) { + FILE *tmp = NULL; + gpr_slice slice; + grpc_error *error; + char *tmp_name; + static const size_t buffer_size = 124631; + unsigned char *buffer = gpr_malloc(buffer_size); + unsigned char *current; + size_t i; + + LOG_TEST_NAME("test_load_big_file"); + + memset(buffer, 42, buffer_size); + + tmp = gpr_tmpfile(prefix, &tmp_name); + GPR_ASSERT(tmp != NULL); + GPR_ASSERT(tmp_name != NULL); + GPR_ASSERT(fwrite(buffer, 1, buffer_size, tmp) == buffer_size); + fclose(tmp); + + error = grpc_load_file(tmp_name, 0, &slice); + GPR_ASSERT(error == GRPC_ERROR_NONE); + GPR_ASSERT(GPR_SLICE_LENGTH(slice) == buffer_size); + current = GPR_SLICE_START_PTR(slice); + for (i = 0; i < buffer_size; i++) { + GPR_ASSERT(current[i] == 42); + } + + remove(tmp_name); + gpr_free(tmp_name); + gpr_slice_unref(slice); + gpr_free(buffer); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + test_load_empty_file(); + test_load_failure(); + test_load_small_file(); + test_load_big_file(); + return 0; +} diff --git a/test/core/security/create_jwt.c b/test/core/security/create_jwt.c index 65468bc0ed..1bd135f175 100644 --- a/test/core/security/create_jwt.c +++ b/test/core/security/create_jwt.c @@ -34,8 +34,8 @@ #include #include +#include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" -#include "src/core/lib/support/load_file.h" #include #include @@ -48,7 +48,7 @@ void create_jwt(const char *json_key_file_path, const char *service_url, char *jwt; gpr_slice json_key_data; GPR_ASSERT(GRPC_LOG_IF_ERROR( - "load_file", gpr_load_file(json_key_file_path, 1, &json_key_data))); + "load_file", grpc_load_file(json_key_file_path, 1, &json_key_data))); key = grpc_auth_json_key_create_from_string( (const char *)GPR_SLICE_START_PTR(json_key_data)); gpr_slice_unref(json_key_data); diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.c index d970ff9c49..292f59a7c1 100644 --- a/test/core/security/fetch_oauth2.c +++ b/test/core/security/fetch_oauth2.c @@ -42,8 +42,8 @@ #include #include +#include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/support/load_file.h" #include "test/core/security/oauth2_utils.h" static grpc_call_credentials *create_refresh_token_creds( @@ -51,7 +51,7 @@ static grpc_call_credentials *create_refresh_token_creds( gpr_slice refresh_token; GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", - gpr_load_file(json_refresh_token_file_path, 1, &refresh_token))); + grpc_load_file(json_refresh_token_file_path, 1, &refresh_token))); return grpc_google_refresh_token_credentials_create( (const char *)GPR_SLICE_START_PTR(refresh_token), NULL); } diff --git a/test/core/support/load_file_test.c b/test/core/support/load_file_test.c deleted file mode 100644 index 9874db3d9a..0000000000 --- a/test/core/support/load_file_test.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * - * 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. - * - */ - -#include -#include - -#include -#include -#include - -#include "src/core/lib/support/load_file.h" -#include "src/core/lib/support/string.h" -#include "src/core/lib/support/tmpfile.h" -#include "test/core/util/test_config.h" - -#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x) - -static const char prefix[] = "file_test"; - -static void test_load_empty_file(void) { - FILE *tmp = NULL; - gpr_slice slice; - gpr_slice slice_with_null_term; - grpc_error *error; - char *tmp_name; - - LOG_TEST_NAME("test_load_empty_file"); - - tmp = gpr_tmpfile(prefix, &tmp_name); - GPR_ASSERT(tmp_name != NULL); - GPR_ASSERT(tmp != NULL); - fclose(tmp); - - error = gpr_load_file(tmp_name, 0, &slice); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0); - - error = gpr_load_file(tmp_name, 1, &slice_with_null_term); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == 1); - GPR_ASSERT(GPR_SLICE_START_PTR(slice_with_null_term)[0] == 0); - - remove(tmp_name); - gpr_free(tmp_name); - gpr_slice_unref(slice); - gpr_slice_unref(slice_with_null_term); -} - -static void test_load_failure(void) { - FILE *tmp = NULL; - gpr_slice slice; - grpc_error *error; - char *tmp_name; - - LOG_TEST_NAME("test_load_failure"); - - tmp = gpr_tmpfile(prefix, &tmp_name); - GPR_ASSERT(tmp_name != NULL); - GPR_ASSERT(tmp != NULL); - fclose(tmp); - remove(tmp_name); - - error = gpr_load_file(tmp_name, 0, &slice); - GPR_ASSERT(error != GRPC_ERROR_NONE); - GRPC_ERROR_UNREF(error); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0); - gpr_free(tmp_name); - gpr_slice_unref(slice); -} - -static void test_load_small_file(void) { - FILE *tmp = NULL; - gpr_slice slice; - gpr_slice slice_with_null_term; - grpc_error *error; - char *tmp_name; - const char *blah = "blah"; - - LOG_TEST_NAME("test_load_small_file"); - - tmp = gpr_tmpfile(prefix, &tmp_name); - GPR_ASSERT(tmp_name != NULL); - GPR_ASSERT(tmp != NULL); - GPR_ASSERT(fwrite(blah, 1, strlen(blah), tmp) == strlen(blah)); - fclose(tmp); - - error = gpr_load_file(tmp_name, 0, &slice); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == strlen(blah)); - GPR_ASSERT(!memcmp(GPR_SLICE_START_PTR(slice), blah, strlen(blah))); - - error = gpr_load_file(tmp_name, 1, &slice_with_null_term); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1)); - GPR_ASSERT(strcmp((const char *)GPR_SLICE_START_PTR(slice_with_null_term), - blah) == 0); - - remove(tmp_name); - gpr_free(tmp_name); - gpr_slice_unref(slice); - gpr_slice_unref(slice_with_null_term); -} - -static void test_load_big_file(void) { - FILE *tmp = NULL; - gpr_slice slice; - grpc_error *error; - char *tmp_name; - static const size_t buffer_size = 124631; - unsigned char *buffer = gpr_malloc(buffer_size); - unsigned char *current; - size_t i; - - LOG_TEST_NAME("test_load_big_file"); - - memset(buffer, 42, buffer_size); - - tmp = gpr_tmpfile(prefix, &tmp_name); - GPR_ASSERT(tmp != NULL); - GPR_ASSERT(tmp_name != NULL); - GPR_ASSERT(fwrite(buffer, 1, buffer_size, tmp) == buffer_size); - fclose(tmp); - - error = gpr_load_file(tmp_name, 0, &slice); - GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == buffer_size); - current = GPR_SLICE_START_PTR(slice); - for (i = 0; i < buffer_size; i++) { - GPR_ASSERT(current[i] == 42); - } - - remove(tmp_name); - gpr_free(tmp_name); - gpr_slice_unref(slice); - gpr_free(buffer); -} - -int main(int argc, char **argv) { - grpc_test_init(argc, argv); - test_load_empty_file(); - test_load_failure(); - test_load_small_file(); - test_load_big_file(); - return 0; -} diff --git a/test/core/util/one_corpus_entry_fuzzer.c b/test/core/util/one_corpus_entry_fuzzer.c index aeb2611f3f..2a23d006f1 100644 --- a/test/core/util/one_corpus_entry_fuzzer.c +++ b/test/core/util/one_corpus_entry_fuzzer.c @@ -32,14 +32,14 @@ */ #include -#include "src/core/lib/support/load_file.h" +#include "src/core/lib/iomgr/load_file.h" extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); int main(int argc, char **argv) { gpr_slice buffer; GPR_ASSERT( - GRPC_LOG_IF_ERROR("load_file", gpr_load_file(argv[1], 0, &buffer))); + GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer))); LLVMFuzzerTestOneInput(GPR_SLICE_START_PTR(buffer), GPR_SLICE_LENGTH(buffer)); gpr_slice_unref(buffer); return 0; diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index f07c6dfa37..cc1835d3d5 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -817,6 +817,7 @@ src/core/lib/iomgr/iocp_windows.h \ src/core/lib/iomgr/iomgr.h \ src/core/lib/iomgr/iomgr_internal.h \ src/core/lib/iomgr/iomgr_posix.h \ +src/core/lib/iomgr/load_file.h \ src/core/lib/iomgr/pollset.h \ src/core/lib/iomgr/pollset_set.h \ src/core/lib/iomgr/pollset_set_windows.h \ @@ -967,6 +968,7 @@ src/core/lib/iomgr/iocp_windows.c \ src/core/lib/iomgr/iomgr.c \ src/core/lib/iomgr/iomgr_posix.c \ src/core/lib/iomgr/iomgr_windows.c \ +src/core/lib/iomgr/load_file.c \ src/core/lib/iomgr/pollset_set_windows.c \ src/core/lib/iomgr/pollset_windows.c \ src/core/lib/iomgr/resolve_address_posix.c \ @@ -1164,7 +1166,6 @@ src/core/lib/profiling/timers.h \ src/core/lib/support/backoff.h \ src/core/lib/support/block_annotate.h \ src/core/lib/support/env.h \ -src/core/lib/support/load_file.h \ src/core/lib/support/murmur_hash.h \ src/core/lib/support/stack_lockfree.h \ src/core/lib/support/string.h \ @@ -1187,7 +1188,6 @@ src/core/lib/support/env_posix.c \ src/core/lib/support/env_win32.c \ src/core/lib/support/histogram.c \ src/core/lib/support/host_port.c \ -src/core/lib/support/load_file.c \ src/core/lib/support/log.c \ src/core/lib/support/log_android.c \ src/core/lib/support/log_linux.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 85c5a37a51..8589a837b8 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -536,21 +536,6 @@ "third_party": false, "type": "target" }, - { - "deps": [ - "gpr", - "gpr_test_util", - "grpc" - ], - "headers": [], - "language": "c", - "name": "gpr_load_file_test", - "src": [ - "test/core/support/load_file_test.c" - ], - "third_party": false, - "type": "target" - }, { "deps": [ "gpr", @@ -1265,6 +1250,22 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc_test_util" + ], + "headers": [], + "language": "c", + "name": "load_file_test", + "src": [ + "test/core/iomgr/load_file_test.c" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", @@ -5471,7 +5472,6 @@ "src/core/lib/support/backoff.h", "src/core/lib/support/block_annotate.h", "src/core/lib/support/env.h", - "src/core/lib/support/load_file.h", "src/core/lib/support/murmur_hash.h", "src/core/lib/support/stack_lockfree.h", "src/core/lib/support/string.h", @@ -5530,8 +5530,6 @@ "src/core/lib/support/env_win32.c", "src/core/lib/support/histogram.c", "src/core/lib/support/host_port.c", - "src/core/lib/support/load_file.c", - "src/core/lib/support/load_file.h", "src/core/lib/support/log.c", "src/core/lib/support/log_android.c", "src/core/lib/support/log_linux.c", @@ -5650,6 +5648,7 @@ "src/core/lib/iomgr/iomgr.h", "src/core/lib/iomgr/iomgr_internal.h", "src/core/lib/iomgr/iomgr_posix.h", + "src/core/lib/iomgr/load_file.h", "src/core/lib/iomgr/pollset.h", "src/core/lib/iomgr/pollset_set.h", "src/core/lib/iomgr/pollset_set_windows.h", @@ -5761,6 +5760,8 @@ "src/core/lib/iomgr/iomgr_posix.c", "src/core/lib/iomgr/iomgr_posix.h", "src/core/lib/iomgr/iomgr_windows.c", + "src/core/lib/iomgr/load_file.c", + "src/core/lib/iomgr/load_file.h", "src/core/lib/iomgr/pollset.h", "src/core/lib/iomgr/pollset_set.h", "src/core/lib/iomgr/pollset_set_windows.c", diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 89e483933e..e4dd31be44 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -598,27 +598,6 @@ "windows" ] }, - { - "args": [], - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "flaky": false, - "gtest": false, - "language": "c", - "name": "gpr_load_file_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ] - }, { "args": [], "ci_platforms": [ @@ -1323,6 +1302,27 @@ "windows" ] }, + { + "args": [], + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "load_file_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ] + }, { "args": [], "ci_platforms": [ diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln index 95a7f17e52..a348b2f36d 100644 --- a/vsprojects/buildtests_c.sln +++ b/vsprojects/buildtests_c.sln @@ -389,16 +389,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_host_port_test", "vcxpr {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_load_file_test", "vcxproj\test\gpr_load_file_test\gpr_load_file_test.vcxproj", "{B36DE5B4-8B73-1194-7539-974D9524D609}" - ProjectSection(myProperties) = preProject - lib = "False" - EndProjectSection - ProjectSection(ProjectDependencies) = postProject - {29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9} - {EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037} - {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_log_test", "vcxproj\test\gpr_log_test\gpr_log_test.vcxproj", "{38797EE3-62CC-3CBF-18D5-009ED6DD0BEC}" ProjectSection(myProperties) = preProject lib = "False" @@ -806,6 +796,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lb_policies_test", "vcxproj {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "load_file_test", "vcxproj\test\load_file_test\load_file_test.vcxproj", "{DC76C089-0D55-DF19-7CCA-49DAE5D29E49}" + ProjectSection(myProperties) = preProject + lib = "False" + EndProjectSection + ProjectSection(ProjectDependencies) = postProject + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + {29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9} + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "message_compress_test", "vcxproj\test\message_compress_test\message_compress_test.vcxproj", "{07170557-CCB0-D23C-8018-C2909D115DF9}" ProjectSection(myProperties) = preProject lib = "False" @@ -2044,22 +2045,6 @@ Global {64728265-92F9-103E-6720-8935385458DF}.Release-DLL|Win32.Build.0 = Release|Win32 {64728265-92F9-103E-6720-8935385458DF}.Release-DLL|x64.ActiveCfg = Release|x64 {64728265-92F9-103E-6720-8935385458DF}.Release-DLL|x64.Build.0 = Release|x64 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Debug|Win32.ActiveCfg = Debug|Win32 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Debug|x64.ActiveCfg = Debug|x64 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Release|Win32.ActiveCfg = Release|Win32 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Release|x64.ActiveCfg = Release|x64 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Debug|Win32.Build.0 = Debug|Win32 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Debug|x64.Build.0 = Debug|x64 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Release|Win32.Build.0 = Release|Win32 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Release|x64.Build.0 = Release|x64 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Debug-DLL|Win32.ActiveCfg = Debug|Win32 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Debug-DLL|Win32.Build.0 = Debug|Win32 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Debug-DLL|x64.ActiveCfg = Debug|x64 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Debug-DLL|x64.Build.0 = Debug|x64 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Release-DLL|Win32.ActiveCfg = Release|Win32 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Release-DLL|Win32.Build.0 = Release|Win32 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Release-DLL|x64.ActiveCfg = Release|x64 - {B36DE5B4-8B73-1194-7539-974D9524D609}.Release-DLL|x64.Build.0 = Release|x64 {38797EE3-62CC-3CBF-18D5-009ED6DD0BEC}.Debug|Win32.ActiveCfg = Debug|Win32 {38797EE3-62CC-3CBF-18D5-009ED6DD0BEC}.Debug|x64.ActiveCfg = Debug|x64 {38797EE3-62CC-3CBF-18D5-009ED6DD0BEC}.Release|Win32.ActiveCfg = Release|Win32 @@ -2684,6 +2669,22 @@ Global {62D58A08-3B5E-D6A8-ABBB-77995AA0A8C6}.Release-DLL|Win32.Build.0 = Release|Win32 {62D58A08-3B5E-D6A8-ABBB-77995AA0A8C6}.Release-DLL|x64.ActiveCfg = Release|x64 {62D58A08-3B5E-D6A8-ABBB-77995AA0A8C6}.Release-DLL|x64.Build.0 = Release|x64 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Debug|Win32.ActiveCfg = Debug|Win32 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Debug|x64.ActiveCfg = Debug|x64 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Release|Win32.ActiveCfg = Release|Win32 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Release|x64.ActiveCfg = Release|x64 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Debug|Win32.Build.0 = Debug|Win32 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Debug|x64.Build.0 = Debug|x64 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Release|Win32.Build.0 = Release|Win32 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Release|x64.Build.0 = Release|x64 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Debug-DLL|Win32.ActiveCfg = Debug|Win32 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Debug-DLL|Win32.Build.0 = Debug|Win32 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Debug-DLL|x64.ActiveCfg = Debug|x64 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Debug-DLL|x64.Build.0 = Debug|x64 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Release-DLL|Win32.ActiveCfg = Release|Win32 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Release-DLL|Win32.Build.0 = Release|Win32 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Release-DLL|x64.ActiveCfg = Release|x64 + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49}.Release-DLL|x64.Build.0 = Release|x64 {07170557-CCB0-D23C-8018-C2909D115DF9}.Debug|Win32.ActiveCfg = Debug|Win32 {07170557-CCB0-D23C-8018-C2909D115DF9}.Debug|x64.ActiveCfg = Debug|x64 {07170557-CCB0-D23C-8018-C2909D115DF9}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj index 26195bb541..2911fe58b9 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj @@ -195,7 +195,6 @@ - @@ -235,8 +234,6 @@ - - diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters index be15391b09..e35a3355e5 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters @@ -46,9 +46,6 @@ src\core\lib\support - - src\core\lib\support - src\core\lib\support @@ -281,9 +278,6 @@ src\core\lib\support - - src\core\lib\support - src\core\lib\support diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 99bb0aa954..c55a88fc42 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -326,6 +326,7 @@ + @@ -506,6 +507,8 @@ + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index bfaa41e345..571b2c0c5b 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -85,6 +85,9 @@ src\core\lib\iomgr + + src\core\lib\iomgr + src\core\lib\iomgr @@ -713,6 +716,9 @@ src\core\lib\iomgr + + src\core\lib\iomgr + src\core\lib\iomgr diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index eef5a13927..626bd67073 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -314,6 +314,7 @@ + @@ -471,6 +472,8 @@ + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index e38e8ca38b..36992db569 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -88,6 +88,9 @@ src\core\lib\iomgr + + src\core\lib\iomgr + src\core\lib\iomgr @@ -608,6 +611,9 @@ src\core\lib\iomgr + + src\core\lib\iomgr + src\core\lib\iomgr diff --git a/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj b/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj deleted file mode 100644 index 504ef8815c..0000000000 --- a/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {B36DE5B4-8B73-1194-7539-974D9524D609} - true - $(SolutionDir)IntDir\$(MSBuildProjectName)\ - - - - v100 - - - v110 - - - v120 - - - v140 - - - Application - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - gpr_load_file_test - static - Debug - static - Debug - - - gpr_load_file_test - static - Release - static - Release - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - None - false - - - Console - true - false - - - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - None - false - - - Console - true - false - - - - - - NotUsing - Level3 - MaxSpeed - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - true - true - MultiThreaded - true - None - false - - - Console - true - false - true - true - - - - - - NotUsing - Level3 - MaxSpeed - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - true - true - MultiThreaded - true - None - false - - - Console - true - false - true - true - - - - - - - - - - {29D16885-7228-4C31-81ED-5F9187C7F2A9} - - - {EAB0A629-17A9-44DB-B5FF-E91A721FE037} - - - {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - diff --git a/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj.filters b/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj.filters deleted file mode 100644 index 0edd0fe299..0000000000 --- a/vsprojects/vcxproj/test/gpr_load_file_test/gpr_load_file_test.vcxproj.filters +++ /dev/null @@ -1,21 +0,0 @@ - - - - - test\core\support - - - - - - {7defb822-a4cc-a221-8900-1041a6c2c134} - - - {3f3cae49-1efd-7015-0fa1-5621168945d5} - - - {54e9b9b9-021a-139b-53f2-2f8b7173306c} - - - - diff --git a/vsprojects/vcxproj/test/load_file_test/load_file_test.vcxproj b/vsprojects/vcxproj/test/load_file_test/load_file_test.vcxproj new file mode 100644 index 0000000000..52fbcccb04 --- /dev/null +++ b/vsprojects/vcxproj/test/load_file_test/load_file_test.vcxproj @@ -0,0 +1,199 @@ + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DC76C089-0D55-DF19-7CCA-49DAE5D29E49} + true + $(SolutionDir)IntDir\$(MSBuildProjectName)\ + + + + v100 + + + v110 + + + v120 + + + v140 + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + load_file_test + static + Debug + static + Debug + + + load_file_test + static + Release + static + Release + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + + + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + + + {29D16885-7228-4C31-81ED-5F9187C7F2A9} + + + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + diff --git a/vsprojects/vcxproj/test/load_file_test/load_file_test.vcxproj.filters b/vsprojects/vcxproj/test/load_file_test/load_file_test.vcxproj.filters new file mode 100644 index 0000000000..2c7934b5a1 --- /dev/null +++ b/vsprojects/vcxproj/test/load_file_test/load_file_test.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + test\core\iomgr + + + + + + {2d5b633c-62d3-3391-6d61-6521bf33e82d} + + + {30d9062f-1ea2-7ee4-249c-0e4220cb5153} + + + {a23b62a8-d5fc-3114-9aa2-8065e49214e8} + + + + -- cgit v1.2.3