aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/client_config
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-10-02 16:59:50 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-10-02 16:59:50 -0700
commit8a50de7e65a9121eb676bc0802c798f1886b35c7 (patch)
treeec8d7c68782e5fca84f0b0bb8e478ddfa6b3af85 /src/core/client_config
parent7cc27777b45b531320427a5cf93a2938e68c5299 (diff)
parent3b147818e3aef9d77cce55e96447b568558f2e62 (diff)
Merge pull request #3586 from dgquintas/conn_state_watcher_plucking
Added subchannel ability to unsubscribe to connectivity state changes.
Diffstat (limited to 'src/core/client_config')
-rw-r--r--src/core/client_config/subchannel.c11
-rw-r--r--src/core/client_config/subchannel.h15
2 files changed, 22 insertions, 4 deletions
diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c
index e77311f4f8..a2c521a20d 100644
--- a/src/core/client_config/subchannel.c
+++ b/src/core/client_config/subchannel.c
@@ -413,6 +413,17 @@ void grpc_subchannel_notify_on_state_change(grpc_exec_ctx *exec_ctx,
}
}
+int grpc_subchannel_state_change_unsubscribe(grpc_exec_ctx *exec_ctx,
+ grpc_subchannel *c,
+ grpc_closure *subscribed_notify) {
+ int success;
+ gpr_mu_lock(&c->mu);
+ success = grpc_connectivity_state_change_unsubscribe(
+ exec_ctx, &c->state_tracker, subscribed_notify);
+ gpr_mu_unlock(&c->mu);
+ return success;
+}
+
void grpc_subchannel_process_transport_op(grpc_exec_ctx *exec_ctx,
grpc_subchannel *c,
grpc_transport_op *op) {
diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h
index 2af3ce9e56..03e7cd0590 100644
--- a/src/core/client_config/subchannel.h
+++ b/src/core/client_config/subchannel.h
@@ -64,13 +64,13 @@ typedef struct grpc_subchannel_args grpc_subchannel_args;
#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS
#endif
-void grpc_subchannel_ref(grpc_subchannel *channel
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_ref(
+ grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_unref(grpc_exec_ctx *exec_ctx,
grpc_subchannel *channel
GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
-void grpc_subchannel_call_ref(grpc_subchannel_call *call
- GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
+void grpc_subchannel_call_ref(
+ grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_call_unref(grpc_exec_ctx *exec_ctx,
grpc_subchannel_call *call
GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
@@ -98,6 +98,13 @@ void grpc_subchannel_notify_on_state_change(grpc_exec_ctx *exec_ctx,
grpc_connectivity_state *state,
grpc_closure *notify);
+/** Remove \a subscribed_notify from the list of closures to be called on a
+ * state change if present, returning 1. Otherwise, nothing is done and return
+ * 0. */
+int grpc_subchannel_state_change_unsubscribe(grpc_exec_ctx *exec_ctx,
+ grpc_subchannel *channel,
+ grpc_closure *subscribed_notify);
+
/** express interest in \a channel's activities through \a pollset. */
void grpc_subchannel_add_interested_party(grpc_exec_ctx *exec_ctx,
grpc_subchannel *channel,