aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-04-23 13:31:34 -0700
committerGravatar Craig Tiller <ctiller@google.com>2016-04-23 13:31:34 -0700
commit0ca01ed80de6b9e698c004534957bca31f70f2c2 (patch)
tree6ffb2b04543fcb206eff72f4436558c068038104 /src
parentc2c0f53e4eb7fe8906df55d984fdb36dc58b649f (diff)
parentab8b9f51437ab7502b09bed22b7fc1a265016e44 (diff)
Expand corpus
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_encoder.c18
-rw-r--r--src/core/lib/http/parser.c13
-rw-r--r--src/core/lib/http/parser.h2
-rw-r--r--src/core/lib/iomgr/udp_server.c3
-rw-r--r--src/core/lib/surface/init.c2
-rw-r--r--src/cpp/client/client_context.cc8
-rw-r--r--src/cpp/common/create_auth_context.h42
-rw-r--r--src/cpp/server/server_context.cc13
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py2
9 files changed, 24 insertions, 79 deletions
diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.c b/src/core/ext/transport/chttp2/transport/bin_encoder.c
index db68e750ac..1b43c28be1 100644
--- a/src/core/ext/transport/chttp2/transport/bin_encoder.c
+++ b/src/core/ext/transport/chttp2/transport/bin_encoder.c
@@ -194,9 +194,13 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input) {
/* encode full triplets */
for (i = 0; i < input_triplets; i++) {
- enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4) | (in[1] >> 4));
- enc_add2(&out, (uint8_t)((in[1] & 0xf) << 2) | (in[2] >> 6),
- (uint8_t)(in[2] & 0x3f));
+ const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4);
+ const uint8_t high_to_low = in[1] >> 4;
+ enc_add2(&out, in[0] >> 2, low_to_high | high_to_low);
+
+ const uint8_t a = (uint8_t)((in[1] & 0xf) << 2);
+ const uint8_t b = (in[2] >> 6);
+ enc_add2(&out, a | b, in[2] & 0x3f);
in += 3;
}
@@ -208,12 +212,14 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input) {
enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4));
in += 1;
break;
- case 2:
- enc_add2(&out, in[0] >> 2,
- (uint8_t)((in[0] & 0x3) << 4) | (uint8_t)(in[1] >> 4));
+ case 2: {
+ const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4);
+ const uint8_t high_to_low = in[1] >> 4;
+ enc_add2(&out, in[0] >> 2, low_to_high | high_to_low);
enc_add1(&out, (uint8_t)((in[1] & 0xf) << 2));
in += 2;
break;
+ }
}
if (out.temp_length) {
diff --git a/src/core/lib/http/parser.c b/src/core/lib/http/parser.c
index 01d17fb623..921c772453 100644
--- a/src/core/lib/http/parser.c
+++ b/src/core/lib/http/parser.c
@@ -39,7 +39,7 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
-extern int grpc_http_trace;
+int grpc_http1_trace = 0;
static char *buf2str(void *buffer, size_t length) {
char *out = gpr_malloc(length + 1);
@@ -74,7 +74,7 @@ static int handle_response_line(grpc_http_parser *parser) {
return 1;
error:
- if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing response line");
+ if (grpc_http1_trace) gpr_log(GPR_ERROR, "Failed parsing response line");
return 0;
}
@@ -127,7 +127,7 @@ static int handle_request_line(grpc_http_parser *parser) {
return 1;
error:
- if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing request line");
+ if (grpc_http1_trace) gpr_log(GPR_ERROR, "Failed parsing request line");
return 0;
}
@@ -152,7 +152,7 @@ static int add_header(grpc_http_parser *parser) {
GPR_ASSERT(cur != end);
if (*cur == ' ' || *cur == '\t') {
- if (grpc_http_trace)
+ if (grpc_http1_trace)
gpr_log(GPR_ERROR, "Continued header lines not supported yet");
goto error;
}
@@ -161,7 +161,8 @@ static int add_header(grpc_http_parser *parser) {
cur++;
}
if (cur == end) {
- if (grpc_http_trace) gpr_log(GPR_ERROR, "Didn't find ':' in header string");
+ if (grpc_http1_trace)
+ gpr_log(GPR_ERROR, "Didn't find ':' in header string");
goto error;
}
GPR_ASSERT(cur >= beg);
@@ -252,7 +253,7 @@ static int addbyte(grpc_http_parser *parser, uint8_t byte) {
case GRPC_HTTP_FIRST_LINE:
case GRPC_HTTP_HEADERS:
if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) {
- if (grpc_http_trace)
+ if (grpc_http1_trace)
gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded",
GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
return 0;
diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h
index 8bd73f649a..42fa5181b8 100644
--- a/src/core/lib/http/parser.h
+++ b/src/core/lib/http/parser.h
@@ -113,4 +113,6 @@ void grpc_http_parser_destroy(grpc_http_parser *parser);
int grpc_http_parser_parse(grpc_http_parser *parser, gpr_slice slice);
int grpc_http_parser_eof(grpc_http_parser *parser);
+extern int grpc_http1_trace;
+
#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */
diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c
index 24131179af..df6cf956d9 100644
--- a/src/core/lib/iomgr/udp_server.c
+++ b/src/core/lib/iomgr/udp_server.c
@@ -166,7 +166,6 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
if (s->nports) {
for (i = 0; i < s->nports; i++) {
server_port *sp = &s->ports[i];
- grpc_unlink_if_unix_domain_socket(&sp->addr.sockaddr);
sp->destroyed_closure.cb = destroyed_port;
sp->destroyed_closure.cb_arg = s;
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
@@ -317,8 +316,6 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
socklen_t sockname_len;
int port;
- grpc_unlink_if_unix_domain_socket((struct sockaddr *)addr);
-
/* Check if this is a wildcard port, and if so, try to keep the port the same
as some previously created listener. */
if (grpc_sockaddr_get_port(addr) == 0) {
diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c
index d4eb2f8ddd..03f379aba8 100644
--- a/src/core/lib/surface/init.c
+++ b/src/core/lib/surface/init.c
@@ -46,6 +46,7 @@
#include "src/core/lib/channel/http_client_filter.h"
#include "src/core/lib/channel/http_server_filter.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/profiling/timers.h"
@@ -162,6 +163,7 @@ void grpc_init(void) {
grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace);
grpc_register_tracer("channel_stack_builder",
&grpc_trace_channel_stack_builder);
+ grpc_register_tracer("http1", &grpc_http1_trace);
grpc_security_pre_init();
grpc_iomgr_init();
grpc_executor_init();
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index c277d7ebe8..32c7794ade 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -42,7 +42,6 @@
#include <grpc/support/string_util.h>
#include "src/core/lib/channel/compress_filter.h"
-#include "src/cpp/common/create_auth_context.h"
namespace grpc {
@@ -116,13 +115,6 @@ void ClientContext::set_compression_algorithm(
AddMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name);
}
-std::shared_ptr<const AuthContext> ClientContext::auth_context() const {
- if (auth_context_.get() == nullptr) {
- auth_context_ = CreateAuthContext(call_);
- }
- return auth_context_;
-}
-
void ClientContext::TryCancel() {
grpc::unique_lock<grpc::mutex> lock(mu_);
if (call_) {
diff --git a/src/cpp/common/create_auth_context.h b/src/cpp/common/create_auth_context.h
deleted file mode 100644
index 387407bfec..0000000000
--- a/src/cpp/common/create_auth_context.h
+++ /dev/null
@@ -1,42 +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.
- *
- */
-#include <memory>
-
-#include <grpc++/security/auth_context.h>
-#include <grpc/grpc.h>
-
-namespace grpc {
-
-std::shared_ptr<const AuthContext> CreateAuthContext(grpc_call* call);
-
-} // namespace grpc
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index e05a7df28a..204fef1b09 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -44,7 +44,6 @@
#include "src/core/lib/channel/compress_filter.h"
#include "src/core/lib/surface/call.h"
-#include "src/cpp/common/create_auth_context.h"
namespace grpc {
@@ -214,18 +213,6 @@ void ServerContext::set_compression_algorithm(
AddInitialMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name);
}
-void ServerContext::set_call(grpc_call* call) {
- call_ = call;
- auth_context_ = CreateAuthContext(call);
-}
-
-std::shared_ptr<const AuthContext> ServerContext::auth_context() const {
- if (auth_context_.get() == nullptr) {
- auth_context_ = CreateAuthContext(call_);
- }
- return auth_context_;
-}
-
grpc::string ServerContext::peer() const {
grpc::string peer;
if (call_) {
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 94e1807c6b..c5a0a398b4 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -74,6 +74,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/support/tmpfile_posix.c',
'src/core/lib/support/tmpfile_win32.c',
'src/core/lib/support/wrap_memcpy.c',
+ 'src/core/lib/surface/init.c',
'src/core/lib/channel/channel_args.c',
'src/core/lib/channel/channel_stack.c',
'src/core/lib/channel/channel_stack_builder.c',
@@ -143,7 +144,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/surface/channel_stack_type.c',
'src/core/lib/surface/completion_queue.c',
'src/core/lib/surface/event_string.c',
- 'src/core/lib/surface/init.c',
'src/core/lib/surface/lame_client.c',
'src/core/lib/surface/metadata_array.c',
'src/core/lib/surface/server.c',