Introduce grpc_socket_mutator

pull/8335/head
Yuchen Zeng 8 years ago
parent b5273fdb73
commit a4f708a4c4
  1. 4
      BUILD
  2. 3
      CMakeLists.txt
  3. 40
      Makefile
  4. 1
      binding.gyp
  5. 15
      build.yaml
  6. 1
      config.m4
  7. 1
      gRPC-Core.podspec
  8. 1
      grpc.gemspec
  9. 14
      include/grpc/impl/codegen/grpc_types.h
  10. 1
      package.xml
  11. 9
      src/core/lib/iomgr/socket_utils_common_posix.c
  12. 4
      src/core/lib/iomgr/socket_utils_posix.h
  13. 68
      src/core/lib/iomgr/socket_utils_tos_posix.c
  14. 7
      src/core/lib/iomgr/tcp_client_posix.c
  15. 1
      src/python/grpcio/grpc_core_dependencies.py
  16. 48
      test/core/iomgr/socket_utils_test.c
  17. 67
      test/core/iomgr/socket_utils_tos_test.c
  18. 1
      tools/doxygen/Doxyfile.core.internal
  19. 18
      tools/run_tests/sources_and_headers.json
  20. 19
      tools/run_tests/tests.json
  21. 2
      vsprojects/vcxproj/grpc/grpc.vcxproj
  22. 3
      vsprojects/vcxproj/grpc/grpc.vcxproj.filters
  23. 2
      vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj
  24. 3
      vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters
  25. 2
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
  26. 3
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters

