diff options
author | Frédéric Danis <frederic.danis@collabora.com> | 2021-03-16 18:18:36 +0100 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-03-16 10:56:36 -0700 |
commit | 389bcb2b78a9a1502d70154bbf45bd93c2fec853 (patch) | |
tree | b6d439574b3154992dfe25130ea02997e4ddabb5 /profiles/health | |
parent | 7b18419775a14fa08f42280eb7ce061849fc0c70 (diff) | |
download | bluez-389bcb2b78a9a1502d70154bbf45bd93c2fec853.tar.gz |
profiles: Use timeout_add_seconds
Replace calls to g_timeout_add_seconds() by the timeout_add_seconds()
wrapper which takes care of 0 delay.
Diffstat (limited to 'profiles/health')
-rw-r--r-- | profiles/health/hdp.c | 16 | ||||
-rw-r--r-- | profiles/health/mcap.c | 21 |
2 files changed, 19 insertions, 18 deletions
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c index 9f906932d..6bc41946f 100644 --- a/profiles/health/hdp.c +++ b/profiles/health/hdp.c @@ -31,6 +31,7 @@ #include "src/adapter.h" #include "src/device.h" #include "src/sdpd.h" +#include "src/shared/timeout.h" #include "btio/btio.h" #include "hdp_types.h" @@ -70,7 +71,7 @@ struct hdp_tmp_dc_data { struct hdp_echo_data { gboolean echo_done; /* Is a echo was already done */ gpointer buf; /* echo packet sent */ - guint tid; /* echo timeout */ + unsigned int tid; /* echo timeout */ }; static struct hdp_channel *hdp_channel_ref(struct hdp_channel *chan) @@ -683,7 +684,7 @@ static void free_echo_data(struct hdp_echo_data *edata) return; if (edata->tid > 0) - g_source_remove(edata->tid); + timeout_remove(edata->tid); if (edata->buf != NULL) g_free(edata->buf); @@ -1524,7 +1525,7 @@ end: reply = g_dbus_create_reply(hdp_conn->msg, DBUS_TYPE_BOOLEAN, &value, DBUS_TYPE_INVALID); g_dbus_send_message(btd_get_dbus_connection(), reply); - g_source_remove(edata->tid); + timeout_remove(edata->tid); edata->tid = 0; g_free(edata->buf); edata->buf = NULL; @@ -1538,7 +1539,7 @@ end: return FALSE; } -static gboolean echo_timeout(gpointer data) +static bool echo_timeout(gpointer data) { struct hdp_channel *chan = data; GIOChannel *io; @@ -1606,10 +1607,9 @@ static void hdp_echo_connect_cb(struct mcap_mdl *mdl, GError *err, g_io_add_watch(io, G_IO_ERR | G_IO_HUP | G_IO_NVAL | G_IO_IN, check_echo, hdp_tmp_dc_data_ref(hdp_conn)); - edata->tid = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, - ECHO_TIMEOUT, echo_timeout, - hdp_channel_ref(hdp_conn->hdp_chann), - (GDestroyNotify) hdp_channel_unref); + edata->tid = timeout_add_seconds(ECHO_TIMEOUT, echo_timeout, + hdp_channel_ref(hdp_conn->hdp_chann), + (timeout_destroy_func_t) hdp_channel_unref); g_io_channel_unref(io); } diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c index 32365fd50..be13af37a 100644 --- a/profiles/health/mcap.c +++ b/profiles/health/mcap.c @@ -26,6 +26,7 @@ #include "bluetooth/l2cap.h" #include "btio/btio.h" #include "src/log.h" +#include "src/shared/timeout.h" #include "mcap.h" @@ -43,7 +44,7 @@ #define RELEASE_TIMER(__mcl) do { \ if (__mcl->tid) { \ - g_source_remove(__mcl->tid); \ + timeout_remove(__mcl->tid); \ __mcl->tid = 0; \ } \ } while(0) @@ -483,7 +484,7 @@ static int compare_mdl(gconstpointer a, gconstpointer b) return 1; } -static gboolean wait_response_timer(gpointer data) +static bool wait_response_timer(gpointer data) { struct mcap_mcl *mcl = data; @@ -549,8 +550,8 @@ gboolean mcap_create_mdl(struct mcap_mcl *mcl, mcl->mdls = g_slist_insert_sorted(mcl->mdls, mcap_mdl_ref(mdl), compare_mdl); - mcl->tid = g_timeout_add_seconds(RESPONSE_TIMER, wait_response_timer, - mcl); + mcl->tid = timeout_add_seconds(RESPONSE_TIMER, wait_response_timer, + mcl, NULL); return TRUE; } @@ -587,8 +588,8 @@ gboolean mcap_reconnect_mdl(struct mcap_mdl *mdl, mcl->state = MCL_ACTIVE; mcl->priv_data = con; - mcl->tid = g_timeout_add_seconds(RESPONSE_TIMER, wait_response_timer, - mcl); + mcl->tid = timeout_add_seconds(RESPONSE_TIMER, wait_response_timer, + mcl, NULL); return TRUE; } @@ -607,8 +608,8 @@ static gboolean send_delete_req(struct mcap_mcl *mcl, mcl->priv_data = con; - mcl->tid = g_timeout_add_seconds(RESPONSE_TIMER, wait_response_timer, - mcl); + mcl->tid = timeout_add_seconds(RESPONSE_TIMER, wait_response_timer, + mcl, NULL); return TRUE; } @@ -718,8 +719,8 @@ gboolean mcap_mdl_abort(struct mcap_mdl *mdl, mcap_mdl_notify_cb abort_cb, con->user_data = user_data; mcl->priv_data = con; - mcl->tid = g_timeout_add_seconds(RESPONSE_TIMER, wait_response_timer, - mcl); + mcl->tid = timeout_add_seconds(RESPONSE_TIMER, wait_response_timer, + mcl, NULL); return TRUE; } |