Remove endpoint/ directories.

Fold endpoint interface into iomgr, move secure_endpoint into security/.
This will make it easier for endpoint to rely on some iomgr defined types (like
pollset).
	Change on 2014/12/17 by ctiller <ctiller@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82338036
pull/1/merge
ctiller 10 years ago committed by Nicolas Noble
parent ab4f91458b
commit 2bbb6c4311
  1. 75
      Makefile
  2. 86
      build.json
  3. 2
      src/core/httpcli/httpcli.c
  4. 2
      src/core/iomgr/endpoint.c
  5. 0
      src/core/iomgr/endpoint.h
  6. 2
      src/core/iomgr/endpoint_pair.h
  7. 2
      src/core/iomgr/socket_utils_posix.c
  8. 2
      src/core/iomgr/tcp_client.h
  9. 2
      src/core/iomgr/tcp_posix.h
  10. 2
      src/core/iomgr/tcp_server.h
  11. 8
      src/core/security/secure_endpoint.c
  12. 2
      src/core/security/secure_endpoint.h
  13. 2
      src/core/security/secure_transport_setup.c
  14. 2
      src/core/security/secure_transport_setup.h
  15. 3
      src/core/security/security_context.c
  16. 2
      src/core/security/security_context.h
  17. 2
      src/core/surface/channel_create.c
  18. 2
      src/core/transport/chttp2_transport.h
  19. 177
      test/core/endpoint/tcp_client_test.c
  20. 2
      test/core/iomgr/endpoint_tests.c
  21. 2
      test/core/iomgr/endpoint_tests.h
  22. 2
      test/core/iomgr/tcp_posix_test.c
  23. 4
      test/core/security/secure_endpoint_test.c
  24. 10
      vsprojects/vs2013/gpr.vcxproj
  25. 16
      vsprojects/vs2013/grpc.vcxproj
  26. 26
      vsprojects/vs2013/grpc_test_util.vcxproj

