diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lib/iomgr/socket_utils_common_posix.c | 9 | ||||
-rw-r--r-- | src/core/lib/iomgr/socket_utils_posix.h | 4 | ||||
-rw-r--r-- | src/core/lib/iomgr/socket_utils_tos_posix.c | 68 | ||||
-rw-r--r-- | src/core/lib/iomgr/tcp_client_posix.c | 7 | ||||
-rw-r--r-- | src/python/grpcio/grpc_core_dependencies.py | 1 |
5 files changed, 15 insertions, 74 deletions
diff --git a/src/core/lib/iomgr/socket_utils_common_posix.c b/src/core/lib/iomgr/socket_utils_common_posix.c index d2f6261e2a..8c33ba3754 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.c +++ b/src/core/lib/iomgr/socket_utils_common_posix.c @@ -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; diff --git a/src/core/lib/iomgr/socket_utils_posix.h b/src/core/lib/iomgr/socket_utils_posix.h index bf4cc96af2..d84a95d3d3 100644 --- a/src/core/lib/iomgr/socket_utils_posix.h +++ b/src/core/lib/iomgr/socket_utils_posix.h @@ -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. diff --git a/src/core/lib/iomgr/socket_utils_tos_posix.c b/src/core/lib/iomgr/socket_utils_tos_posix.c deleted file mode 100644 index 603ad3c421..0000000000 --- a/src/core/lib/iomgr/socket_utils_tos_posix.c +++ /dev/null @@ -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 diff --git a/src/core/lib/iomgr/tcp_client_posix.c b/src/core/lib/iomgr/tcp_client_posix.c index 1439efe706..84eb41ecd2 100644 --- a/src/core/lib/iomgr/tcp_client_posix.c +++ b/src/core/lib/iomgr/tcp_client_posix.c @@ -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; } } } diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index dec578edb5..2bebf48c70 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -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', |