Remove grpc_httpcli_context (#27867)

* remove grpc_httpcli_context
pull/27074/head^2
apolcyn 3 years ago committed by GitHub
parent bccd1c7c22
commit 066a50b9ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc
  2. 48
      src/core/lib/http/httpcli.cc
  3. 18
      src/core/lib/http/httpcli.h
  4. 15
      src/core/lib/security/credentials/external/aws_external_account_credentials.cc
  5. 16
      src/core/lib/security/credentials/external/external_account_credentials.cc
  6. 9
      src/core/lib/security/credentials/external/external_account_credentials.h
  7. 5
      src/core/lib/security/credentials/external/url_external_account_credentials.cc
  8. 7
      src/core/lib/security/credentials/google_default/google_default_credentials.cc
  9. 9
      src/core/lib/security/credentials/jwt/jwt_verifier.cc
  10. 24
      src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
  11. 3
      src/core/lib/security/credentials/oauth2/oauth2_credentials.h
  12. 10
      test/core/http/httpcli_test.cc
  13. 10
      test/core/http/httpscli_test.cc
  14. 17
      test/core/util/port_server_client.cc

@ -61,7 +61,6 @@ class GoogleCloud2ProdResolver : public Resolver {
grpc_error_handle error) = 0;
RefCountedPtr<GoogleCloud2ProdResolver> resolver_;
grpc_httpcli_context context_;
grpc_httpcli_response response_;
grpc_closure on_done_;
std::atomic<bool> on_done_called_{false};
@ -115,7 +114,6 @@ GoogleCloud2ProdResolver::MetadataQuery::MetadataQuery(
RefCountedPtr<GoogleCloud2ProdResolver> resolver, const char* path,
grpc_polling_entity* pollent)
: resolver_(std::move(resolver)) {
grpc_httpcli_context_init(&context_);
// Start HTTP request.
GRPC_CLOSURE_INIT(&on_done_, OnHttpRequestDone, this, nullptr);
Ref().release(); // Ref held by callback.
@ -128,13 +126,12 @@ GoogleCloud2ProdResolver::MetadataQuery::MetadataQuery(
request.http.hdr_count = 1;
request.http.hdrs = &header;
// TODO(ctiller): share the quota from whomever instantiates this!
grpc_httpcli_get(&context_, pollent, ResourceQuota::Default(), &request,
grpc_httpcli_get(pollent, ResourceQuota::Default(), &request,
ExecCtx::Get()->Now() + 10000, // 10s timeout
&on_done_, &response_);
}
GoogleCloud2ProdResolver::MetadataQuery::~MetadataQuery() {
grpc_httpcli_context_destroy(&context_);
grpc_http_response_destroy(&response_);
}

@ -57,8 +57,8 @@ class InternalRequest {
ResourceQuotaRefPtr resource_quota, absl::string_view host,
absl::string_view ssl_host_override, grpc_millis deadline,
const grpc_httpcli_handshaker* handshaker,
grpc_closure* on_done, grpc_httpcli_context* context,
grpc_polling_entity* pollent, const char* name)
grpc_closure* on_done, grpc_polling_entity* pollent,
const char* name)
: request_text_(request_text),
resource_quota_(std::move(resource_quota)),
host_(host),
@ -66,8 +66,8 @@ class InternalRequest {
deadline_(deadline),
handshaker_(handshaker),
on_done_(on_done),
context_(context),
pollent_(pollent) {
pollent_(pollent),
pollset_set_(grpc_pollset_set_create()) {
grpc_http_parser_init(&parser_, GRPC_HTTP_RESPONSE, response);
grpc_slice_buffer_init(&incoming_);
grpc_slice_buffer_init(&outgoing_);
@ -76,9 +76,9 @@ class InternalRequest {
GRPC_CLOSURE_INIT(&on_read_, OnRead, this, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&done_write_, DoneWrite, this, grpc_schedule_on_exec_ctx);
GPR_ASSERT(pollent);
grpc_polling_entity_add_to_pollset_set(pollent_, context->pollset_set);
grpc_polling_entity_add_to_pollset_set(pollent, pollset_set_);
dns_request_ = GetDNSResolver()->ResolveName(
host_.c_str(), handshaker_->default_port, context_->pollset_set,
host_.c_str(), handshaker_->default_port, pollset_set_,
absl::bind_front(&InternalRequest::OnResolved, this));
dns_request_->Start();
}
@ -93,11 +93,12 @@ class InternalRequest {
grpc_slice_buffer_destroy_internal(&incoming_);
grpc_slice_buffer_destroy_internal(&outgoing_);
GRPC_ERROR_UNREF(overall_error_);
grpc_pollset_set_destroy(pollset_set_);
}
private:
void Finish(grpc_error_handle error) {
grpc_polling_entity_del_from_pollset_set(pollent_, context_->pollset_set);
grpc_polling_entity_del_from_pollset_set(pollent_, pollset_set_);
ExecCtx::Run(DEBUG_LOCATION, on_done_, error);
delete this;
}
@ -210,8 +211,8 @@ class InternalRequest {
auto* args = CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(&channel_args);
grpc_tcp_client_connect(&connected_, &ep_, context_->pollset_set, args,
addr, deadline_);
grpc_tcp_client_connect(&connected_, &ep_, pollset_set_, args, addr,
deadline_);
grpc_channel_args_destroy(args);
}
@ -239,8 +240,8 @@ class InternalRequest {
int have_read_byte_ = 0;
const grpc_httpcli_handshaker* handshaker_;
grpc_closure* on_done_;
grpc_httpcli_context* context_;
grpc_polling_entity* pollent_;
grpc_pollset_set* pollset_set_;
grpc_iomgr_object iomgr_obj_;
grpc_slice_buffer incoming_;
grpc_slice_buffer outgoing_;
@ -267,17 +268,8 @@ static void plaintext_handshake(void* arg, grpc_endpoint* endpoint,
const grpc_httpcli_handshaker grpc_httpcli_plaintext = {"http",
plaintext_handshake};
void grpc_httpcli_context_init(grpc_httpcli_context* context) {
context->pollset_set = grpc_pollset_set_create();
}
void grpc_httpcli_context_destroy(grpc_httpcli_context* context) {
grpc_pollset_set_destroy(context->pollset_set);
}
static void internal_request_begin(
grpc_httpcli_context* context, grpc_polling_entity* pollent,
grpc_core::ResourceQuotaRefPtr resource_quota,
grpc_polling_entity* pollent, grpc_core::ResourceQuotaRefPtr resource_quota,
const grpc_httpcli_request* request, grpc_millis deadline,
grpc_closure* on_done, grpc_httpcli_response* response, const char* name,
const grpc_slice& request_text) {
@ -285,11 +277,10 @@ static void internal_request_begin(
request_text, response, std::move(resource_quota), request->host,
request->ssl_host_override, deadline,
request->handshaker ? request->handshaker : &grpc_httpcli_plaintext,
on_done, context, pollent, name);
on_done, pollent, name);
}
void grpc_httpcli_get(grpc_httpcli_context* context,
grpc_polling_entity* pollent,
void grpc_httpcli_get(grpc_polling_entity* pollent,
grpc_core::ResourceQuotaRefPtr resource_quota,
const grpc_httpcli_request* request, grpc_millis deadline,
grpc_closure* on_done, grpc_httpcli_response* response) {
@ -298,13 +289,12 @@ void grpc_httpcli_get(grpc_httpcli_context* context,
}
std::string name =
absl::StrFormat("HTTP:GET:%s:%s", request->host, request->http.path);
internal_request_begin(context, pollent, std::move(resource_quota), request,
deadline, on_done, response, name.c_str(),
internal_request_begin(pollent, std::move(resource_quota), request, deadline,
on_done, response, name.c_str(),
grpc_httpcli_format_get_request(request));
}
void grpc_httpcli_post(grpc_httpcli_context* context,
grpc_polling_entity* pollent,
void grpc_httpcli_post(grpc_polling_entity* pollent,
grpc_core::ResourceQuotaRefPtr resource_quota,
const grpc_httpcli_request* request,
const char* body_bytes, size_t body_size,
@ -317,8 +307,8 @@ void grpc_httpcli_post(grpc_httpcli_context* context,
std::string name =
absl::StrFormat("HTTP:POST:%s:%s", request->host, request->http.path);
internal_request_begin(
context, pollent, std::move(resource_quota), request, deadline, on_done,
response, name.c_str(),
pollent, std::move(resource_quota), request, deadline, on_done, response,
name.c_str(),
grpc_httpcli_format_post_request(request, body_bytes, body_size));
}

@ -35,13 +35,8 @@
/* User agent this library reports */
#define GRPC_HTTPCLI_USER_AGENT "grpc-httpcli/0.0"
/* Tracks in-progress http requests
TODO(ctiller): allow caching and capturing multiple requests for the
/* TODO(ctiller): allow caching and capturing multiple requests for the
same content and combining them */
typedef struct grpc_httpcli_context {
grpc_pollset_set* pollset_set;
} grpc_httpcli_context;
struct grpc_httpcli_handshaker {
const char* default_port;
void (*handshake)(void* arg, grpc_endpoint* endpoint, const char* host,
@ -68,11 +63,7 @@ typedef struct grpc_httpcli_request {
/* Expose the parser response type as a httpcli response too */
typedef struct grpc_http_response grpc_httpcli_response;
void grpc_httpcli_context_init(grpc_httpcli_context* context);
void grpc_httpcli_context_destroy(grpc_httpcli_context* context);
/* Asynchronously perform a HTTP GET.
'context' specifies the http context under which to do the get
'pollent' indicates a grpc_polling_entity that is interested in the result
of the get - work on this entity may be used to progress the get
operation
@ -82,14 +73,12 @@ void grpc_httpcli_context_destroy(grpc_httpcli_context* context);
can be destroyed once the call returns 'deadline' contains a deadline for the
request (or gpr_inf_future)
'on_response' is a callback to report results to */
void grpc_httpcli_get(grpc_httpcli_context* context,
grpc_polling_entity* pollent,
void grpc_httpcli_get(grpc_polling_entity* pollent,
grpc_core::ResourceQuotaRefPtr resource_quota,
const grpc_httpcli_request* request, grpc_millis deadline,
grpc_closure* on_done, grpc_httpcli_response* response);
/* Asynchronously perform a HTTP POST.
'context' specifies the http context under which to do the post
'pollent' indicates a grpc_polling_entity that is interested in the result
of the post - work on this entity may be used to progress the post
operation
@ -104,8 +93,7 @@ void grpc_httpcli_get(grpc_httpcli_context* context,
lifetime of the request
'on_response' is a callback to report results to
Does not support ?var1=val1&var2=val2 in the path. */
void grpc_httpcli_post(grpc_httpcli_context* context,
grpc_polling_entity* pollent,
void grpc_httpcli_post(grpc_polling_entity* pollent,
grpc_core::ResourceQuotaRefPtr resource_quota,
const grpc_httpcli_request* request,
const char* body_bytes, size_t body_size,

@ -169,9 +169,8 @@ void AwsExternalAccountCredentials::RetrieveRegion() {
grpc_http_response_destroy(&ctx_->response);
ctx_->response = {};
GRPC_CLOSURE_INIT(&ctx_->closure, OnRetrieveRegion, this, nullptr);
grpc_httpcli_get(ctx_->httpcli_context, ctx_->pollent,
ResourceQuota::Default(), &request, ctx_->deadline,
&ctx_->closure, &ctx_->response);
grpc_httpcli_get(ctx_->pollent, ResourceQuota::Default(), &request,
ctx_->deadline, &ctx_->closure, &ctx_->response);
grpc_http_request_destroy(&request.http);
}
@ -217,9 +216,8 @@ void AwsExternalAccountCredentials::RetrieveRoleName() {
ctx_->response = {};
GRPC_CLOSURE_INIT(&ctx_->closure, OnRetrieveRoleName, this, nullptr);
// TODO(ctiller): use the caller's resource quota.
grpc_httpcli_get(ctx_->httpcli_context, ctx_->pollent,
ResourceQuota::Default(), &request, ctx_->deadline,
&ctx_->closure, &ctx_->response);
grpc_httpcli_get(ctx_->pollent, ResourceQuota::Default(), &request,
ctx_->deadline, &ctx_->closure, &ctx_->response);
grpc_http_request_destroy(&request.http);
}
@ -277,9 +275,8 @@ void AwsExternalAccountCredentials::RetrieveSigningKeys() {
ctx_->response = {};
GRPC_CLOSURE_INIT(&ctx_->closure, OnRetrieveSigningKeys, this, nullptr);
// TODO(ctiller): use the caller's resource quota.
grpc_httpcli_get(ctx_->httpcli_context, ctx_->pollent,
ResourceQuota::Default(), &request, ctx_->deadline,
&ctx_->closure, &ctx_->response);
grpc_httpcli_get(ctx_->pollent, ResourceQuota::Default(), &request,
ctx_->deadline, &ctx_->closure, &ctx_->response);
grpc_http_request_destroy(&request.http);
}

@ -237,10 +237,10 @@ std::string ExternalAccountCredentials::debug_string() {
// down.
void ExternalAccountCredentials::fetch_oauth2(
grpc_credentials_metadata_request* metadata_req,
grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent,
grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
grpc_polling_entity* pollent, grpc_iomgr_cb_func response_cb,
grpc_millis deadline) {
GPR_ASSERT(ctx_ == nullptr);
ctx_ = new HTTPRequestContext(httpcli_context, pollent, deadline);
ctx_ = new HTTPRequestContext(pollent, deadline);
metadata_req_ = metadata_req;
response_cb_ = response_cb;
auto cb = [this](std::string token, grpc_error_handle error) {
@ -326,9 +326,8 @@ void ExternalAccountCredentials::ExchangeToken(
grpc_http_response_destroy(&ctx_->response);
ctx_->response = {};
GRPC_CLOSURE_INIT(&ctx_->closure, OnExchangeToken, this, nullptr);
grpc_httpcli_post(ctx_->httpcli_context, ctx_->pollent,
ResourceQuota::Default(), &request, body.c_str(),
body.size(), ctx_->deadline, &ctx_->closure,
grpc_httpcli_post(ctx_->pollent, ResourceQuota::Default(), &request,
body.c_str(), body.size(), ctx_->deadline, &ctx_->closure,
&ctx_->response);
grpc_http_request_destroy(&request.http);
}
@ -412,9 +411,8 @@ void ExternalAccountCredentials::ImpersenateServiceAccount() {
ctx_->response = {};
GRPC_CLOSURE_INIT(&ctx_->closure, OnImpersenateServiceAccount, this, nullptr);
// TODO(ctiller): Use the callers resource quota.
grpc_httpcli_post(ctx_->httpcli_context, ctx_->pollent,
ResourceQuota::Default(), &request, body.c_str(),
body.size(), ctx_->deadline, &ctx_->closure,
grpc_httpcli_post(ctx_->pollent, ResourceQuota::Default(), &request,
body.c_str(), body.size(), ctx_->deadline, &ctx_->closure,
&ctx_->response);
grpc_http_request_destroy(&request.http);
}

@ -61,16 +61,12 @@ class ExternalAccountCredentials
// This is a helper struct to pass information between multiple callback based
// asynchronous calls.
struct HTTPRequestContext {
HTTPRequestContext(grpc_httpcli_context* httpcli_context,
grpc_polling_entity* pollent, grpc_millis deadline)
: httpcli_context(httpcli_context),
pollent(pollent),
deadline(deadline) {}
HTTPRequestContext(grpc_polling_entity* pollent, grpc_millis deadline)
: pollent(pollent), deadline(deadline) {}
~HTTPRequestContext() { grpc_http_response_destroy(&response); }
// Contextual parameters passed from
// grpc_oauth2_token_fetcher_credentials::fetch_oauth2().
grpc_httpcli_context* httpcli_context;
grpc_polling_entity* pollent;
grpc_millis deadline;
@ -92,7 +88,6 @@ class ExternalAccountCredentials
// This method implements the common token fetch logic and it will be called
// when grpc_oauth2_token_fetcher_credentials request a new access token.
void fetch_oauth2(grpc_credentials_metadata_request* req,
grpc_httpcli_context* httpcli_context,
grpc_polling_entity* pollent, grpc_iomgr_cb_func cb,
grpc_millis deadline) override;

@ -142,9 +142,8 @@ void UrlExternalAccountCredentials::RetrieveSubjectToken(
grpc_http_response_destroy(&ctx_->response);
ctx_->response = {};
GRPC_CLOSURE_INIT(&ctx_->closure, OnRetrieveSubjectToken, this, nullptr);
grpc_httpcli_get(ctx_->httpcli_context, ctx_->pollent,
ResourceQuota::Default(), &request, ctx_->deadline,
&ctx_->closure, &ctx_->response);
grpc_httpcli_get(ctx_->pollent, ResourceQuota::Default(), &request,
ctx_->deadline, &ctx_->closure, &ctx_->response);
grpc_http_request_destroy(&request.http);
}

@ -172,7 +172,6 @@ static void destroy_pollset(void* p, grpc_error_handle /*e*/) {
static int is_metadata_server_reachable() {
metadata_server_detector detector;
grpc_httpcli_request request;
grpc_httpcli_context context;
grpc_closure destroy_closure;
/* The http call is local. If it takes more than one sec, it is for sure not
on compute engine. */
@ -186,10 +185,9 @@ static int is_metadata_server_reachable() {
memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = const_cast<char*>(GRPC_COMPUTE_ENGINE_DETECTION_HOST);
request.http.path = const_cast<char*>("/");
grpc_httpcli_context_init(&context);
grpc_httpcli_get(
&context, &detector.pollent, grpc_core::ResourceQuota::Default(),
&request, grpc_core::ExecCtx::Get()->Now() + max_detection_delay,
&detector.pollent, grpc_core::ResourceQuota::Default(), &request,
grpc_core::ExecCtx::Get()->Now() + max_detection_delay,
GRPC_CLOSURE_CREATE(on_metadata_server_detection_http_response, &detector,
grpc_schedule_on_exec_ctx),
&detector.response);
@ -208,7 +206,6 @@ static int is_metadata_server_reachable() {
}
}
gpr_mu_unlock(g_polling_mu);
grpc_httpcli_context_destroy(&context);
GRPC_CLOSURE_INIT(&destroy_closure, destroy_pollset,
grpc_polling_entity_pollset(&detector.pollent),
grpc_schedule_on_exec_ctx);

@ -395,7 +395,6 @@ struct grpc_jwt_verifier {
email_key_mapping* mappings;
size_t num_mappings; /* Should be very few, linear search ok. */
size_t allocated_mappings;
grpc_httpcli_context http_ctx;
};
static Json json_from_http(const grpc_httpcli_response* response) {
@ -698,8 +697,7 @@ static void on_openid_config_retrieved(void* user_data,
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
grpc_httpcli_get(
&ctx->verifier->http_ctx, &ctx->pollent,
grpc_core::ResourceQuota::Default(), &req,
&ctx->pollent, grpc_core::ResourceQuota::Default(), &req,
grpc_core::ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay,
GRPC_CLOSURE_CREATE(on_keys_retrieved, ctx, grpc_schedule_on_exec_ctx),
&ctx->responses[HTTP_RESPONSE_KEYS]);
@ -822,8 +820,7 @@ static void retrieve_key_and_verify(verifier_cb_ctx* ctx) {
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
grpc_httpcli_get(
&ctx->verifier->http_ctx, &ctx->pollent,
grpc_core::ResourceQuota::Default(), &req,
&ctx->pollent, grpc_core::ResourceQuota::Default(), &req,
grpc_core::ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay, http_cb,
&ctx->responses[rsp_idx]);
gpr_free(req.host);
@ -884,7 +881,6 @@ grpc_jwt_verifier* grpc_jwt_verifier_create(
const grpc_jwt_verifier_email_domain_key_url_mapping* mappings,
size_t num_mappings) {
grpc_jwt_verifier* v = grpc_core::Zalloc<grpc_jwt_verifier>();
grpc_httpcli_context_init(&v->http_ctx);
/* We know at least of one mapping. */
v->allocated_mappings = 1 + num_mappings;
@ -906,7 +902,6 @@ grpc_jwt_verifier* grpc_jwt_verifier_create(
void grpc_jwt_verifier_destroy(grpc_jwt_verifier* v) {
size_t i;
if (v == nullptr) return;
grpc_httpcli_context_destroy(&v->http_ctx);
if (v->mappings != nullptr) {
for (i = 0; i < v->num_mappings; i++) {
gpr_free(v->mappings[i].email_domain);

@ -129,7 +129,6 @@ grpc_oauth2_token_fetcher_credentials::
~grpc_oauth2_token_fetcher_credentials() {
gpr_mu_destroy(&mu_);
grpc_pollset_set_destroy(grpc_polling_entity_pollset_set(&pollent_));
grpc_httpcli_context_destroy(&httpcli_context_);
}
grpc_credentials_status
@ -317,8 +316,7 @@ bool grpc_oauth2_token_fetcher_credentials::get_request_metadata(
if (start_fetch) {
Ref().release();
fetch_oauth2(grpc_credentials_metadata_request_create(this->Ref()),
&httpcli_context_, &pollent_,
on_oauth2_token_fetcher_http_response,
&pollent_, on_oauth2_token_fetcher_http_response,
grpc_core::ExecCtx::Get()->Now() + refresh_threshold);
}
return false;
@ -357,7 +355,6 @@ grpc_oauth2_token_fetcher_credentials::grpc_oauth2_token_fetcher_credentials()
pollent_(grpc_polling_entity_create_from_pollset_set(
grpc_pollset_set_create())) {
gpr_mu_init(&mu_);
grpc_httpcli_context_init(&httpcli_context_);
}
std::string grpc_oauth2_token_fetcher_credentials::debug_string() {
@ -378,7 +375,6 @@ class grpc_compute_engine_token_fetcher_credentials
protected:
void fetch_oauth2(grpc_credentials_metadata_request* metadata_req,
grpc_httpcli_context* http_context,
grpc_polling_entity* pollent,
grpc_iomgr_cb_func response_cb,
grpc_millis deadline) override {
@ -394,8 +390,8 @@ class grpc_compute_engine_token_fetcher_credentials
/* TODO(ctiller): Carry the memory quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
grpc_httpcli_get(http_context, pollent, grpc_core::ResourceQuota::Default(),
&request, deadline,
grpc_httpcli_get(pollent, grpc_core::ResourceQuota::Default(), &request,
deadline,
GRPC_CLOSURE_INIT(&http_get_cb_closure_, response_cb,
metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
@ -434,8 +430,8 @@ grpc_google_refresh_token_credentials::
void grpc_google_refresh_token_credentials::fetch_oauth2(
grpc_credentials_metadata_request* metadata_req,
grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent,
grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
grpc_polling_entity* pollent, grpc_iomgr_cb_func response_cb,
grpc_millis deadline) {
grpc_http_header header = {
const_cast<char*>("Content-Type"),
const_cast<char*>("application/x-www-form-urlencoded")};
@ -452,9 +448,8 @@ void grpc_google_refresh_token_credentials::fetch_oauth2(
/* TODO(ctiller): Carry the memory quota in ctx and share it with the host
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
grpc_httpcli_post(httpcli_context, pollent,
grpc_core::ResourceQuota::Default(), &request, body.c_str(),
body.size(), deadline,
grpc_httpcli_post(pollent, grpc_core::ResourceQuota::Default(), &request,
body.c_str(), body.size(), deadline,
GRPC_CLOSURE_INIT(&http_post_cb_closure_, response_cb,
metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
@ -555,7 +550,6 @@ class StsTokenFetcherCredentials
private:
void fetch_oauth2(grpc_credentials_metadata_request* metadata_req,
grpc_httpcli_context* http_context,
grpc_polling_entity* pollent,
grpc_iomgr_cb_func response_cb,
grpc_millis deadline) override {
@ -583,8 +577,8 @@ class StsTokenFetcherCredentials
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
grpc_httpcli_post(
http_context, pollent, ResourceQuota::Default(), &request, body,
body_length, deadline,
pollent, ResourceQuota::Default(), &request, body, body_length,
deadline,
GRPC_CLOSURE_INIT(&http_post_cb_closure_, response_cb, metadata_req,
grpc_schedule_on_exec_ctx),
&metadata_req->response);

@ -91,7 +91,6 @@ class grpc_oauth2_token_fetcher_credentials : public grpc_call_credentials {
protected:
virtual void fetch_oauth2(grpc_credentials_metadata_request* req,
grpc_httpcli_context* httpcli_context,
grpc_polling_entity* pollent, grpc_iomgr_cb_func cb,
grpc_millis deadline) = 0;
@ -101,7 +100,6 @@ class grpc_oauth2_token_fetcher_credentials : public grpc_call_credentials {
gpr_timespec token_expiration_;
bool token_fetch_pending_ = false;
grpc_oauth2_pending_get_request_metadata* pending_requests_ = nullptr;
grpc_httpcli_context httpcli_context_;
grpc_polling_entity pollent_;
};
@ -121,7 +119,6 @@ class grpc_google_refresh_token_credentials final
protected:
void fetch_oauth2(grpc_credentials_metadata_request* req,
grpc_httpcli_context* httpcli_context,
grpc_polling_entity* pollent, grpc_iomgr_cb_func cb,
grpc_millis deadline) override;

@ -32,7 +32,6 @@
#include "test/core/util/test_config.h"
static int g_done = 0;
static grpc_httpcli_context g_context;
static gpr_mu* g_mu;
static grpc_polling_entity g_pops;
@ -79,8 +78,7 @@ static void test_get(int port) {
grpc_http_response response;
response = {};
grpc_httpcli_get(
&g_context, &g_pops, grpc_core::ResourceQuota::Default(), &req,
n_seconds_time(15),
&g_pops, grpc_core::ResourceQuota::Default(), &req, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
gpr_mu_lock(g_mu);
@ -117,8 +115,8 @@ static void test_post(int port) {
grpc_http_response response;
response = {};
grpc_httpcli_post(
&g_context, &g_pops, grpc_core::ResourceQuota::Default(), &req, "hello",
5, n_seconds_time(15),
&g_pops, grpc_core::ResourceQuota::Default(), &req, "hello", 5,
n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
gpr_mu_lock(g_mu);
@ -193,7 +191,6 @@ int main(int argc, char** argv) {
gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(5, GPR_TIMESPAN)));
grpc_httpcli_context_init(&g_context);
grpc_pollset* pollset =
static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &g_mu);
@ -202,7 +199,6 @@ int main(int argc, char** argv) {
test_get(port);
test_post(port);
grpc_httpcli_context_destroy(&g_context);
GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);

@ -34,7 +34,6 @@
#include "test/core/util/test_config.h"
static int g_done = 0;
static grpc_httpcli_context g_context;
static gpr_mu* g_mu;
static grpc_polling_entity g_pops;
@ -82,8 +81,7 @@ static void test_get(int port) {
grpc_http_response response;
response = {};
grpc_httpcli_get(
&g_context, &g_pops, grpc_core::ResourceQuota::Default(), &req,
n_seconds_time(15),
&g_pops, grpc_core::ResourceQuota::Default(), &req, n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
gpr_mu_lock(g_mu);
@ -121,8 +119,8 @@ static void test_post(int port) {
grpc_http_response response;
response = {};
grpc_httpcli_post(
&g_context, &g_pops, grpc_core::ResourceQuota::Default(), &req, "hello",
5, n_seconds_time(15),
&g_pops, grpc_core::ResourceQuota::Default(), &req, "hello", 5,
n_seconds_time(15),
GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx),
&response);
gpr_mu_lock(g_mu);
@ -201,7 +199,6 @@ int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(argc, argv);
grpc_init();
grpc_httpcli_context_init(&g_context);
grpc_pollset* pollset =
static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &g_mu);
@ -212,7 +209,6 @@ int main(int argc, char** argv) {
{
grpc_core::ExecCtx exec_ctx;
grpc_httpcli_context_destroy(&g_context);
GRPC_CLOSURE_INIT(&destroyed, destroy_pops, &g_pops,
grpc_schedule_on_exec_ctx);
grpc_pollset_shutdown(grpc_polling_entity_pollset(&g_pops), &destroyed);

@ -58,7 +58,6 @@ static void freed_port_from_server(void* arg, grpc_error_handle /*error*/) {
}
void grpc_free_port_using_server(int port) {
grpc_httpcli_context context;
grpc_httpcli_request req;
grpc_httpcli_response rsp;
freereq pr;
@ -84,9 +83,7 @@ void grpc_free_port_using_server(int port) {
gpr_asprintf(&path, "/drop/%d", port);
req.http.path = path;
grpc_httpcli_context_init(&context);
grpc_httpcli_get(&context, &pr.pops, grpc_core::ResourceQuota::Default(),
&req,
grpc_httpcli_get(&pr.pops, grpc_core::ResourceQuota::Default(), &req,
grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(freed_port_from_server, &pr,
grpc_schedule_on_exec_ctx),
@ -105,7 +102,6 @@ void grpc_free_port_using_server(int port) {
}
gpr_mu_unlock(pr.mu);
grpc_httpcli_context_destroy(&context);
grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
@ -121,7 +117,6 @@ typedef struct portreq {
int port = 0;
int retries = 0;
char* server = nullptr;
grpc_httpcli_context* ctx = nullptr;
grpc_httpcli_response response = {};
} portreq;
@ -166,8 +161,7 @@ static void got_port_from_server(void* arg, grpc_error_handle error) {
req.http.path = const_cast<char*>("/get");
grpc_http_response_destroy(&pr->response);
pr->response = {};
grpc_httpcli_get(pr->ctx, &pr->pops, grpc_core::ResourceQuota::Default(),
&req,
grpc_httpcli_get(&pr->pops, grpc_core::ResourceQuota::Default(), &req,
grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(got_port_from_server, pr,
grpc_schedule_on_exec_ctx),
@ -190,7 +184,6 @@ static void got_port_from_server(void* arg, grpc_error_handle error) {
}
int grpc_pick_port_using_server(void) {
grpc_httpcli_context context;
grpc_httpcli_request req;
portreq pr;
grpc_closure* shutdown_closure;
@ -208,14 +201,11 @@ int grpc_pick_port_using_server(void) {
grpc_schedule_on_exec_ctx);
pr.port = -1;
pr.server = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS);
pr.ctx = &context;
req.host = const_cast<char*>(GRPC_PORT_SERVER_ADDRESS);
req.http.path = const_cast<char*>("/get");
grpc_httpcli_context_init(&context);
grpc_httpcli_get(&context, &pr.pops, grpc_core::ResourceQuota::Default(),
&req,
grpc_httpcli_get(&pr.pops, grpc_core::ResourceQuota::Default(), &req,
grpc_core::ExecCtx::Get()->Now() + 30 * GPR_MS_PER_SEC,
GRPC_CLOSURE_CREATE(got_port_from_server, &pr,
grpc_schedule_on_exec_ctx),
@ -235,7 +225,6 @@ int grpc_pick_port_using_server(void) {
gpr_mu_unlock(pr.mu);
grpc_http_response_destroy(&pr.response);
grpc_httpcli_context_destroy(&context);
grpc_pollset_shutdown(grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);

Loading…
Cancel
Save