summaryrefslogtreecommitdiff
path: root/src/gatt-database.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@codecoup.pl>2020-04-07 03:29:06 +0200
committerSzymon Janc <szymon.janc@codecoup.pl>2020-04-07 09:13:17 +0200
commit590a11b82f5e1b77d739e49a30cedc30e255d6ae (patch)
treef2b6b5bd6e32a2f1799ea1d52485ffb9dfd2a16b /src/gatt-database.c
parent2a7df9323ea541b38ced544ea2460d583aefb10a (diff)
downloadbluez-590a11b82f5e1b77d739e49a30cedc30e255d6ae.tar.gz
gatt: Fix AcquireWrite and AcquireNotify server support
Register read handler only for notify IO and handle socket disconnection in sock_io_read.
Diffstat (limited to 'src/gatt-database.c')
-rw-r--r--src/gatt-database.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/gatt-database.c b/src/gatt-database.c
index 483c84341..92e24e5f7 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2358,7 +2358,7 @@ static bool sock_io_read(struct io *io, void *user_data)
ssize_t bytes_read;
bytes_read = read(fd, buf, sizeof(buf));
- if (bytes_read < 0)
+ if (bytes_read <= 0)
return false;
send_notification_to_devices(chrc->service->app->database,
@@ -2379,8 +2379,6 @@ static struct io *sock_io_new(int fd, void *user_data)
io_set_close_on_destroy(io, true);
- io_set_read_handler(io, sock_io_read, user_data, NULL);
-
io_set_disconnect_handler(io, sock_hup, user_data, NULL);
return io;
@@ -2537,6 +2535,7 @@ static void acquire_notify_reply(DBusMessage *message, void *user_data)
DBG("AcquireNotify success: fd %d MTU %u\n", fd, mtu);
chrc->notify_io = sock_io_new(fd, chrc);
+ io_set_read_handler(chrc->notify_io, sock_io_read, chrc, NULL);
__sync_fetch_and_add(&chrc->ntfy_cnt, 1);