diff options
author | Archie Pusaka <apusaka@chromium.org> | 2021-11-25 15:06:24 +0800 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2021-11-29 09:43:41 -0800 |
commit | 69c7d34744e5ea1ca84b20ea3fe8f83436567e70 (patch) | |
tree | 1abd00d7640f8a5facc29f1509d065fc91854009 /src/device.c | |
parent | db31aecae07e20a08fd92f66b540ac962e72efc7 (diff) | |
download | bluez-69c7d34744e5ea1ca84b20ea3fe8f83436567e70.tar.gz |
Listen and process remote name resolving failure
When Remote Name Resolve ends with failure, record this occurrence and
prevent remote name resolving for the same device for some time.
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
Diffstat (limited to 'src/device.c')
-rw-r--r-- | src/device.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c index 6b398bd39..a83cb61f8 100644 --- a/src/device.c +++ b/src/device.c @@ -79,6 +79,8 @@ #define GATT_INCLUDE_UUID_STR "2802" #define GATT_CHARAC_UUID_STR "2803" +#define NAME_RESOLVE_RETRY_DELAY 300 /* seconds */ + static DBusConnection *dbus_conn = NULL; static unsigned service_state_cb_id; @@ -272,6 +274,8 @@ struct btd_device { GIOChannel *att_io; guint store_id; + + time_t name_resolve_failed_time; }; static const uint16_t uuid_list[] = { @@ -4389,6 +4393,29 @@ bool device_name_known(struct btd_device *device) return device->name[0] != '\0'; } +bool device_is_name_resolve_allowed(struct btd_device *device) +{ + struct timespec now; + + if (!device) + return false; + + clock_gettime(CLOCK_MONOTONIC, &now); + return now.tv_sec >= device->name_resolve_failed_time + + NAME_RESOLVE_RETRY_DELAY; +} + +void device_name_resolve_fail(struct btd_device *device) +{ + struct timespec now; + + if (!device) + return; + + clock_gettime(CLOCK_MONOTONIC, &now); + device->name_resolve_failed_time = now.tv_sec; +} + void device_set_class(struct btd_device *device, uint32_t class) { if (device->class == class) |