* [PATCH] gatt: Fix AcquireWrite and AcquireNotify server support
@ 2020-04-07 1:29 Szymon Janc
2020-04-07 7:14 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2020-04-07 1:29 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Register read handler only for notify IO and handle socket
disconnection in sock_io_read.
---
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 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);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gatt: Fix AcquireWrite and AcquireNotify server support
2020-04-07 1:29 [PATCH] gatt: Fix AcquireWrite and AcquireNotify server support Szymon Janc
@ 2020-04-07 7:14 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2020-04-07 7:14 UTC (permalink / raw)
To: linux-bluetooth
On Tuesday, 7 April 2020 03:29:06 CEST Szymon Janc wrote:
> Register read handler only for notify IO and handle socket
> disconnection in sock_io_read.
> ---
> 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 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);
Applied.
--
pozdrawiam
Szymon Janc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-07 7:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-07 1:29 [PATCH] gatt: Fix AcquireWrite and AcquireNotify server support Szymon Janc
2020-04-07 7:14 ` Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).