@ -791,14 +791,14 @@ LIBGPR_SRC = \
src/core/support/cpu_posix.c \
src/core/support/histogram.c \
src/core/support/host_port.c \
src/core/support/log_android.c \
src/core/support/log.c \
src/core/support/log_posix.c \
src/core/support/log_linux.c \
src/core/support/log_android.c \
src/core/support/log_posix.c \
src/core/support/log_win32.c \
src/core/support/murmur_hash.c \
src/core/support/slice.c \
src/core/support/slice_buffer.c \
src/core/support/slice.c \
src/core/support/string.c \
src/core/support/string_posix.c \
src/core/support/string_win32.c \
@ -881,12 +881,11 @@ LIBGRPC_SRC = \
src/core/channel/noop_filter.c \
src/core/compression/algorithm.c \
src/core/compression/message_compress.c \
src/core/endpoint/endpoint.c \
src/core/endpoint/secure_endpoint.c \
src/core/httpcli/format_request.c \
src/core/httpcli/httpcli.c \
src/core/httpcli/httpcli_security_context.c \
src/core/httpcli/parser.c \
src/core/iomgr/endpoint.c \
src/core/iomgr/endpoint_pair_posix.c \
src/core/iomgr/iomgr_libevent.c \
src/core/iomgr/iomgr_libevent_use_threads.c \
@ -904,14 +903,15 @@ LIBGRPC_SRC = \
src/core/security/credentials.c \
src/core/security/google_root_certs.c \
src/core/security/json_token.c \
src/core/security/secure_endpoint.c \
src/core/security/secure_transport_setup.c \
src/core/security/security_context.c \
src/core/security/server_secure_chttp2.c \
src/core/statistics/census_init.c \
src/core/statistics/census_log.c \
src/core/statistics/census_rpc_stats.c \
src/core/statistics/census_tracing.c \
src/core/statistics/hash_table.c \
src/core/statistics/census_log.c \
src/core/statistics/window_stats.c \
src/core/surface/byte_buffer.c \
src/core/surface/byte_buffer_reader.c \
@ -1004,19 +1004,19 @@ clean_libgrpc:
LIBGRPC_TEST_UTIL_SRC = \
test/core/end2end/cq_verifier.c \
test/core/end2end/data/ca_cert.c \
test/core/end2end/data/server1_cert.c \
test/core/end2end/data/server1_key.c \
test/core/iomgr/endpoint_tests.c \
test/core/statistics/census_log_tests.c \
test/core/transport/transport_end2end_tests.c \
test/core/util/grpc_profiler.c \
test/core/util/ipv6_posix.c \
test/core/util/parse_hexstring.c \
test/core/util/port_posix.c \
test/core/util/slice_splitter.c \
test/core/util/test_config.c \
test/core/end2end/data/server1_cert.c \
test/core/end2end/data/server1_key.c \
test/core/end2end/data/ca_cert.c \
test/core/end2end/cq_verifier.c \
test/core/endpoint/endpoint_tests.c \
test/core/transport/transport_end2end_tests.c \
test/core/statistics/census_log_tests.c \
LIBGRPC_TEST_UTIL_OBJS = $(addprefix objs/, $(addsuffix .o, $(basename $(LIBGRPC_TEST_UTIL_SRC))))
@ -1054,37 +1054,37 @@ clean_libgrpc_test_util:
LIBGRPC++_SRC = \
src/cpp/server/server.cc \
src/cpp/server/server_rpc_handler.cc \
src/cpp/server/thread_pool.cc \
src/cpp/server/async_server_context.cc \
src/cpp/server/async_server.cc \
src/cpp/server/completion_queue.cc \
src/cpp/server/server_builder.cc \
src/cpp/stream/stream_context.cc \
src/cpp/client/create_channel.cc \
src/cpp/client/channel.cc \
src/cpp/client/client_context.cc \
src/cpp/client/create_channel.cc \
src/cpp/client/internal_stub.cc \
src/cpp/util/time.cc \
src/cpp/util/status.cc \
src/cpp/proto/proto_utils.cc \
src/cpp/rpc_method.cc \
src/cpp/server/async_server.cc \
src/cpp/server/async_server_context.cc \
src/cpp/server/completion_queue.cc \
src/cpp/server/server_builder.cc \
src/cpp/server/server.cc \
src/cpp/server/server_rpc_handler.cc \
src/cpp/server/thread_pool.cc \
src/cpp/stream/stream_context.cc \
src/cpp/util/status.cc \
src/cpp/util/time.cc \
PUBLIC_HEADERS_CXX += \
include/grpc++/channel_interface.h \
include/grpc++/async_server_context.h \
include/grpc++/async_server.h \
include/grpc++/channel_interface.h \
include/grpc++/client_context.h \
include/grpc++/completion_queue.h \
include/grpc++/config.h \
include/grpc++/create_channel.h \
include/grpc++/server_builder.h \
include/grpc++/thread_pool_interface.h \
include/grpc++/stream_context_interface.h \
include/grpc++/server.h \
include/grpc++/status.h \
include/grpc++/config.h \
include/grpc++/completion_queue.h \
include/grpc++/stream_context_interface.h \
include/grpc++/stream.h \
include/grpc++/async_server_context.h \
include/grpc++/server.h \
include/grpc++/client_context.h \
include/grpc++/thread_pool_interface.h \
LIBGRPC++_OBJS = $(addprefix objs/, $(addsuffix .o, $(basename $(LIBGRPC++_SRC))))
LIBGRPC++_DEPS = $(addprefix deps/, $(addsuffix .dep, $(basename $(LIBGRPC++_SRC))))
@ -1124,9 +1124,9 @@ clean_libgrpc++:
LIBGRPC++_TEST_UTIL_SRC = \
test/cpp/util/test_ssl_channel.cc \
gens/test/cpp/util/echo.pb.cc \
test/cpp/end2end/async_test_server.cc \
gens/test/cpp/util/echo.pb.cc \
test/cpp/util/test_ssl_channel.cc \
LIBGRPC++_TEST_UTIL_OBJS = $(addprefix objs/, $(addsuffix .o, $(basename $(LIBGRPC++_TEST_UTIL_SRC))))
@ -2007,12 +2007,11 @@ LIBGRPC_UNSECURE_SRC = \
src/core/channel/noop_filter.c \
src/core/compression/algorithm.c \
src/core/compression/message_compress.c \
src/core/endpoint/endpoint.c \
src/core/endpoint/secure_endpoint.c \
src/core/httpcli/format_request.c \
src/core/httpcli/httpcli.c \
src/core/httpcli/httpcli_security_context.c \
src/core/httpcli/parser.c \
src/core/iomgr/endpoint.c \
src/core/iomgr/endpoint_pair_posix.c \
src/core/iomgr/iomgr_libevent.c \
src/core/iomgr/iomgr_libevent_use_threads.c \
@ -2026,10 +2025,10 @@ LIBGRPC_UNSECURE_SRC = \
src/core/iomgr/tcp_server_posix.c \
src/core/iomgr/time_averaged_stats.c \
src/core/statistics/census_init.c \
src/core/statistics/census_log.c \
src/core/statistics/census_rpc_stats.c \
src/core/statistics/census_tracing.c \
src/core/statistics/hash_table.c \
src/core/statistics/census_log.c \
src/core/statistics/window_stats.c \
src/core/surface/byte_buffer.c \
src/core/surface/byte_buffer_reader.c \
@ -3959,7 +3958,7 @@ clean_bin_encoder_test:
SECURE_ENDPOINT_TEST_SRC = \
test/core/endpoint/secure_endpoint_test.c \
test/core/security/secure_endpoint_test.c \
SECURE_ENDPOINT_TEST_OBJS = $(addprefix objs/, $(addsuffix .o, $(basename $(SECURE_ENDPOINT_TEST_SRC))))
SECURE_ENDPOINT_TEST_DEPS = $(addprefix deps/, $(addsuffix .dep, $(basename $(SECURE_ENDPOINT_TEST_SRC))))

