Skip to content

Commit

Permalink
Merge branch 'master' of github.com:grpc/grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Jun 4, 2015
2 parents 548dc2e + 1b13c54 commit 2687db6
Show file tree
Hide file tree
Showing 86 changed files with 501 additions and 166 deletions.
3 changes: 3 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ cc_library(
"include/grpc/support/port_platform.h",
"include/grpc/support/slice.h",
"include/grpc/support/slice_buffer.h",
"include/grpc/support/string_util.h",
"include/grpc/support/subprocess.h",
"include/grpc/support/sync.h",
"include/grpc/support/sync_generic.h",
Expand Down Expand Up @@ -582,6 +583,7 @@ cc_library(
"src/cpp/common/rpc_method.cc",
"src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc",
Expand Down Expand Up @@ -661,6 +663,7 @@ cc_library(
"src/cpp/common/rpc_method.cc",
"src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc",
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2838,6 +2838,7 @@ PUBLIC_HEADERS_C += \
include/grpc/support/port_platform.h \
include/grpc/support/slice.h \
include/grpc/support/slice_buffer.h \
include/grpc/support/string_util.h \
include/grpc/support/subprocess.h \
include/grpc/support/sync.h \
include/grpc/support/sync_generic.h \
Expand Down Expand Up @@ -3331,6 +3332,7 @@ LIBGRPC++_SRC = \
src/cpp/common/rpc_method.cc \
src/cpp/proto/proto_utils.cc \
src/cpp/server/async_generic_service.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/insecure_server_credentials.cc \
src/cpp/server/server.cc \
src/cpp/server/server_builder.cc \
Expand Down Expand Up @@ -3618,6 +3620,7 @@ LIBGRPC++_UNSECURE_SRC = \
src/cpp/common/rpc_method.cc \
src/cpp/proto/proto_utils.cc \
src/cpp/server/async_generic_service.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/insecure_server_credentials.cc \
src/cpp/server/server.cc \
src/cpp/server/server_builder.cc \
Expand Down
2 changes: 2 additions & 0 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"src/cpp/common/rpc_method.cc",
"src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc",
Expand Down Expand Up @@ -314,6 +315,7 @@
"include/grpc/support/port_platform.h",
"include/grpc/support/slice.h",
"include/grpc/support/slice_buffer.h",
"include/grpc/support/string_util.h",
"include/grpc/support/subprocess.h",
"include/grpc/support/sync.h",
"include/grpc/support/sync_generic.h",
Expand Down
10 changes: 10 additions & 0 deletions include/grpc/grpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,16 @@ void grpc_server_shutdown_and_notify(grpc_server *server, void *tag);
Implies grpc_server_shutdown() if one was not previously performed. */
void grpc_server_destroy(grpc_server *server);

/** Enable or disable a tracer.
Tracers (usually controlled by the environment variable GRPC_TRACE)
allow printf-style debugging on GRPC internals, and are useful for
tracking down problems in the field.
Use of this function is not strictly thread-safe, but the
thread-safety issues raised by it should not be of concern. */
int grpc_tracer_set_enabled(const char *name, int enabled);

#ifdef __cplusplus
}
#endif
Expand Down
61 changes: 61 additions & 0 deletions include/grpc/support/string_util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
*
* 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.
*
*/

#ifndef GRPC_SUPPORT_STRING_UTIL_H
#define GRPC_SUPPORT_STRING_UTIL_H

#ifdef __cplusplus
extern "C" {
#endif

/* String utility functions */

/* Returns a copy of src that can be passed to gpr_free().
If allocation fails or if src is NULL, returns NULL. */
char *gpr_strdup(const char *src);

/* printf to a newly-allocated string. The set of supported formats may vary
between platforms.
On success, returns the number of bytes printed (excluding the final '\0'),
and *strp points to a string which must later be destroyed with gpr_free().
On error, returns -1 and sets *strp to NULL. If the format string is bad,
the result is undefined. */
int gpr_asprintf(char **strp, const char *format, ...);

#ifdef __cplusplus
}
#endif

#endif /* GRPC_SUPPORT_STRING_UTIL_H */
1 change: 1 addition & 0 deletions src/core/channel/channel_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "src/core/support/string.h"

#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>

#include <string.h>

Expand Down
45 changes: 27 additions & 18 deletions src/core/debug/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include <string.h>

#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/support/env.h"
Expand Down Expand Up @@ -80,27 +81,10 @@ static void parse(const char *s) {
char **strings = NULL;
size_t nstrings = 0;
size_t i;
tracer *t;
split(s, &strings, &nstrings);

for (i = 0; i < nstrings; i++) {
const char *s = strings[i];
if (0 == strcmp(s, "all")) {
for (t = tracers; t; t = t->next) {
*t->flag = 1;
}
} else {
int found = 0;
for (t = tracers; t; t = t->next) {
if (0 == strcmp(s, t->name)) {
*t->flag = 1;
found = 1;
}
}
if (!found) {
gpr_log(GPR_ERROR, "Unknown trace var: '%s'", s);
}
}
grpc_tracer_set_enabled(strings[i], 1);
}

for (i = 0; i < nstrings; i++) {
Expand All @@ -115,9 +99,34 @@ void grpc_tracer_init(const char *env_var) {
parse(e);
gpr_free(e);
}
}

void grpc_tracer_shutdown(void) {
while (tracers) {
tracer *t = tracers;
tracers = t->next;
gpr_free(t);
}
}

int grpc_tracer_set_enabled(const char *name, int enabled) {
tracer *t;
if (0 == strcmp(name, "all")) {
for (t = tracers; t; t = t->next) {
*t->flag = 1;
}
} else {
int found = 0;
for (t = tracers; t; t = t->next) {
if (0 == strcmp(name, t->name)) {
*t->flag = enabled;
found = 1;
}
}
if (!found) {
gpr_log(GPR_ERROR, "Unknown trace var: '%s'", name);
return 0; /* early return */
}
}
return 1;
}
1 change: 1 addition & 0 deletions src/core/debug/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@

void grpc_register_tracer(const char *name, int *flag);
void grpc_tracer_init(const char *env_var_name);
void grpc_tracer_shutdown(void);

#endif /* GRPC_INTERNAL_CORE_DEBUG_TRACE_H */
1 change: 1 addition & 0 deletions src/core/httpcli/format_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/slice.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>

static void fill_common_header(const grpc_httpcli_request *request, gpr_strvec *buf) {
Expand Down
1 change: 1 addition & 0 deletions src/core/httpcli/httpcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>

typedef struct {
gpr_slice request_text;
Expand Down
1 change: 1 addition & 0 deletions src/core/httpcli/httpcli_security_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/tsi/ssl_transport_security.h"

typedef struct {
Expand Down
1 change: 1 addition & 0 deletions src/core/iomgr/endpoint_pair_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>

static void create_sockets(int sv[2]) {
int flags;
Expand Down
3 changes: 2 additions & 1 deletion src/core/iomgr/iomgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/thd.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>

static gpr_mu g_mu;
static gpr_cv g_rcv;
Expand Down
1 change: 1 addition & 0 deletions src/core/iomgr/resolve_address_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>

Expand Down
1 change: 1 addition & 0 deletions src/core/iomgr/resolve_address_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/thd.h>
#include <grpc/support/time.h>

Expand Down
1 change: 1 addition & 0 deletions src/core/iomgr/sockaddr_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>

static const gpr_uint8 kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0xff, 0xff};
Expand Down
1 change: 1 addition & 0 deletions src/core/iomgr/tcp_client_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>

typedef struct {
Expand Down
1 change: 1 addition & 0 deletions src/core/iomgr/tcp_server_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>

Expand Down
1 change: 1 addition & 0 deletions src/core/iomgr/tcp_server_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_win32.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>

Expand Down
1 change: 1 addition & 0 deletions src/core/iomgr/tcp_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <grpc/support/log.h>
#include <grpc/support/log_win32.h>
#include <grpc/support/slice_buffer.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>

#include "src/core/iomgr/alarm.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/security/client_auth_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>

#include "src/core/support/string.h"
#include "src/core/channel/channel_stack.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/security/credentials.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>

Expand Down
1 change: 1 addition & 0 deletions src/core/security/credentials_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>

#include "src/core/support/env.h"
#include "src/core/support/string.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/security/credentials_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>

#include "src/core/support/env.h"
#include "src/core/support/string.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/security/json_token.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>

#include "src/core/security/base64.h"
#include "src/core/support/string.h"
Expand Down
1 change: 1 addition & 0 deletions src/core/security/security_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h>
#include <grpc/support/string_util.h>
#include "src/core/tsi/fake_transport_security.h"
#include "src/core/tsi/ssl_transport_security.h"

Expand Down
1 change: 1 addition & 0 deletions src/core/security/security_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>

/* --- grpc_call --- */

Expand Down
1 change: 0 additions & 1 deletion src/core/security/server_auth_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ static void init_call_elem(grpc_call_element *elem,
calld->unused = 0;

GPR_ASSERT(initial_op && initial_op->context != NULL &&
chand->security_connector->auth_context != NULL &&
initial_op->context[GRPC_CONTEXT_SECURITY].value == NULL);

/* Create a security context for the call and reference the auth context from
Expand Down
Loading

0 comments on commit 2687db6

Please sign in to comment.