Skip to content

Commit

Permalink
Move block_annotate from iomgr to support since it's used in other
Browse files Browse the repository at this point in the history
core places besides iomgr
  • Loading branch information
vjpai committed Sep 25, 2015
1 parent 50d6534 commit 9839d28
Show file tree
Hide file tree
Showing 20 changed files with 74 additions and 81 deletions.
5 changes: 2 additions & 3 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
56 changes: 28 additions & 28 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions gRPC.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions src/core/iomgr/pollset_multipoller_with_epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#include <sys/epoll.h>
#include <unistd.h>

#include "src/core/iomgr/block_annotate.h"
#include "src/core/iomgr/fd_posix.h"
#include "src/core/support/block_annotate.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>

Expand Down Expand Up @@ -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) {
Expand All @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions src/core/iomgr/pollset_multipoller_with_poll_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
#include <stdlib.h>
#include <string.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/support/block_annotate.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/core/iomgr/pollset_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
#include <unistd.h>

#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 <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions src/core/iomgr/resolve_address_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
#include <sys/un.h>
#include <string.h>

#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 <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
Expand Down Expand Up @@ -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;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/iomgr/resolve_address_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
#include <sys/types.h>
#include <string.h>

#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 <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
*
*/

#ifndef GRPC_INTERNAL_CORE_IOMGR_BLOCK_ANNOTATE_H
#define GRPC_INTERNAL_CORE_IOMGR_BLOCK_ANNOTATE_H
#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_IOMGR_START_BLOCKING_REGION do {} while (0)
#define GRPC_IOMGR_END_BLOCKING_REGION do {} while (0)
#define GRPC_SCHEDULING_START_BLOCKING_REGION do {} while (0)
#define GRPC_SCHEDULING_END_BLOCKING_REGION do {} while (0)

#endif /* GRPC_INTERNAL_CORE_IOMGR_BLOCK_ANNOTATE_H */
#endif /* GRPC_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H */
6 changes: 3 additions & 3 deletions src/core/support/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>

#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,
Expand All @@ -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,
Expand Down Expand Up @@ -86,6 +86,6 @@ gpr_slice gpr_load_file(const char *filename, int add_null_terminator,
if (success != NULL) *success = 0;
}
if (file != NULL) fclose(file);
GRPC_IOMGR_END_BLOCKING_REGION;
GRPC_SCHEDULING_END_BLOCKING_REGION;
return result;
}
6 changes: 3 additions & 3 deletions src/core/support/time_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <unistd.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#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;
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/support/time_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <src/core/support/time_precise.h>
#include <sys/timeb.h>

#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;
Expand Down Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/doxygen/Doxyfile.core.internal
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
Loading

0 comments on commit 9839d28

Please sign in to comment.