Uncover the badness

reviewable/pr8842/r4
Craig Tiller 8 years ago
parent e5d8e02aa6
commit 95beab2284
  1. 1
      src/core/lib/iomgr/closure.c
  2. 1
      src/core/lib/iomgr/closure.h
  3. 12
      src/core/lib/iomgr/combiner.c
  4. 2
      src/core/lib/iomgr/ev_epoll_linux.c
  5. 2
      src/core/lib/iomgr/exec_ctx.c
  6. 4
      src/core/lib/iomgr/executor.c
  7. 11
      src/core/lib/security/credentials/plugin/plugin_credentials.c
  8. 24
      src/core/lib/security/transport/client_auth_filter.c
  9. 2
      src/cpp/client/secure_credentials.h
  10. 9
      src/cpp/server/dynamic_thread_pool.cc
  11. 1
      test/cpp/end2end/end2end_test.cc

@ -34,6 +34,7 @@
#include "src/core/lib/iomgr/closure.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/profiling/timers.h"

@ -66,6 +66,7 @@ typedef struct grpc_closure_scheduler_vtable {
grpc_error *error);
void (*sched)(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
grpc_error *error);
const char *name;
} grpc_closure_scheduler_vtable;
/** Abstract type that can schedule closures for execution */

@ -86,13 +86,17 @@ static void combiner_finally_exec_covered(grpc_exec_ctx *exec_ctx,
grpc_error *error);
static const grpc_closure_scheduler_vtable scheduler_uncovered = {
combiner_exec_uncovered, combiner_exec_uncovered};
combiner_exec_uncovered, combiner_exec_uncovered,
"combiner:immediately:uncovered"};
static const grpc_closure_scheduler_vtable scheduler_covered = {
combiner_exec_covered, combiner_exec_covered};
combiner_exec_covered, combiner_exec_covered,
"combiner:immediately:covered"};
static const grpc_closure_scheduler_vtable finally_scheduler_uncovered = {
combiner_finally_exec_uncovered, combiner_finally_exec_uncovered};
combiner_finally_exec_uncovered, combiner_finally_exec_uncovered,
"combiner:finally:uncovered"};
static const grpc_closure_scheduler_vtable finally_scheduler_covered = {
combiner_finally_exec_covered, combiner_finally_exec_covered};
combiner_finally_exec_covered, combiner_finally_exec_covered,
"combiner:finally:covered"};
static void offload(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error);

@ -321,7 +321,7 @@ gpr_atm g_epoll_sync;
#endif /* defined(GRPC_TSAN) */
static const grpc_closure_scheduler_vtable workqueue_scheduler_vtable = {
workqueue_enqueue, workqueue_enqueue};
workqueue_enqueue, workqueue_enqueue, "workqueue"};
static void pi_add_ref(polling_island *pi);
static void pi_unref(grpc_exec_ctx *exec_ctx, polling_island *pi);

@ -101,6 +101,6 @@ void grpc_exec_ctx_global_init(void) {}
void grpc_exec_ctx_global_shutdown(void) {}
static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = {
exec_ctx_run, exec_ctx_sched};
exec_ctx_run, exec_ctx_sched, "exec_ctx"};
static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable};
grpc_closure_scheduler *grpc_schedule_on_exec_ctx = &exec_ctx_scheduler;

@ -158,7 +158,7 @@ void grpc_executor_shutdown(grpc_exec_ctx *exec_ctx) {
gpr_mu_destroy(&g_executor.mu);
}
static const grpc_closure_scheduler_vtable executor_vtable = {executor_push,
executor_push};
static const grpc_closure_scheduler_vtable executor_vtable = {
executor_push, executor_push, "executor"};
static grpc_closure_scheduler executor_scheduler = {&executor_vtable};
grpc_closure_scheduler *grpc_executor_scheduler = &executor_scheduler;

