diff mbox

[11/23] adapter: Do not poll when there is an active tag

Message ID 20170615182516.4508-12-mgreer@animalcreek.com (mailing list archive)
State Accepted
Delegated to: Samuel Ortiz
Headers show

Commit Message

Mark Greer June 15, 2017, 6:25 p.m. UTC
When there is an active tag and a request to start polling is
received by neard, it will discard the currently registered tag
and requests that the kernel start another poll.  The kernel receives
this request and returns EBUSY because there is already an active tag.
neard receives this failure and reports it to the poll requestor.
At this point, the tag is active but neard no longer has any knowledge
of it.  Fix this by returning EBUSY when there is an active tag and
a new poll request is received.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
---
 src/adapter.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/src/adapter.c b/src/adapter.c
index eb1a407..9e3e75e 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -358,6 +358,9 @@  static DBusMessage *start_poll_loop(DBusConnection *conn,
 		return __near_error_failed(msg, ENODEV);
 	}
 
+	if (g_hash_table_size(adapter->tags) > 0)
+		return __near_error_failed(msg, EBUSY);
+
 	dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &dbus_mode,
 							DBUS_TYPE_INVALID);