From b4ed05a04e86c956f97563cd4ca0809a6c635c18 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 7 Apr 2020 03:29:06 +0200 Subject: [PATCH] gatt: Fix AcquireWrite and AcquireNotify server support Register read handler only for notify IO and handle socket disconnection in sock_io_read. Change-Id: I69349f7570aea4370bfb85809a3078886b7560e3 Signed-off-by: Wootak Jung --- src/gatt-database.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gatt-database.c b/src/gatt-database.c index ec83420..5f94576 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -2800,7 +2800,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, @@ -2821,8 +2821,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; @@ -2963,6 +2961,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); -- 2.7.4