aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/client_config
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-09-15 08:20:20 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-09-15 08:20:20 -0700
commit131f6edafa1a281604fffc24019dcb99134eec9f (patch)
treea9d07123c1f2abbed609eba38411bba40520cd32 /src/core/client_config
parent7dc34ac7a057abba51a38fb7f6a73ee827933e70 (diff)
Fix memory leak
Diffstat (limited to 'src/core/client_config')
-rw-r--r--src/core/client_config/connector.c4
-rw-r--r--src/core/client_config/connector.h6
-rw-r--r--src/core/client_config/subchannel.c4
-rw-r--r--src/core/client_config/subchannel.h1
4 files changed, 15 insertions, 0 deletions
diff --git a/src/core/client_config/connector.c b/src/core/client_config/connector.c
index a8cd5fc149..c1e583e4a5 100644
--- a/src/core/client_config/connector.c
+++ b/src/core/client_config/connector.c
@@ -47,3 +47,7 @@ void grpc_connector_connect(grpc_connector *connector,
grpc_iomgr_closure *notify) {
connector->vtable->connect(connector, in_args, out_args, notify);
}
+
+void grpc_connector_shutdown(grpc_connector *connector) {
+ connector->vtable->shutdown(connector);
+}
diff --git a/src/core/client_config/connector.h b/src/core/client_config/connector.h
index 39f3467990..01aa716412 100644
--- a/src/core/client_config/connector.h
+++ b/src/core/client_config/connector.h
@@ -70,6 +70,9 @@ typedef struct {
struct grpc_connector_vtable {
void (*ref)(grpc_connector *connector);
void (*unref)(grpc_connector *connector);
+ /** Implementation of grpc_connector_shutdown */
+ void (*shutdown)(grpc_connector *connector);
+ /** Implementation of grpc_connector_connect */
void (*connect)(grpc_connector *connector,
const grpc_connect_in_args *in_args,
grpc_connect_out_args *out_args, grpc_iomgr_closure *notify);
@@ -77,9 +80,12 @@ struct grpc_connector_vtable {
void grpc_connector_ref(grpc_connector *connector);
void grpc_connector_unref(grpc_connector *connector);
+/** Connect using the connector: max one outstanding call at a time */
void grpc_connector_connect(grpc_connector *connector,
const grpc_connect_in_args *in_args,
grpc_connect_out_args *out_args,
grpc_iomgr_closure *notify);
+/** Cancel any pending connection */
+void grpc_connector_shutdown(grpc_connector *connector);
#endif
diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c
index ca52c75beb..876d2aa418 100644
--- a/src/core/client_config/subchannel.c
+++ b/src/core/client_config/subchannel.c
@@ -439,6 +439,10 @@ void grpc_subchannel_process_transport_op(grpc_subchannel *c,
if (cancel_alarm) {
grpc_alarm_cancel(&c->alarm);
}
+
+ if (op->disconnect) {
+ grpc_connector_shutdown(c->connector);
+ }
}
static void on_state_changed(void *p, int iomgr_success) {
diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h
index 2e36c69134..29a0b67d2d 100644
--- a/src/core/client_config/subchannel.h
+++ b/src/core/client_config/subchannel.h
@@ -43,6 +43,7 @@ typedef struct grpc_subchannel grpc_subchannel;
typedef struct grpc_subchannel_call grpc_subchannel_call;
typedef struct grpc_subchannel_args grpc_subchannel_args;
+#define GRPC_SUBCHANNEL_REFCOUNT_DEBUG
#ifdef GRPC_SUBCHANNEL_REFCOUNT_DEBUG
#define GRPC_SUBCHANNEL_REF(p, r) \
grpc_subchannel_ref((p), __FILE__, __LINE__, (r))