@ -366,7 +366,6 @@ cc_library(
"src/core/lib/iomgr/socket_utils_common_posix.c",
"src/core/lib/iomgr/socket_utils_linux.c",
"src/core/lib/iomgr/socket_utils_posix.c",
"src/core/lib/iomgr/socket_utils_tos_posix.c",
"src/core/lib/iomgr/socket_windows.c",
"src/core/lib/iomgr/tcp_client_posix.c",
"src/core/lib/iomgr/tcp_client_windows.c",
@ -753,7 +752,6 @@ cc_library(
"src/core/lib/iomgr/socket_utils_common_posix.c",
"src/core/lib/iomgr/socket_utils_linux.c",
"src/core/lib/iomgr/socket_utils_posix.c",
"src/core/lib/iomgr/socket_utils_tos_posix.c",
"src/core/lib/iomgr/socket_windows.c",
"src/core/lib/iomgr/tcp_client_posix.c",
"src/core/lib/iomgr/tcp_client_windows.c",
@ -1102,7 +1100,6 @@ cc_library(
"src/core/lib/iomgr/socket_utils_common_posix.c",
"src/core/lib/iomgr/socket_utils_linux.c",
"src/core/lib/iomgr/socket_utils_posix.c",
"src/core/lib/iomgr/socket_utils_tos_posix.c",
"src/core/lib/iomgr/socket_windows.c",
"src/core/lib/iomgr/tcp_client_posix.c",
"src/core/lib/iomgr/tcp_client_windows.c",
@ -1866,7 +1863,6 @@ objc_library(
"src/core/lib/iomgr/socket_utils_common_posix.c",
"src/core/lib/iomgr/socket_utils_linux.c",
"src/core/lib/iomgr/socket_utils_posix.c",
"src/core/lib/iomgr/socket_utils_tos_posix.c",
"src/core/lib/iomgr/socket_windows.c",
"src/core/lib/iomgr/tcp_client_posix.c",
"src/core/lib/iomgr/tcp_client_windows.c",

@ -333,7 +333,6 @@ add_library(grpc
src/core/lib/iomgr/socket_utils_common_posix.c
src/core/lib/iomgr/socket_utils_linux.c
src/core/lib/iomgr/socket_utils_posix.c
src/core/lib/iomgr/socket_utils_tos_posix.c
src/core/lib/iomgr/socket_windows.c
src/core/lib/iomgr/tcp_client_posix.c
src/core/lib/iomgr/tcp_client_windows.c
@ -593,7 +592,6 @@ add_library(grpc_cronet
src/core/lib/iomgr/socket_utils_common_posix.c
src/core/lib/iomgr/socket_utils_linux.c
src/core/lib/iomgr/socket_utils_posix.c
src/core/lib/iomgr/socket_utils_tos_posix.c
src/core/lib/iomgr/socket_windows.c
src/core/lib/iomgr/tcp_client_posix.c
src/core/lib/iomgr/tcp_client_windows.c
@ -825,7 +823,6 @@ add_library(grpc_unsecure
src/core/lib/iomgr/socket_utils_common_posix.c
src/core/lib/iomgr/socket_utils_linux.c
src/core/lib/iomgr/socket_utils_posix.c
src/core/lib/iomgr/socket_utils_tos_posix.c
src/core/lib/iomgr/socket_windows.c
src/core/lib/iomgr/tcp_client_posix.c
src/core/lib/iomgr/tcp_client_windows.c

@ -1012,7 +1012,6 @@ set_initial_connect_string_test: $(BINDIR)/$(CONFIG)/set_initial_connect_string_
sockaddr_resolver_test: $(BINDIR)/$(CONFIG)/sockaddr_resolver_test
sockaddr_utils_test: $(BINDIR)/$(CONFIG)/sockaddr_utils_test
socket_utils_test: $(BINDIR)/$(CONFIG)/socket_utils_test
socket_utils_tos_test: $(BINDIR)/$(CONFIG)/socket_utils_tos_test
tcp_client_posix_test: $(BINDIR)/$(CONFIG)/tcp_client_posix_test
tcp_posix_test: $(BINDIR)/$(CONFIG)/tcp_posix_test
tcp_server_posix_test: $(BINDIR)/$(CONFIG)/tcp_server_posix_test
@ -1329,7 +1328,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/sockaddr_resolver_test \
$(BINDIR)/$(CONFIG)/sockaddr_utils_test \
$(BINDIR)/$(CONFIG)/socket_utils_test \
$(BINDIR)/$(CONFIG)/socket_utils_tos_test \
$(BINDIR)/$(CONFIG)/tcp_client_posix_test \
$(BINDIR)/$(CONFIG)/tcp_posix_test \
$(BINDIR)/$(CONFIG)/tcp_server_posix_test \
@ -1716,8 +1714,6 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/sockaddr_utils_test || ( echo test sockaddr_utils_test failed ; exit 1 )
$(E) "[RUN] Testing socket_utils_test"
$(Q) $(BINDIR)/$(CONFIG)/socket_utils_test || ( echo test socket_utils_test failed ; exit 1 )
$(E) "[RUN] Testing socket_utils_tos_test"
$(Q) $(BINDIR)/$(CONFIG)/socket_utils_tos_test || ( echo test socket_utils_tos_test failed ; exit 1 )
$(E) "[RUN] Testing tcp_client_posix_test"
$(Q) $(BINDIR)/$(CONFIG)/tcp_client_posix_test || ( echo test tcp_client_posix_test failed ; exit 1 )
$(E) "[RUN] Testing tcp_posix_test"
@ -2581,7 +2577,6 @@ LIBGRPC_SRC = \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
src/core/lib/iomgr/socket_utils_posix.c \
src/core/lib/iomgr/socket_utils_tos_posix.c \
src/core/lib/iomgr/socket_windows.c \
src/core/lib/iomgr/tcp_client_posix.c \
src/core/lib/iomgr/tcp_client_windows.c \
@ -2859,7 +2854,6 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
src/core/lib/iomgr/socket_utils_posix.c \
src/core/lib/iomgr/socket_utils_tos_posix.c \
src/core/lib/iomgr/socket_windows.c \
src/core/lib/iomgr/tcp_client_posix.c \
src/core/lib/iomgr/tcp_client_windows.c \
@ -3127,7 +3121,6 @@ LIBGRPC_TEST_UTIL_SRC = \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
src/core/lib/iomgr/socket_utils_posix.c \
src/core/lib/iomgr/socket_utils_tos_posix.c \
src/core/lib/iomgr/socket_windows.c \
src/core/lib/iomgr/tcp_client_posix.c \
src/core/lib/iomgr/tcp_client_windows.c \
@ -3322,7 +3315,6 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
src/core/lib/iomgr/socket_utils_posix.c \
src/core/lib/iomgr/socket_utils_tos_posix.c \
src/core/lib/iomgr/socket_windows.c \
src/core/lib/iomgr/tcp_client_posix.c \
src/core/lib/iomgr/tcp_client_windows.c \
@ -10349,38 +10341,6 @@ endif
endif
SOCKET_UTILS_TOS_TEST_SRC = \
test/core/iomgr/socket_utils_tos_test.c \
SOCKET_UTILS_TOS_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SOCKET_UTILS_TOS_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/socket_utils_tos_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/socket_utils_tos_test: $(SOCKET_UTILS_TOS_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) $(SOCKET_UTILS_TOS_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)/socket_utils_tos_test
endif
$(OBJDIR)/$(CONFIG)/test/core/iomgr/socket_utils_tos_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_socket_utils_tos_test: $(SOCKET_UTILS_TOS_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(SOCKET_UTILS_TOS_TEST_OBJS:.o=.dep)
endif
endif
TCP_CLIENT_POSIX_TEST_SRC = \
test/core/iomgr/tcp_client_posix_test.c \

@ -608,7 +608,6 @@
'src/core/lib/iomgr/socket_utils_common_posix.c',
'src/core/lib/iomgr/socket_utils_linux.c',
'src/core/lib/iomgr/socket_utils_posix.c',
'src/core/lib/iomgr/socket_utils_tos_posix.c',
'src/core/lib/iomgr/socket_windows.c',
'src/core/lib/iomgr/tcp_client_posix.c',
'src/core/lib/iomgr/tcp_client_windows.c',

@ -293,7 +293,6 @@ filegroups:
- src/core/lib/iomgr/socket_utils_common_posix.c
- src/core/lib/iomgr/socket_utils_linux.c
- src/core/lib/iomgr/socket_utils_posix.c
- src/core/lib/iomgr/socket_utils_tos_posix.c
- src/core/lib/iomgr/socket_windows.c
- src/core/lib/iomgr/tcp_client_posix.c
- src/core/lib/iomgr/tcp_client_windows.c
@ -2438,20 +2437,6 @@ targets:
- mac
- linux
- posix
- name: socket_utils_tos_test
build: test
language: c
src:
- test/core/iomgr/socket_utils_tos_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
platforms:
- mac
- linux
- posix
- name: tcp_client_posix_test
cpu_cost: 0.5
build: test

@ -127,7 +127,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
src/core/lib/iomgr/socket_utils_posix.c \
src/core/lib/iomgr/socket_utils_tos_posix.c \
src/core/lib/iomgr/socket_windows.c \
src/core/lib/iomgr/tcp_client_posix.c \
src/core/lib/iomgr/tcp_client_windows.c \

@ -457,7 +457,6 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/socket_utils_common_posix.c',
'src/core/lib/iomgr/socket_utils_linux.c',
'src/core/lib/iomgr/socket_utils_posix.c',
'src/core/lib/iomgr/socket_utils_tos_posix.c',
'src/core/lib/iomgr/socket_windows.c',
'src/core/lib/iomgr/tcp_client_posix.c',
'src/core/lib/iomgr/tcp_client_windows.c',

@ -377,7 +377,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/iomgr/socket_utils_common_posix.c )
s.files += %w( src/core/lib/iomgr/socket_utils_linux.c )
s.files += %w( src/core/lib/iomgr/socket_utils_posix.c )
s.files += %w( src/core/lib/iomgr/socket_utils_tos_posix.c )
s.files += %w( src/core/lib/iomgr/socket_windows.c )
s.files += %w( src/core/lib/iomgr/tcp_client_posix.c )
s.files += %w( src/core/lib/iomgr/tcp_client_windows.c )

@ -201,10 +201,20 @@ typedef struct {
#define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size"
/** If non-zero, allow the use of SO_REUSEPORT if it's available (default 1) */
#define GRPC_ARG_ALLOW_REUSEPORT "grpc.so_reuseport"
/** The Type-Of-Service (TOS), in bytes. */
#define GRPC_ARG_TOS "grpc.tos"
/** The grpc_socket_mutator instance that set the socket options. A pointer. */
#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator"
/** \} */
typedef struct grpc_socket_mutator grpc_socket_mutator;
typedef struct grpc_socket_mutator_vtable {
bool (*mutate_fd)(int fd, grpc_socket_mutator *mutator);
} grpc_socket_mutator_vtable;
struct grpc_socket_mutator {
const grpc_socket_mutator_vtable *vtable;
};
/** Result of a grpc call. If the caller satisfies the prerequisites of a
particular operation, the grpc_call_error returned will be GRPC_CALL_OK.
Receiving any other value listed here is an indication of a bug in the

@ -384,7 +384,6 @@
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_common_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_linux.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_tos_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_windows.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client_windows.c" role="src" />

@ -208,6 +208,15 @@ grpc_error *grpc_set_socket_low_latency(int fd, int low_latency) {
return GRPC_ERROR_NONE;
}
/* set a socker using a grpc_socket_mutator */
grpc_error *grpc_set_socket_with_mutator(int fd, grpc_socket_mutator *mutator) {
GPR_ASSERT(mutator);
if (!mutator->vtable->mutate_fd(fd, mutator)) {
return GRPC_ERROR_CREATE("grpc_socket_mutator failed.");
}
return GRPC_ERROR_NONE;
}
static gpr_once g_probe_ipv6_once = GPR_ONCE_INIT;
static int g_ipv6_loopback_available;

@ -87,8 +87,8 @@ grpc_error *grpc_set_socket_sndbuf(int fd, int buffer_size_bytes);
/* Tries to set the socket's receive buffer to given size. */
grpc_error *grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes);
/* Tries to set the socket's type to service */
grpc_error *grpc_set_socket_tos(int fd, grpc_arg *arg);
/* Tries to set the socket using a grpc_socket_mutator */
grpc_error *grpc_set_socket_with_mutator(int fd, grpc_socket_mutator *mutator);
/* An enum to keep track of IPv4/IPv6 socket modes.

@ -1,68 +0,0 @@
/*
*
* Copyright 2016, 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 <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SOCKET
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include <errno.h>
#include <netinet/in.h>
#include <string.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/support/log.h>
grpc_error* grpc_set_socket_tos(int fd, grpc_arg* arg) {
int newval;
socklen_t intlen = sizeof(newval);
GPR_ASSERT(0 == strcmp(arg->key, GRPC_ARG_TOS));
GPR_ASSERT(arg->type == GRPC_ARG_INTEGER);
if (0 != setsockopt(fd, IPPROTO_IP, IP_TOS, &arg->value.integer,
sizeof(arg->value.integer))) {
return GRPC_OS_ERROR(errno, "setsockopt(IP_TOS)");
}
if (0 != getsockopt(fd, IPPROTO_IP, IP_TOS, &newval, &intlen)) {
return GRPC_OS_ERROR(errno, "getsockopt(IP_TOS)");
}
if (newval != arg->value.integer) {
return GRPC_ERROR_CREATE("Failed to set IP_TOS");
}
return GRPC_ERROR_NONE;
}
#endif

@ -89,10 +89,11 @@ static grpc_error *prepare_socket(const struct sockaddr *addr, int fd,
if (err != GRPC_ERROR_NONE) goto error;
if (channel_args) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_TOS)) {
err = grpc_set_socket_tos(fd, &channel_args->args[i]);
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_SOCKET_MUTATOR)) {
GPR_ASSERT(channel_args->args[i].type == GRPC_ARG_POINTER);
grpc_socket_mutator *mutator = channel_args->args[i].value.pointer.p;
err = grpc_set_socket_with_mutator(fd, mutator);
if (err != GRPC_ERROR_NONE) goto error;
break;
}
}
}

@ -121,7 +121,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/iomgr/socket_utils_common_posix.c',
'src/core/lib/iomgr/socket_utils_linux.c',
'src/core/lib/iomgr/socket_utils_posix.c',
'src/core/lib/iomgr/socket_utils_tos_posix.c',
'src/core/lib/iomgr/socket_windows.c',
'src/core/lib/iomgr/tcp_client_posix.c',
'src/core/lib/iomgr/tcp_client_windows.c',

@ -35,11 +35,37 @@
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include <errno.h>
#include <netinet/ip.h>
#include <string.h>
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
struct test_socket_mutator {
grpc_socket_mutator base;
int option_value;
};
static bool mutate_fd(int fd, grpc_socket_mutator* mutator) {
int newval;
socklen_t intlen = sizeof(newval);
struct test_socket_mutator* m = (struct test_socket_mutator*)mutator;
if (0 != setsockopt(fd, IPPROTO_IP, IP_TOS, &m->option_value,
sizeof(m->option_value))) {
return false;
}
if (0 != getsockopt(fd, IPPROTO_IP, IP_TOS, &newval, &intlen)) {
return false;
}
if (newval != m->option_value) {
return false;
}
return true;
}
static const grpc_socket_mutator_vtable mutator_vtable = {mutate_fd};
int main(int argc, char **argv) {
int sock;
grpc_test_init(argc, argv);
@ -64,6 +90,28 @@ int main(int argc, char **argv) {
GPR_ASSERT(GRPC_LOG_IF_ERROR("set_socket_low_latency",
grpc_set_socket_low_latency(sock, 0)));
struct test_socket_mutator mutator;
mutator.base.vtable = &mutator_vtable;
mutator.option_value = IPTOS_LOWDELAY;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"set_socket_with_mutator",
grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator)));
mutator.option_value = IPTOS_THROUGHPUT;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"set_socket_with_mutator",
grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator)));
mutator.option_value = IPTOS_RELIABILITY;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"set_socket_with_mutator",
grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator)));
mutator.option_value = -1;
GPR_ASSERT(GRPC_ERROR_NONE != grpc_set_socket_with_mutator(
sock, (grpc_socket_mutator*)&mutator));
close(sock);
return 0;

@ -1,67 +0,0 @@
/*
*
* Copyright 2016, 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 <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include <errno.h>
#include <netinet/ip.h>
#include <string.h>
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
int main(int argc, char **argv) {
int sock;
grpc_arg tos_arg;
grpc_test_init(argc, argv);
sock = socket(PF_INET, SOCK_STREAM, 0);
GPR_ASSERT(sock > 0);
tos_arg.key = GRPC_ARG_TOS;
tos_arg.type = GRPC_ARG_INTEGER;
tos_arg.value.integer = IPTOS_LOWDELAY;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("set_socket_tos", grpc_set_socket_tos(sock, &tos_arg)));
tos_arg.value.integer = IPTOS_THROUGHPUT;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("set_socket_tos", grpc_set_socket_tos(sock, &tos_arg)));
tos_arg.value.integer = IPTOS_RELIABILITY;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("set_socket_tos", grpc_set_socket_tos(sock, &tos_arg)));
close(sock);
return 0;
}

@ -994,7 +994,6 @@ src/core/lib/iomgr/sockaddr_utils.c \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
src/core/lib/iomgr/socket_utils_posix.c \
src/core/lib/iomgr/socket_utils_tos_posix.c \
src/core/lib/iomgr/socket_windows.c \
src/core/lib/iomgr/tcp_client_posix.c \
src/core/lib/iomgr/tcp_client_windows.c \

@ -1858,23 +1858,6 @@
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc_test_util"
],
"headers": [],
"is_filegroup": false,
"language": "c",
"name": "socket_utils_tos_test",
"src": [
"test/core/iomgr/socket_utils_tos_test.c"
],
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
@ -6550,7 +6533,6 @@
"src/core/lib/iomgr/socket_utils_linux.c",
"src/core/lib/iomgr/socket_utils_posix.c",
"src/core/lib/iomgr/socket_utils_posix.h",
"src/core/lib/iomgr/socket_utils_tos_posix.c",
"src/core/lib/iomgr/socket_windows.c",
"src/core/lib/iomgr/socket_windows.h",
"src/core/lib/iomgr/tcp_client.h",

@ -1819,25 +1819,6 @@
"posix"
]
},
{
"args": [],
"ci_platforms": [
"linux",
"mac",
"posix"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "socket_utils_tos_test",
"platforms": [
"linux",
"mac",
"posix"
]
},
{
"args": [],
"ci_platforms": [

@ -549,8 +549,6 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_tos_posix.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.c">

@ -133,9 +133,6 @@
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_tos_posix.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>

@ -397,8 +397,6 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_tos_posix.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.c">

@ -187,9 +187,6 @@
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_tos_posix.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>

@ -517,8 +517,6 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_tos_posix.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.c">

@ -136,9 +136,6 @@
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_tos_posix.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>

Loading…
Cancel
Save