@ -21,14 +21,14 @@
"src/core/support/cpu_posix.c",
"src/core/support/histogram.c",
"src/core/support/host_port.c",
"src/core/support/log_android.c",
"src/core/support/log.c",
"src/core/support/log_posix.c",
"src/core/support/log_linux.c",
"src/core/support/log_android.c",
"src/core/support/log_posix.c",
"src/core/support/log_win32.c",
"src/core/support/murmur_hash.c",
"src/core/support/slice.c",
"src/core/support/slice_buffer.c",
"src/core/support/slice.c",
"src/core/support/string.c",
"src/core/support/string_posix.c",
"src/core/support/string_win32.c",
@ -111,12 +111,11 @@
"src/core/channel/noop_filter.c",
"src/core/compression/algorithm.c",
"src/core/compression/message_compress.c",
"src/core/endpoint/endpoint.c",
"src/core/endpoint/secure_endpoint.c",
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/httpcli_security_context.c",
"src/core/httpcli/parser.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
"src/core/iomgr/iomgr_libevent.c",
"src/core/iomgr/iomgr_libevent_use_threads.c",
@ -134,14 +133,15 @@
"src/core/security/credentials.c",
"src/core/security/google_root_certs.c",
"src/core/security/json_token.c",
"src/core/security/secure_endpoint.c",
"src/core/security/secure_transport_setup.c",
"src/core/security/security_context.c",
"src/core/security/server_secure_chttp2.c",
"src/core/statistics/census_init.c",
"src/core/statistics/census_log.c",
"src/core/statistics/census_rpc_stats.c",
"src/core/statistics/census_tracing.c",
"src/core/statistics/hash_table.c",
"src/core/statistics/census_log.c",
"src/core/statistics/window_stats.c",
"src/core/surface/byte_buffer.c",
"src/core/surface/byte_buffer_reader.c",
@ -205,12 +205,12 @@
"src/core/channel/noop_filter.h",
"src/core/compression/algorithm.h",
"src/core/compression/message_compress.h",
"src/core/endpoint/endpoint.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/httpcli_security_context.h",
"src/core/httpcli/parser.h",
"src/core/iomgr/alarm.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
"src/core/iomgr/iomgr_completion_queue_interface.h",
"src/core/iomgr/iomgr.h",
@ -233,9 +233,9 @@
"src/core/security/secure_transport_setup.h",
"src/core/security/security_context.h",
"src/core/statistics/census_interface.h",
"src/core/statistics/census_log.h",
"src/core/statistics/census_rpc_stats.h",
"src/core/statistics/hash_table.h",
"src/core/statistics/census_log.h",
"src/core/statistics/window_stats.h",
"src/core/surface/call.h",
"src/core/surface/channel.h",
@ -279,19 +279,19 @@
"build": "private",
"vs_project_guid": "{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}",
"src": [
"test/core/end2end/cq_verifier.c",
"test/core/end2end/data/ca_cert.c",
"test/core/end2end/data/server1_cert.c",
"test/core/end2end/data/server1_key.c",
"test/core/iomgr/endpoint_tests.c",
"test/core/statistics/census_log_tests.c",
"test/core/transport/transport_end2end_tests.c",
"test/core/util/grpc_profiler.c",
"test/core/util/ipv6_posix.c",
"test/core/util/parse_hexstring.c",
"test/core/util/port_posix.c",
"test/core/util/slice_splitter.c",
"test/core/util/test_config.c",
"test/core/end2end/data/server1_cert.c",
"test/core/end2end/data/server1_key.c",
"test/core/end2end/data/ca_cert.c",
"test/core/end2end/cq_verifier.c",
"test/core/endpoint/endpoint_tests.c",
"test/core/transport/transport_end2end_tests.c",
"test/core/statistics/census_log_tests.c"
"test/core/util/test_config.c"
]
},
{
@ -301,57 +301,57 @@
"secure": true,
"vs_project_guid": "{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}",
"src": [
"src/cpp/server/server.cc",
"src/cpp/server/server_rpc_handler.cc",
"src/cpp/server/thread_pool.cc",
"src/cpp/server/async_server_context.cc",
"src/cpp/client/channel.cc",
"src/cpp/client/client_context.cc",
"src/cpp/client/create_channel.cc",
"src/cpp/client/internal_stub.cc",
"src/cpp/proto/proto_utils.cc",
"src/cpp/rpc_method.cc",
"src/cpp/server/async_server.cc",
"src/cpp/server/async_server_context.cc",
"src/cpp/server/completion_queue.cc",
"src/cpp/server/server_builder.cc",
"src/cpp/server/server.cc",
"src/cpp/server/server_rpc_handler.cc",
"src/cpp/server/thread_pool.cc",
"src/cpp/stream/stream_context.cc",
"src/cpp/client/create_channel.cc",
"src/cpp/client/channel.cc",
"src/cpp/client/client_context.cc",
"src/cpp/client/internal_stub.cc",
"src/cpp/util/time.cc",
"src/cpp/util/status.cc",
"src/cpp/proto/proto_utils.cc",
"src/cpp/rpc_method.cc"
"src/cpp/util/time.cc"
],
"public_headers": [
"include/grpc++/channel_interface.h",
"include/grpc++/async_server_context.h",
"include/grpc++/async_server.h",
"include/grpc++/channel_interface.h",
"include/grpc++/client_context.h",
"include/grpc++/completion_queue.h",
"include/grpc++/config.h",
"include/grpc++/create_channel.h",
"include/grpc++/server_builder.h",
"include/grpc++/thread_pool_interface.h",
"include/grpc++/stream_context_interface.h",
"include/grpc++/server.h",
"include/grpc++/status.h",
"include/grpc++/config.h",
"include/grpc++/completion_queue.h",
"include/grpc++/stream_context_interface.h",
"include/grpc++/stream.h",
"include/grpc++/async_server_context.h",
"include/grpc++/server.h",
"include/grpc++/client_context.h"
"include/grpc++/thread_pool_interface.h"
],
"headers": [
"src/cpp/client/channel.h",
"src/cpp/client/internal_stub.h",
"src/cpp/proto/proto_utils.h",
"src/cpp/rpc_method.h",
"src/cpp/server/rpc_service_method.h",
"src/cpp/server/server_rpc_handler.h",
"src/cpp/server/thread_pool.h",
"src/cpp/stream/stream_context.h",
"src/cpp/client/channel.h",
"src/cpp/client/internal_stub.h",
"src/cpp/util/time.h",
"src/cpp/rpc_method.h",
"src/cpp/proto/proto_utils.h"
"src/cpp/util/time.h"
]
},
{
"name": "grpc++_test_util",
"build": "test",
"src": [
"test/cpp/util/test_ssl_channel.cc",
"test/cpp/end2end/async_test_server.cc",
"test/cpp/util/echo.proto",
"test/cpp/end2end/async_test_server.cc"
"test/cpp/util/test_ssl_channel.cc"
],
"c++": true
}
@ -1023,7 +1023,7 @@
"name": "secure_endpoint_test",
"build": "test",
"src": [
"test/core/endpoint/secure_endpoint_test.c"
"test/core/security/secure_endpoint_test.c"
],
"deps": [
"grpc_test_util",

@ -35,7 +35,7 @@
#include <string.h>
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/tcp_client.h"
#include "src/core/httpcli/format_request.h"

@ -31,7 +31,7 @@
*
*/
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
void grpc_endpoint_notify_on_read(grpc_endpoint *ep, grpc_endpoint_read_cb cb,
void *user_data, gpr_timespec deadline) {

@ -34,7 +34,7 @@
#ifndef __GRPC_INTERNAL_IOMGR_ENDPOINT_PAIR_H_
#define __GRPC_INTERNAL_IOMGR_ENDPOINT_PAIR_H_
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
typedef struct {
grpc_endpoint *client;

@ -36,7 +36,7 @@
#ifdef GPR_POSIX_SOCKETUTILS
#define _BSD_SOURCE
#include "src/core/endpoint/socket_utils.h"
#include "src/core/iomgr/socket_utils_posix.h"
#include <fcntl.h>
#include <sys/socket.h>

@ -34,7 +34,7 @@
#ifndef __GRPC_INTERNAL_IOMGR_TCP_CLIENT_H__
#define __GRPC_INTERNAL_IOMGR_TCP_CLIENT_H__
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/sockaddr.h"
#include <grpc/support/time.h>

@ -44,7 +44,7 @@
otherwise specified.
*/
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/iomgr_libevent.h"
#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192

@ -37,7 +37,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
/* Forward decl of grpc_tcp_server */
typedef struct grpc_tcp_server grpc_tcp_server;

@ -31,14 +31,14 @@
*
*/
#include "src/core/endpoint/secure_endpoint.h"
#include "src/core/tsi/transport_security_interface.h"
#include "src/core/security/secure_endpoint.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/slice.h>
#include <grpc/support/slice_buffer.h>
#include <grpc/support/slice.h>
#include <grpc/support/string.h>
#include <grpc/support/sync.h>
#include "src/core/tsi/transport_security_interface.h"
#define STAGING_BUFFER_SIZE 8192
@ -67,7 +67,7 @@ typedef struct {
static void secure_endpoint_ref(secure_endpoint *ep) { gpr_ref(&ep->ref); }
static void destroy(secure_endpoint *secure_ep) {
secure_endpoint *ep = (secure_endpoint *)secure_ep;
secure_endpoint *ep = secure_ep;
grpc_endpoint_destroy(ep->wrapped_ep);
tsi_frame_protector_destroy(ep->protector);
gpr_slice_buffer_destroy(&ep->leftover_bytes);

@ -34,8 +34,8 @@
#ifndef __GRPC_INTERNAL_ENDPOINT_SECURE_ENDPOINT_H__
#define __GRPC_INTERNAL_ENDPOINT_SECURE_ENDPOINT_H__
#include "src/core/iomgr/endpoint.h"
#include <grpc/support/slice.h>
#include "src/core/endpoint/endpoint.h"
struct tsi_frame_protector;

@ -35,7 +35,7 @@
#include <string.h>
#include "src/core/endpoint/secure_endpoint.h"
#include "src/core/security/secure_endpoint.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h>

@ -34,7 +34,7 @@
#ifndef __GRPC_INTERNAL_SECURITY_SECURE_TRANSPORT_SETUP_H__
#define __GRPC_INTERNAL_SECURITY_SECURE_TRANSPORT_SETUP_H__
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/security/security_context.h"
/* --- Secure transport setup --- */

@ -35,15 +35,14 @@
#include <string.h>
#include "src/core/endpoint/secure_endpoint.h"
#include "src/core/security/credentials.h"
#include "src/core/security/secure_endpoint.h"
#include "src/core/surface/lame_client.h"
#include "src/core/transport/chttp2/alpn.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h>
#include <grpc/support/string.h>
#include "src/core/tsi/fake_transport_security.h"
#include "src/core/tsi/ssl_transport_security.h"

@ -35,7 +35,7 @@
#define __GRPC_INTERNAL_SECURITY_SECURITY_CONTEXT_H__
#include <grpc/grpc_security.h>
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/security/credentials.h"
#include "src/core/tsi/transport_security_interface.h"

@ -43,7 +43,7 @@
#include "src/core/channel/connected_channel.h"
#include "src/core/channel/http_client_filter.h"
#include "src/core/channel/http_filter.h"
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/tcp_client.h"
#include "src/core/surface/channel.h"

@ -34,7 +34,7 @@
#ifndef __GRPC_INTERNAL_TRANSPORT_CHTTP2_TRANSPORT_H__
#define __GRPC_INTERNAL_TRANSPORT_CHTTP2_TRANSPORT_H__
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/transport/transport.h"
void grpc_create_chttp2_transport(grpc_transport_setup_callback setup,

@ -1,177 +0,0 @@
/*
*
* Copyright 2014, 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/endpoint/tcp_client.h"
#include <errno.h>
#include <netinet/in.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include "src/core/eventmanager/em.h"
#include <grpc/support/log.h>
#include <grpc/support/time.h>
static grpc_em em;
static gpr_timespec test_deadline() {
return gpr_time_add(gpr_now(), gpr_time_from_micros(1000000));
}
static void must_succeed(void *arg, grpc_endpoint *tcp) {
GPR_ASSERT(tcp);
grpc_endpoint_shutdown(tcp);
grpc_endpoint_destroy(tcp);
gpr_event_set(arg, (void *)1);
}
static void must_fail(void *arg, grpc_endpoint *tcp) {
GPR_ASSERT(!tcp);
gpr_event_set(arg, (void *)1);
}
void test_succeeds() {
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
int svr_fd;
int r;
gpr_event ev;
gpr_event_init(&ev);
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
/* create a dummy server */
svr_fd = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(svr_fd >= 0);
GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr *)&addr, addr_len));
GPR_ASSERT(0 == listen(svr_fd, 1));
/* connect to it */
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)&addr, &addr_len) == 0);
grpc_tcp_client_connect(must_succeed, &ev, &em, (struct sockaddr *)&addr,
addr_len, gpr_inf_future);
/* await the connection */
do {
addr_len = sizeof(addr);
r = accept(svr_fd, (struct sockaddr *)&addr, &addr_len);
} while (r == -1 && errno == EINTR);
GPR_ASSERT(r >= 0);
close(r);
/* wait for the connection callback to finish */
GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
}
void test_fails() {
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
gpr_event ev;
gpr_event_init(&ev);
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
/* connect to a broken address */
grpc_tcp_client_connect(must_fail, &ev, &em, (struct sockaddr *)&addr,
addr_len, gpr_inf_future);
/* wait for the connection callback to finish */
GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
}
void test_times_out() {
struct sockaddr_in addr;
socklen_t addr_len = sizeof(addr);
int svr_fd;
#define NUM_CLIENT_CONNECTS 10
int client_fd[NUM_CLIENT_CONNECTS];
int i;
int r;
gpr_event ev;
gpr_timespec connect_deadline;
gpr_event_init(&ev);
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
/* create a dummy server */
svr_fd = socket(AF_INET, SOCK_STREAM, 0);
GPR_ASSERT(svr_fd >= 0);
GPR_ASSERT(0 == bind(svr_fd, (struct sockaddr *)&addr, addr_len));
GPR_ASSERT(0 == listen(svr_fd, 1));
/* Get its address */
GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)&addr, &addr_len) == 0);
/* tie up the listen buffer, which is somewhat arbitrarily sized. */
for (i = 0; i < NUM_CLIENT_CONNECTS; ++i) {
client_fd[i] = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
do {
r = connect(client_fd[i], (struct sockaddr *)&addr, addr_len);
} while (r == -1 && errno == EINTR);
GPR_ASSERT(r < 0);
GPR_ASSERT(errno == EWOULDBLOCK || errno == EINPROGRESS);
}
/* connect to dummy server address */
connect_deadline = gpr_time_add(gpr_now(), gpr_time_from_micros(1000000));
grpc_tcp_client_connect(must_fail, &ev, &em, (struct sockaddr *)&addr,
addr_len, connect_deadline);
/* Make sure the event doesn't trigger early */
GPR_ASSERT(!gpr_event_wait(
&ev, gpr_time_add(gpr_now(), gpr_time_from_micros(500000))));
/* Now wait until it should have triggered */
sleep(1);
/* wait for the connection callback to finish */
GPR_ASSERT(gpr_event_wait(&ev, test_deadline()));
close(svr_fd);
for (i = 0; i < NUM_CLIENT_CONNECTS; ++i) {
close(client_fd[i]);
}
}
int main(void) {
grpc_em_init(&em);
test_succeeds();
test_fails();
test_times_out();
return 0;
}

