aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/channel/client_setup.c
diff options
context:
space:
mode:
authorGravatar ctiller <ctiller@google.com>2014-12-09 14:39:16 -0800
committerGravatar Jan Tattermusch <jtattermusch@google.com>2014-12-09 16:20:55 -0800
commit18b49ab914ea5a57f22ed6d77520cd7d4372749b (patch)
treec2ec5971eebd10e3ef52c0c084c797b8d06bb267 /src/core/channel/client_setup.c
parent98bffb779b8c47f4d76c72c7807d9f1b1074a795 (diff)
Introducing iomgr.
Move eventmanager and platform dependent endpoint functionality into a single library called 'iomgr'. This is primarily to prepare for a Windows port - where posix socket semantics lead to poor quality code. Mostly this is a code movement CL, with some small changes to help prepare the way for porting: - em style fd objects can only be held internally in iomgr, and own their memory - added grpc_iomgr_create_endpoint_pair() to accomodate the common pattern of creating a tcp endpoint from the output of socketpair - this will help keep our tests portable - separated em alarm interface into a separate file, as this part of event manager is needed higher up the stack - made the eventmanager bits a true singleton, simplifying API's across the stack as there's no longer a reason to carry a pointer there. Initial design document is here: https://docs.google.com/document/d/1VmafcHvvrP5kwtQkz84R5yXF7u7fW-9Pn0bkSUQHDt8/edit?disco=AAAAARNByxg Change on 2014/12/09 by ctiller <ctiller@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=81716456
Diffstat (limited to 'src/core/channel/client_setup.c')
-rw-r--r--src/core/channel/client_setup.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/core/channel/client_setup.c b/src/core/channel/client_setup.c
index ea256706fd..29fe915add 100644
--- a/src/core/channel/client_setup.c
+++ b/src/core/channel/client_setup.c
@@ -34,6 +34,7 @@
#include "src/core/channel/client_setup.h"
#include "src/core/channel/channel_args.h"
#include "src/core/channel/channel_stack.h"
+#include "src/core/iomgr/alarm.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
@@ -45,8 +46,7 @@ struct grpc_client_setup {
void *user_data;
grpc_channel_args *args;
grpc_mdctx *mdctx;
- grpc_em *em;
- grpc_em_alarm backoff_alarm;
+ grpc_alarm backoff_alarm;
gpr_timespec current_backoff_interval;
int in_alarm;
@@ -115,7 +115,7 @@ static void setup_cancel(grpc_transport_setup *sp) {
/* effectively cancels the current request (if any) */
s->active_request = NULL;
if (s->in_alarm) {
- grpc_em_alarm_cancel(&s->backoff_alarm);
+ grpc_alarm_cancel(&s->backoff_alarm);
}
if (--s->refs == 0) {
gpr_mu_unlock(&s->mu);
@@ -133,7 +133,7 @@ void grpc_client_setup_create_and_attach(
grpc_channel_stack *newly_minted_channel, const grpc_channel_args *args,
grpc_mdctx *mdctx,
void (*initiate)(void *user_data, grpc_client_setup_request *request),
- void (*done)(void *user_data), void *user_data, grpc_em *em) {
+ void (*done)(void *user_data), void *user_data) {
grpc_client_setup *s = gpr_malloc(sizeof(grpc_client_setup));
s->base.vtable = &setup_vtable;
@@ -143,7 +143,6 @@ void grpc_client_setup_create_and_attach(
s->initiate = initiate;
s->done = done;
s->user_data = user_data;
- s->em = em;
s->active_request = NULL;
s->args = grpc_channel_args_copy(args);
s->current_backoff_interval = gpr_time_from_micros(1000000);
@@ -164,7 +163,7 @@ int grpc_client_setup_request_should_continue(grpc_client_setup_request *r) {
}
static void backoff_alarm_done(void *arg /* grpc_client_setup */,
- grpc_em_cb_status status) {
+ grpc_iomgr_cb_status status) {
grpc_client_setup *s = arg;
grpc_client_setup_request *r = gpr_malloc(sizeof(grpc_client_setup_request));
r->setup = s;
@@ -215,9 +214,9 @@ void grpc_client_setup_request_finish(grpc_client_setup_request *r,
gpr_timespec max_backoff = gpr_time_from_micros(120000000);
GPR_ASSERT(!s->in_alarm);
s->in_alarm = 1;
- grpc_em_alarm_init(&s->backoff_alarm, s->em, backoff_alarm_done, s);
- grpc_em_alarm_add(&s->backoff_alarm,
- gpr_time_add(s->current_backoff_interval, gpr_now()));
+ grpc_alarm_init(&s->backoff_alarm, backoff_alarm_done, s);
+ grpc_alarm_add(&s->backoff_alarm,
+ gpr_time_add(s->current_backoff_interval, gpr_now()));
s->current_backoff_interval =
gpr_time_add(s->current_backoff_interval, s->current_backoff_interval);
if (gpr_time_cmp(s->current_backoff_interval, max_backoff) > 0) {