From: Szymon Janc Date: Tue, 7 Apr 2020 01:29:06 +0000 (+0200) Subject: gatt: Fix AcquireWrite and AcquireNotify server support X-Git-Tag: accepted/tizen/unified/20200427.125827^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b4ed05a04e86c956f97563cd4ca0809a6c635c18;p=platform%2Fupstream%2Fbluez.git 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 --- 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);