@ -31,7 +31,7 @@
*
*/
#include "test/core/endpoint/endpoint_tests.h"
#include "test/core/iomgr/endpoint_tests.h"
#include <sys/types.h>

@ -36,7 +36,7 @@
#include <sys/types.h>
#include "src/core/endpoint/endpoint.h"
#include "src/core/iomgr/endpoint.h"
typedef struct grpc_endpoint_test_config grpc_endpoint_test_config;
typedef struct grpc_endpoint_test_fixture grpc_endpoint_test_fixture;

@ -46,7 +46,7 @@
#include <grpc/support/time.h>
#include <grpc/support/useful.h>
#include "test/core/util/test_config.h"
#include "test/core/endpoint/endpoint_tests.h"
#include "test/core/iomgr/endpoint_tests.h"
/*
General test notes:

@ -31,14 +31,14 @@
*
*/
#include "endpoint_tests.h"
#include "test/core/iomgr/endpoint_tests.h"
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include "src/core/endpoint/secure_endpoint.h"
#include "src/core/security/secure_endpoint.h"
#include "src/core/iomgr/endpoint_pair.h"
#include "src/core/iomgr/iomgr.h"
#include <grpc/support/alloc.h>

@ -117,22 +117,22 @@
</ClCompile>
<ClCompile Include="..\..\src\core\support\host_port.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\log.c">
<ClCompile Include="..\..\src\core\support\log_android.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\log_posix.c">
<ClCompile Include="..\..\src\core\support\log.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\log_linux.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\log_android.c">
<ClCompile Include="..\..\src\core\support\log_posix.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\log_win32.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\murmur_hash.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\slice.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\slice_buffer.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\slice.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\string.c">
</ClCompile>
<ClCompile Include="..\..\src\core\support\string_posix.c">

