From ba130550fcb87ce15c60b3339adb268905d3b2b1 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 24 Sep 2015 13:43:01 -0700 Subject: Put in blocking point annotations at places in the code where we may block for reasons other than synchronization --- src/core/iomgr/pollset_posix.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/core/iomgr/pollset_posix.c') diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index f3e424e83c..cfdfbcf606 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -43,6 +43,7 @@ #include #include "src/core/iomgr/alarm_internal.h" +#include "src/core/iomgr/block_annotate.h" #include "src/core/iomgr/fd_posix.h" #include "src/core/iomgr/iomgr_internal.h" #include "src/core/iomgr/socket_utils_posix.h" @@ -453,7 +454,9 @@ static void basic_pollset_maybe_work(grpc_pollset *pollset, /* poll fd count (argument 2) is shortened by one if we have no events to poll on - such that it only includes the kicker */ + GRPC_IOMGR_START_BLOCKING_REGION; r = grpc_poll_function(pfd, nfds, timeout); + GRPC_IOMGR_END_BLOCKING_REGION; GRPC_TIMER_MARK(GRPC_PTAG_POLL_FINISHED, r); if (fd) { -- cgit v1.2.3 From 9839d285cd39d3fd2a16f3393f33e72f1e6b645b Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 24 Sep 2015 17:55:18 -0700 Subject: Move block_annotate from iomgr to support since it's used in other core places besides iomgr --- BUILD | 5 +- build.yaml | 56 +++++++++++----------- gRPC.podspec | 8 ++-- src/core/iomgr/block_annotate.h | 44 ----------------- src/core/iomgr/pollset_multipoller_with_epoll.c | 10 ++-- .../iomgr/pollset_multipoller_with_poll_posix.c | 6 +-- src/core/iomgr/pollset_posix.c | 6 +-- src/core/iomgr/resolve_address_posix.c | 10 ++-- src/core/iomgr/resolve_address_windows.c | 6 +-- src/core/support/block_annotate.h | 44 +++++++++++++++++ src/core/support/file.c | 6 +-- src/core/support/time_posix.c | 6 +-- src/core/support/time_win32.c | 6 +-- tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/sources_and_headers.json | 6 +-- vsprojects/vcxproj/gpr/gpr.vcxproj | 1 + vsprojects/vcxproj/gpr/gpr.vcxproj.filters | 3 ++ vsprojects/vcxproj/grpc/grpc.vcxproj | 1 - vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 3 -- .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 1 - .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 3 -- 21 files changed, 113 insertions(+), 120 deletions(-) delete mode 100644 src/core/iomgr/block_annotate.h create mode 100644 src/core/support/block_annotate.h (limited to 'src/core/iomgr/pollset_posix.c') diff --git a/BUILD b/BUILD index 69b5c32070..955d224574 100644 --- a/BUILD +++ b/BUILD @@ -44,6 +44,7 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "gpr", srcs = [ + "src/core/support/block_annotate.h", "src/core/support/env.h", "src/core/support/file.h", "src/core/support/murmur_hash.h", @@ -179,7 +180,6 @@ cc_library( "src/core/iomgr/alarm.h", "src/core/iomgr/alarm_heap.h", "src/core/iomgr/alarm_internal.h", - "src/core/iomgr/block_annotate.h", "src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint_pair.h", "src/core/iomgr/fd_posix.h", @@ -456,7 +456,6 @@ cc_library( "src/core/iomgr/alarm.h", "src/core/iomgr/alarm_heap.h", "src/core/iomgr/alarm_internal.h", - "src/core/iomgr/block_annotate.h", "src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint_pair.h", "src/core/iomgr/fd_posix.h", @@ -1007,6 +1006,7 @@ objc_library( "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", + "src/core/support/block_annotate.h", "src/core/support/env.h", "src/core/support/file.h", "src/core/support/murmur_hash.h", @@ -1229,7 +1229,6 @@ objc_library( "src/core/iomgr/alarm.h", "src/core/iomgr/alarm_heap.h", "src/core/iomgr/alarm_internal.h", - "src/core/iomgr/block_annotate.h", "src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint_pair.h", "src/core/iomgr/fd_posix.h", diff --git a/build.yaml b/build.yaml index 4479ca655c..a9aba93f32 100644 --- a/build.yaml +++ b/build.yaml @@ -55,31 +55,31 @@ filegroups: src/core/client_config/uri_parser.h, src/core/compression/message_compress.h, src/core/debug/trace.h, src/core/httpcli/format_request.h, src/core/httpcli/httpcli.h, src/core/httpcli/parser.h, src/core/iomgr/alarm.h, src/core/iomgr/alarm_heap.h, - src/core/iomgr/alarm_internal.h, src/core/iomgr/block_annotate.h, src/core/iomgr/endpoint.h, - src/core/iomgr/endpoint_pair.h, src/core/iomgr/fd_posix.h, src/core/iomgr/iocp_windows.h, - src/core/iomgr/iomgr.h, src/core/iomgr/iomgr_internal.h, src/core/iomgr/iomgr_posix.h, - src/core/iomgr/pollset.h, src/core/iomgr/pollset_posix.h, src/core/iomgr/pollset_set.h, - src/core/iomgr/pollset_set_posix.h, src/core/iomgr/pollset_set_windows.h, src/core/iomgr/pollset_windows.h, - src/core/iomgr/resolve_address.h, src/core/iomgr/sockaddr.h, src/core/iomgr/sockaddr_posix.h, - src/core/iomgr/sockaddr_utils.h, src/core/iomgr/sockaddr_win32.h, src/core/iomgr/socket_utils_posix.h, - src/core/iomgr/socket_windows.h, src/core/iomgr/tcp_client.h, src/core/iomgr/tcp_posix.h, - src/core/iomgr/tcp_server.h, src/core/iomgr/tcp_windows.h, src/core/iomgr/time_averaged_stats.h, - src/core/iomgr/udp_server.h, src/core/iomgr/wakeup_fd_pipe.h, src/core/iomgr/wakeup_fd_posix.h, - src/core/json/json.h, src/core/json/json_common.h, src/core/json/json_reader.h, - src/core/json/json_writer.h, src/core/profiling/timers.h, src/core/statistics/census_interface.h, - src/core/statistics/census_rpc_stats.h, src/core/surface/byte_buffer_queue.h, - src/core/surface/call.h, src/core/surface/channel.h, src/core/surface/completion_queue.h, - src/core/surface/event_string.h, src/core/surface/init.h, src/core/surface/server.h, - src/core/surface/surface_trace.h, src/core/transport/chttp2/alpn.h, src/core/transport/chttp2/bin_encoder.h, - src/core/transport/chttp2/frame.h, src/core/transport/chttp2/frame_data.h, src/core/transport/chttp2/frame_goaway.h, - src/core/transport/chttp2/frame_ping.h, src/core/transport/chttp2/frame_rst_stream.h, - src/core/transport/chttp2/frame_settings.h, src/core/transport/chttp2/frame_window_update.h, - src/core/transport/chttp2/hpack_parser.h, src/core/transport/chttp2/hpack_table.h, - src/core/transport/chttp2/http2_errors.h, src/core/transport/chttp2/huffsyms.h, - src/core/transport/chttp2/incoming_metadata.h, src/core/transport/chttp2/internal.h, - src/core/transport/chttp2/status_conversion.h, src/core/transport/chttp2/stream_encoder.h, - src/core/transport/chttp2/stream_map.h, src/core/transport/chttp2/timeout_encoding.h, - src/core/transport/chttp2/varint.h, src/core/transport/chttp2_transport.h, src/core/transport/connectivity_state.h, + src/core/iomgr/alarm_internal.h, src/core/iomgr/endpoint.h, src/core/iomgr/endpoint_pair.h, + src/core/iomgr/fd_posix.h, src/core/iomgr/iocp_windows.h, src/core/iomgr/iomgr.h, + src/core/iomgr/iomgr_internal.h, src/core/iomgr/iomgr_posix.h, src/core/iomgr/pollset.h, + src/core/iomgr/pollset_posix.h, src/core/iomgr/pollset_set.h, src/core/iomgr/pollset_set_posix.h, + src/core/iomgr/pollset_set_windows.h, src/core/iomgr/pollset_windows.h, src/core/iomgr/resolve_address.h, + src/core/iomgr/sockaddr.h, src/core/iomgr/sockaddr_posix.h, src/core/iomgr/sockaddr_utils.h, + src/core/iomgr/sockaddr_win32.h, src/core/iomgr/socket_utils_posix.h, src/core/iomgr/socket_windows.h, + src/core/iomgr/tcp_client.h, src/core/iomgr/tcp_posix.h, src/core/iomgr/tcp_server.h, + src/core/iomgr/tcp_windows.h, src/core/iomgr/time_averaged_stats.h, src/core/iomgr/udp_server.h, + src/core/iomgr/wakeup_fd_pipe.h, src/core/iomgr/wakeup_fd_posix.h, src/core/json/json.h, + src/core/json/json_common.h, src/core/json/json_reader.h, src/core/json/json_writer.h, + src/core/profiling/timers.h, src/core/statistics/census_interface.h, src/core/statistics/census_rpc_stats.h, + src/core/surface/byte_buffer_queue.h, src/core/surface/call.h, src/core/surface/channel.h, + src/core/surface/completion_queue.h, src/core/surface/event_string.h, src/core/surface/init.h, + src/core/surface/server.h, src/core/surface/surface_trace.h, src/core/transport/chttp2/alpn.h, + src/core/transport/chttp2/bin_encoder.h, src/core/transport/chttp2/frame.h, src/core/transport/chttp2/frame_data.h, + src/core/transport/chttp2/frame_goaway.h, src/core/transport/chttp2/frame_ping.h, + src/core/transport/chttp2/frame_rst_stream.h, src/core/transport/chttp2/frame_settings.h, + src/core/transport/chttp2/frame_window_update.h, src/core/transport/chttp2/hpack_parser.h, + src/core/transport/chttp2/hpack_table.h, src/core/transport/chttp2/http2_errors.h, + src/core/transport/chttp2/huffsyms.h, src/core/transport/chttp2/incoming_metadata.h, + src/core/transport/chttp2/internal.h, src/core/transport/chttp2/status_conversion.h, + src/core/transport/chttp2/stream_encoder.h, src/core/transport/chttp2/stream_map.h, + src/core/transport/chttp2/timeout_encoding.h, src/core/transport/chttp2/varint.h, + src/core/transport/chttp2_transport.h, src/core/transport/connectivity_state.h, src/core/transport/metadata.h, src/core/transport/stream_op.h, src/core/transport/transport.h, src/core/transport/transport_impl.h] src: [src/core/census/grpc_context.c, src/core/census/grpc_filter.c, src/core/channel/channel_args.c, @@ -148,9 +148,9 @@ libs: include/grpc/support/sync_posix.h, include/grpc/support/sync_win32.h, include/grpc/support/thd.h, include/grpc/support/time.h, include/grpc/support/tls.h, include/grpc/support/tls_gcc.h, include/grpc/support/tls_msvc.h, include/grpc/support/tls_pthread.h, include/grpc/support/useful.h] - headers: [src/core/support/env.h, src/core/support/file.h, src/core/support/murmur_hash.h, - src/core/support/stack_lockfree.h, src/core/support/string.h, src/core/support/string_win32.h, - src/core/support/thd_internal.h, src/core/support/time_precise.h] + headers: [src/core/support/block_annotate.h, src/core/support/env.h, src/core/support/file.h, + src/core/support/murmur_hash.h, src/core/support/stack_lockfree.h, src/core/support/string.h, + src/core/support/string_win32.h, src/core/support/thd_internal.h, src/core/support/time_precise.h] src: [src/core/support/alloc.c, src/core/support/cmdline.c, src/core/support/cpu_iphone.c, src/core/support/cpu_linux.c, src/core/support/cpu_posix.c, src/core/support/cpu_windows.c, src/core/support/env_linux.c, src/core/support/env_posix.c, src/core/support/env_win32.c, diff --git a/gRPC.podspec b/gRPC.podspec index 38d6b2861f..a8d586f847 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -61,7 +61,8 @@ Pod::Spec.new do |s| # Core cross-platform gRPC library, written in C. s.subspec 'C-Core' do |ss| - ss.source_files = 'src/core/support/env.h', + ss.source_files = 'src/core/support/block_annotate.h', + 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/stack_lockfree.h', @@ -181,7 +182,6 @@ Pod::Spec.new do |s| 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', - 'src/core/iomgr/block_annotate.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', @@ -406,7 +406,8 @@ Pod::Spec.new do |s| 'src/core/census/operation.c', 'src/core/census/tracing.c' - ss.private_header_files = 'src/core/support/env.h', + ss.private_header_files = 'src/core/support/block_annotate.h', + 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', 'src/core/support/stack_lockfree.h', @@ -462,7 +463,6 @@ Pod::Spec.new do |s| 'src/core/iomgr/alarm.h', 'src/core/iomgr/alarm_heap.h', 'src/core/iomgr/alarm_internal.h', - 'src/core/iomgr/block_annotate.h', 'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/fd_posix.h', diff --git a/src/core/iomgr/block_annotate.h b/src/core/iomgr/block_annotate.h deleted file mode 100644 index c962da0a89..0000000000 --- a/src/core/iomgr/block_annotate.h +++ /dev/null @@ -1,44 +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_INTERNAL_CORE_IOMGR_BLOCK_ANNOTATE_H -#define GRPC_INTERNAL_CORE_IOMGR_BLOCK_ANNOTATE_H - -/* These annotations identify the beginning and end of regions where - the code may block for reasons other than synchronization functions. - These include poll, epoll, and getaddrinfo. */ - -#define GRPC_IOMGR_START_BLOCKING_REGION do {} while (0) -#define GRPC_IOMGR_END_BLOCKING_REGION do {} while (0) - -#endif /* GRPC_INTERNAL_CORE_IOMGR_BLOCK_ANNOTATE_H */ diff --git a/src/core/iomgr/pollset_multipoller_with_epoll.c b/src/core/iomgr/pollset_multipoller_with_epoll.c index 39746d501b..65d1517291 100644 --- a/src/core/iomgr/pollset_multipoller_with_epoll.c +++ b/src/core/iomgr/pollset_multipoller_with_epoll.c @@ -41,8 +41,8 @@ #include #include -#include "src/core/iomgr/block_annotate.h" #include "src/core/iomgr/fd_posix.h" +#include "src/core/support/block_annotate.h" #include #include @@ -181,9 +181,9 @@ static void multipoll_with_epoll_pollset_maybe_work( pfds[1].events = POLLIN; pfds[1].revents = 0; - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; poll_rv = grpc_poll_function(pfds, 2, timeout_ms); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; if (poll_rv < 0) { if (errno != EINTR) { @@ -197,9 +197,9 @@ static void multipoll_with_epoll_pollset_maybe_work( } if (pfds[1].revents) { do { - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; ep_rv = epoll_wait(h->epoll_fd, ep_ev, GRPC_EPOLL_MAX_EVENTS, 0); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; if (ep_rv < 0) { if (errno != EINTR) { gpr_log(GPR_ERROR, "epoll_wait() failed: %s", strerror(errno)); diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c index 0b12aaca6d..75bba8214d 100644 --- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c +++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c @@ -42,9 +42,9 @@ #include #include -#include "src/core/iomgr/block_annotate.h" #include "src/core/iomgr/fd_posix.h" #include "src/core/iomgr/iomgr_internal.h" +#include "src/core/support/block_annotate.h" #include #include #include @@ -146,9 +146,9 @@ static void multipoll_with_poll_pollset_maybe_work( POLLOUT, &watchers[i]); } - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; r = grpc_poll_function(pfds, pfd_count, timeout); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; for (i = 1; i < pfd_count; i++) { grpc_fd_end_poll(&watchers[i], pfds[i].revents & POLLIN, diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index cfdfbcf606..7d5340140c 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -43,11 +43,11 @@ #include #include "src/core/iomgr/alarm_internal.h" -#include "src/core/iomgr/block_annotate.h" #include "src/core/iomgr/fd_posix.h" #include "src/core/iomgr/iomgr_internal.h" #include "src/core/iomgr/socket_utils_posix.h" #include "src/core/profiling/timers.h" +#include "src/core/support/block_annotate.h" #include #include #include @@ -454,9 +454,9 @@ static void basic_pollset_maybe_work(grpc_pollset *pollset, /* poll fd count (argument 2) is shortened by one if we have no events to poll on - such that it only includes the kicker */ - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; r = grpc_poll_function(pfd, nfds, timeout); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; GRPC_TIMER_MARK(GRPC_PTAG_POLL_FINISHED, r); if (fd) { diff --git a/src/core/iomgr/resolve_address_posix.c b/src/core/iomgr/resolve_address_posix.c index e7ebe3a2e6..00b7423eab 100644 --- a/src/core/iomgr/resolve_address_posix.c +++ b/src/core/iomgr/resolve_address_posix.c @@ -41,9 +41,9 @@ #include #include -#include "src/core/iomgr/block_annotate.h" #include "src/core/iomgr/iomgr_internal.h" #include "src/core/iomgr/sockaddr_utils.h" +#include "src/core/support/block_annotate.h" #include "src/core/support/string.h" #include #include @@ -104,18 +104,18 @@ grpc_resolved_addresses *grpc_blocking_resolve_address( hints.ai_socktype = SOCK_STREAM; /* stream socket */ hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; s = getaddrinfo(host, port, &hints, &result); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; if (s != 0) { /* Retry if well-known service name is recognized */ char *svc[][2] = {{"http", "80"}, {"https", "443"}}; for (i = 0; i < GPR_ARRAY_SIZE(svc); i++) { if (strcmp(port, svc[i][0]) == 0) { - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; s = getaddrinfo(host, svc[i][1], &hints, &result); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; break; } } diff --git a/src/core/iomgr/resolve_address_windows.c b/src/core/iomgr/resolve_address_windows.c index e9297a7895..5e63df9f66 100644 --- a/src/core/iomgr/resolve_address_windows.c +++ b/src/core/iomgr/resolve_address_windows.c @@ -40,9 +40,9 @@ #include #include -#include "src/core/iomgr/block_annotate.h" #include "src/core/iomgr/iomgr_internal.h" #include "src/core/iomgr/sockaddr_utils.h" +#include "src/core/support/block_annotate.h" #include "src/core/support/string.h" #include #include @@ -89,9 +89,9 @@ grpc_resolved_addresses *grpc_blocking_resolve_address( hints.ai_socktype = SOCK_STREAM; /* stream socket */ hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; s = getaddrinfo(host, port, &hints, &result); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; if (s != 0) { gpr_log(GPR_ERROR, "getaddrinfo: %s", gai_strerror(s)); goto done; diff --git a/src/core/support/block_annotate.h b/src/core/support/block_annotate.h new file mode 100644 index 0000000000..bf2c17f859 --- /dev/null +++ b/src/core/support/block_annotate.h @@ -0,0 +1,44 @@ +/* + * + * 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_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H +#define GRPC_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H + +/* These annotations identify the beginning and end of regions where + the code may block for reasons other than synchronization functions. + These include poll, epoll, and getaddrinfo. */ + +#define GRPC_SCHEDULING_START_BLOCKING_REGION do {} while (0) +#define GRPC_SCHEDULING_END_BLOCKING_REGION do {} while (0) + +#endif /* GRPC_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H */ diff --git a/src/core/support/file.c b/src/core/support/file.c index 25a566905e..8c673dbcc6 100644 --- a/src/core/support/file.c +++ b/src/core/support/file.c @@ -40,7 +40,7 @@ #include #include -#include "src/core/iomgr/block_annotate.h" +#include "src/core/support/block_annotate.h" #include "src/core/support/string.h" gpr_slice gpr_load_file(const char *filename, int add_null_terminator, @@ -52,7 +52,7 @@ gpr_slice gpr_load_file(const char *filename, int add_null_terminator, FILE *file; size_t bytes_read = 0; - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; file = fopen(filename, "rb"); if (file == NULL) { gpr_asprintf(&error_msg, "Could not open file %s (error = %s).", filename, @@ -86,6 +86,6 @@ end: if (success != NULL) *success = 0; } if (file != NULL) fclose(file); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; return result; } diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c index 889b63a88a..eedfd0a060 100644 --- a/src/core/support/time_posix.c +++ b/src/core/support/time_posix.c @@ -41,7 +41,7 @@ #include #include #include -#include "src/core/iomgr/block_annotate.h" +#include "src/core/support/block_annotate.h" static struct timespec timespec_from_gpr(gpr_timespec gts) { struct timespec rv; @@ -139,9 +139,9 @@ void gpr_sleep_until(gpr_timespec until) { delta = gpr_time_sub(until, now); delta_ts = timespec_from_gpr(delta); - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; ns_result = nanosleep(&delta_ts, NULL); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; if (ns_result == 0) { break; } diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c index 710c7969ba..bc0586d069 100644 --- a/src/core/support/time_win32.c +++ b/src/core/support/time_win32.c @@ -41,7 +41,7 @@ #include #include -#include "src/core/iomgr/block_annotate.h" +#include "src/core/support/block_annotate.h" static LARGE_INTEGER g_start_time; static double g_time_scale; @@ -94,9 +94,9 @@ void gpr_sleep_until(gpr_timespec until) { delta = gpr_time_sub(until, now); sleep_millis = (DWORD)delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS; - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; Sleep(sleep_millis); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; } } diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index f38bee2bc0..88b125356d 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -815,7 +815,6 @@ src/core/httpcli/parser.h \ src/core/iomgr/alarm.h \ src/core/iomgr/alarm_heap.h \ src/core/iomgr/alarm_internal.h \ -src/core/iomgr/block_annotate.h \ src/core/iomgr/endpoint.h \ src/core/iomgr/endpoint_pair.h \ src/core/iomgr/fd_posix.h \ @@ -1059,6 +1058,7 @@ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ +src/core/support/block_annotate.h \ src/core/support/env.h \ src/core/support/file.h \ src/core/support/murmur_hash.h \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 28361adee9..97c7949ef2 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -12161,6 +12161,7 @@ "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", + "src/core/support/block_annotate.h", "src/core/support/env.h", "src/core/support/file.h", "src/core/support/murmur_hash.h", @@ -12201,6 +12202,7 @@ "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", "src/core/support/alloc.c", + "src/core/support/block_annotate.h", "src/core/support/cmdline.c", "src/core/support/cpu_iphone.c", "src/core/support/cpu_linux.c", @@ -12311,7 +12313,6 @@ "src/core/iomgr/alarm.h", "src/core/iomgr/alarm_heap.h", "src/core/iomgr/alarm_internal.h", - "src/core/iomgr/block_annotate.h", "src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint_pair.h", "src/core/iomgr/fd_posix.h", @@ -12483,7 +12484,6 @@ "src/core/iomgr/alarm_heap.c", "src/core/iomgr/alarm_heap.h", "src/core/iomgr/alarm_internal.h", - "src/core/iomgr/block_annotate.h", "src/core/iomgr/endpoint.c", "src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint_pair.h", @@ -12802,7 +12802,6 @@ "src/core/iomgr/alarm.h", "src/core/iomgr/alarm_heap.h", "src/core/iomgr/alarm_internal.h", - "src/core/iomgr/block_annotate.h", "src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint_pair.h", "src/core/iomgr/fd_posix.h", @@ -12959,7 +12958,6 @@ "src/core/iomgr/alarm_heap.c", "src/core/iomgr/alarm_heap.h", "src/core/iomgr/alarm_internal.h", - "src/core/iomgr/block_annotate.h", "src/core/iomgr/endpoint.c", "src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint_pair.h", diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj index a130f5961e..1ffa0a858e 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj @@ -151,6 +151,7 @@ + diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters index 98b9121392..be5bb5162d 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters @@ -197,6 +197,9 @@ + + src\core\support + src\core\support diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 007ad41999..a09e813a5a 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -277,7 +277,6 @@ - diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index a52db5178f..1538c33552 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -602,9 +602,6 @@ src\core\iomgr - - src\core\iomgr - src\core\iomgr diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 738a9ab627..1ef4aadf52 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -256,7 +256,6 @@ - diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 040b34344f..da199b05f1 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -500,9 +500,6 @@ src\core\iomgr - - src\core\iomgr - src\core\iomgr -- cgit v1.2.3