@ -44,6 +44,7 @@
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/validate_metadata.h"
typedef struct {
void *user_data;
@ -78,14 +79,14 @@ static void plugin_md_request_metadata_ready(void *request,
bool seen_illegal_header = false;
grpc_credentials_md *md_array = NULL;
for (i = 0; i < num_md; i++) {
if (!grpc_header_key_is_legal(md[i].key)) {
char *key = grpc_slice_to_c_string(md[i].key);
gpr_log(GPR_ERROR, "Plugin added invalid metadata key: %s", key);
gpr_free(key);
if (!GRPC_LOG_IF_ERROR("validate_metadata_from_plugin",
grpc_validate_header_key_is_legal(md[i].key))) {
seen_illegal_header = true;
break;
} else if (!grpc_is_binary_header(md[i].key) &&
!grpc_header_nonbin_value_is_legal(md[i].value)) {
!GRPC_LOG_IF_ERROR(
"validate_metadata_from_plugin",
grpc_validate_header_nonbin_value_is_legal(md[i].value))) {
gpr_log(GPR_ERROR, "Plugin added invalid metadata value.");
seen_illegal_header = true;
break;

@ -123,24 +123,12 @@ static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *user_data,
GPR_ASSERT(op->send_initial_metadata != NULL);
mdb = op->send_initial_metadata;
for (i = 0; i < num_md; i++) {
if (!grpc_header_key_is_legal(md_elems[i].key)) {
char *str = grpc_slice_to_c_string(md_elems[i].key);
gpr_log(GPR_ERROR, "attempt to send invalid metadata key: %s", str);
gpr_free(str);
} else if (!grpc_is_binary_header(md_elems[i].key) &&
!grpc_header_nonbin_value_is_legal(md_elems[i].value)) {
char *str =
grpc_dump_slice(md_elems[i].value, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "attempt to send invalid metadata value: %s", str);
gpr_free(str);
} else {
add_error(&error,
grpc_metadata_batch_add_tail(
exec_ctx, mdb, &calld->md_links[i],
grpc_mdelem_from_slices(
exec_ctx, grpc_slice_ref_internal(md_elems[i].key),
grpc_slice_ref_internal(md_elems[i].value))));
}
add_error(&error,
grpc_metadata_batch_add_tail(
exec_ctx, mdb, &calld->md_links[i],
grpc_mdelem_from_slices(
exec_ctx, grpc_slice_ref_internal(md_elems[i].key),
grpc_slice_ref_internal(md_elems[i].value))));
}
}
if (error == GRPC_ERROR_NONE) {

@ -70,7 +70,7 @@ class SecureCallCredentials final : public CallCredentials {
grpc_call_credentials* const c_creds_;
};
class MetadataCredentialsPluginWrapper final {
class MetadataCredentialsPluginWrapper final : private GrpcLibraryCodegen {
public:
static void Destroy(void* wrapper);
static void GetMetadata(void* wrapper, grpc_auth_metadata_context context,

@ -31,12 +31,16 @@
*
*/
#include "src/cpp/server/dynamic_thread_pool.h"
#include <mutex>
#include <thread>
#include "src/cpp/server/dynamic_thread_pool.h"
#include <grpc/support/log.h>
namespace grpc {
static thread_local bool g_is_dynamic_thread_pool_thread;
DynamicThreadPool::DynamicThread::DynamicThread(DynamicThreadPool* pool)
: pool_(pool),
thd_(new std::thread(&DynamicThreadPool::DynamicThread::ThreadFunc,
@ -47,6 +51,7 @@ DynamicThreadPool::DynamicThread::~DynamicThread() {
}
void DynamicThreadPool::DynamicThread::ThreadFunc() {
g_is_dynamic_thread_pool_thread = true;
pool_->ThreadFunc();
// Now that we have killed ourselves, we should reduce the thread count
std::unique_lock<std::mutex> lock(pool_->mu_);
@ -99,11 +104,13 @@ DynamicThreadPool::DynamicThreadPool(int reserve_threads)
void DynamicThreadPool::ReapThreads(std::list<DynamicThread*>* tlist) {
for (auto t = tlist->begin(); t != tlist->end(); t = tlist->erase(t)) {
gpr_log(GPR_DEBUG, "delete %p", *t);
delete *t;
}
}
DynamicThreadPool::~DynamicThreadPool() {
GPR_ASSERT(!g_is_dynamic_thread_pool_thread);
std::unique_lock<std::mutex> lock(mu_);
shutdown_ = true;
cv_.notify_all();

@ -1302,6 +1302,7 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginAndProcessorFailure) {
EXPECT_FALSE(s.ok());
EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED);
}
TEST_P(SecureEnd2endTest, SetPerCallCredentials) {
ResetStub();
EchoRequest request;

Loading…
Cancel
Save