@ -94,12 +94,12 @@
<ClInclude Include="..\..\src\core\channel\noop_filter.h" />
<ClInclude Include="..\..\src\core\compression\algorithm.h" />
<ClInclude Include="..\..\src\core\compression\message_compress.h" />
<ClInclude Include="..\..\src\core\endpoint\endpoint.h" />
<ClInclude Include="..\..\src\core\httpcli\format_request.h" />
<ClInclude Include="..\..\src\core\httpcli\httpcli.h" />
<ClInclude Include="..\..\src\core\httpcli\httpcli_security_context.h" />
<ClInclude Include="..\..\src\core\httpcli\parser.h" />
<ClInclude Include="..\..\src\core\iomgr\alarm.h" />
<ClInclude Include="..\..\src\core\iomgr\endpoint.h" />
<ClInclude Include="..\..\src\core\iomgr\endpoint_pair.h" />
<ClInclude Include="..\..\src\core\iomgr\iomgr_completion_queue_interface.h" />
<ClInclude Include="..\..\src\core\iomgr\iomgr.h" />
@ -122,9 +122,9 @@
<ClInclude Include="..\..\src\core\security\secure_transport_setup.h" />
<ClInclude Include="..\..\src\core\security\security_context.h" />
<ClInclude Include="..\..\src\core\statistics\census_interface.h" />
<ClInclude Include="..\..\src\core\statistics\census_log.h" />
<ClInclude Include="..\..\src\core\statistics\census_rpc_stats.h" />
<ClInclude Include="..\..\src\core\statistics\hash_table.h" />
<ClInclude Include="..\..\src\core\statistics\census_log.h" />
<ClInclude Include="..\..\src\core\statistics\window_stats.h" />
<ClInclude Include="..\..\src\core\surface\call.h" />
<ClInclude Include="..\..\src\core\surface\channel.h" />
@ -193,10 +193,6 @@
</ClCompile>
<ClCompile Include="..\..\src\core\compression\message_compress.c">
</ClCompile>
<ClCompile Include="..\..\src\core\endpoint\endpoint.c">
</ClCompile>
<ClCompile Include="..\..\src\core\endpoint\secure_endpoint.c">
</ClCompile>
<ClCompile Include="..\..\src\core\httpcli\format_request.c">
</ClCompile>
<ClCompile Include="..\..\src\core\httpcli\httpcli.c">
@ -205,6 +201,8 @@
</ClCompile>
<ClCompile Include="..\..\src\core\httpcli\parser.c">
</ClCompile>
<ClCompile Include="..\..\src\core\iomgr\endpoint.c">
</ClCompile>
<ClCompile Include="..\..\src\core\iomgr\endpoint_pair_posix.c">
</ClCompile>
<ClCompile Include="..\..\src\core\iomgr\iomgr_libevent.c">
@ -239,6 +237,8 @@
</ClCompile>
<ClCompile Include="..\..\src\core\security\json_token.c">
</ClCompile>
<ClCompile Include="..\..\src\core\security\secure_endpoint.c">
</ClCompile>
<ClCompile Include="..\..\src\core\security\secure_transport_setup.c">
</ClCompile>
<ClCompile Include="..\..\src\core\security\security_context.c">
@ -247,14 +247,14 @@
</ClCompile>
<ClCompile Include="..\..\src\core\statistics\census_init.c">
</ClCompile>
<ClCompile Include="..\..\src\core\statistics\census_log.c">
</ClCompile>
<ClCompile Include="..\..\src\core\statistics\census_rpc_stats.c">
</ClCompile>
<ClCompile Include="..\..\src\core\statistics\census_tracing.c">
</ClCompile>
<ClCompile Include="..\..\src\core\statistics\hash_table.c">
</ClCompile>
<ClCompile Include="..\..\src\core\statistics\census_log.c">
</ClCompile>
<ClCompile Include="..\..\src\core\statistics\window_stats.c">
</ClCompile>
<ClCompile Include="..\..\src\core\surface\byte_buffer.c">

