--- health/mcap.c | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diff --git a/health/mcap.c b/health/mcap.c index 6f1e565..ec9ea08 100644 --- a/health/mcap.c +++ b/health/mcap.c @@ -1592,6 +1592,22 @@ static void mcap_connect_mdl_cb(GIOChannel *chan, GError *conn_err, cb(mdl, conn_err, user_data); } +static void mdl_io_destroy(gpointer data) +{ + struct mcap_mdl_op_cb *con = data; + struct mcap_mdl *mdl = con->mdl; + mcap_mdl_operation_cb cb = con->cb.op; + gpointer user_data = con->user_data; + GError *err = NULL; + + g_free(con); + g_set_error(&err, MCAP_ERROR, MCAP_ERROR_FAILED, "Connection error"); + mdl->state = MDL_CLOSED; + g_io_channel_unref(mdl->dc); + mdl->dc = NULL; + cb(mdl, err, user_data); +} + gboolean mcap_connect_mdl(struct mcap_mdl *mdl, BtIOType BtType, uint16_t dcpsm, mcap_mdl_operation_cb connect_cb, @@ -1613,7 +1629,7 @@ gboolean mcap_connect_mdl(struct mcap_mdl *mdl, BtIOType BtType, /* TODO: Check if BtIOType is ERTM or Streaming before continue */ mdl->dc = bt_io_connect(BtType, mcap_connect_mdl_cb, con, - NULL, err, + mdl_io_destroy, err, BT_IO_OPT_SOURCE_BDADDR, &mdl->mcl->ms->src, BT_IO_OPT_DEST_BDADDR, &mdl->mcl->addr, BT_IO_OPT_PSM, dcpsm, -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html