@ -73,31 +73,31 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\test\core\util\grpc_profiler.c">
<ClCompile Include="..\..\test\core\end2end\cq_verifier.c">
</ClCompile>
<ClCompile Include="..\..\test\core\util\ipv6_posix.c">
<ClCompile Include="..\..\test\core\end2end\data\ca_cert.c">
</ClCompile>
<ClCompile Include="..\..\test\core\util\parse_hexstring.c">
<ClCompile Include="..\..\test\core\end2end\data\server1_cert.c">
</ClCompile>
<ClCompile Include="..\..\test\core\util\port_posix.c">
<ClCompile Include="..\..\test\core\end2end\data\server1_key.c">
</ClCompile>
<ClCompile Include="..\..\test\core\util\slice_splitter.c">
<ClCompile Include="..\..\test\core\iomgr\endpoint_tests.c">
</ClCompile>
<ClCompile Include="..\..\test\core\util\test_config.c">
<ClCompile Include="..\..\test\core\statistics\census_log_tests.c">
</ClCompile>
<ClCompile Include="..\..\test\core\end2end\data\server1_cert.c">
<ClCompile Include="..\..\test\core\transport\transport_end2end_tests.c">
</ClCompile>
<ClCompile Include="..\..\test\core\end2end\data\server1_key.c">
<ClCompile Include="..\..\test\core\util\grpc_profiler.c">
</ClCompile>
<ClCompile Include="..\..\test\core\end2end\data\ca_cert.c">
<ClCompile Include="..\..\test\core\util\ipv6_posix.c">
</ClCompile>
<ClCompile Include="..\..\test\core\end2end\cq_verifier.c">
<ClCompile Include="..\..\test\core\util\parse_hexstring.c">
</ClCompile>
<ClCompile Include="..\..\test\core\endpoint\endpoint_tests.c">
<ClCompile Include="..\..\test\core\util\port_posix.c">
</ClCompile>
<ClCompile Include="..\..\test\core\transport\transport_end2end_tests.c">
<ClCompile Include="..\..\test\core\util\slice_splitter.c">
</ClCompile>
<ClCompile Include="..\..\test\core\statistics\census_log_tests.c">
<ClCompile Include="..\..\test\core\util\test_config.c">
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

Loading…
Cancel
Save