* [PATCH 1/1] meshctl: Fix infinite sock read
[not found] <CGME20191206041323epcas5p35d6b7b22e50698d10af05d669001fd5a@epcas5p3.samsung.com>
@ 2019-12-06 4:13 ` Anurag Biradar
2020-01-05 15:50 ` anurag biradar
2020-01-06 15:36 ` Gix, Brian
0 siblings, 2 replies; 3+ messages in thread
From: Anurag Biradar @ 2019-12-06 4:13 UTC (permalink / raw)
To: linux-bluetooth
When a stream socket peer has performed an orderly shutdown,
then return value will be 0.
---
tools/mesh-gatt/gatt.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/mesh-gatt/gatt.c b/tools/mesh-gatt/gatt.c
index bff5947..1bd9868 100644
--- a/tools/mesh-gatt/gatt.c
+++ b/tools/mesh-gatt/gatt.c
@@ -416,7 +416,7 @@ static bool sock_read(struct io *io, bool prov, void *user_data)
msg.msg_iovlen = 1;
while ((len = recvmsg(fd, &msg, MSG_DONTWAIT))) {
- if (len <= 0) {
+ if (len < 0) {
if (errno == EAGAIN)
break;
return false;
@@ -431,6 +431,11 @@ static bool sock_read(struct io *io, bool prov, void *user_data)
net_data_ready(res, len_sar);
}
}
+
+ /* When socket is orderly closed, then recvmsg returns 0 */
+ if (len == 0)
+ return false;
+
return true;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] meshctl: Fix infinite sock read
2019-12-06 4:13 ` [PATCH 1/1] meshctl: Fix infinite sock read Anurag Biradar
@ 2020-01-05 15:50 ` anurag biradar
2020-01-06 15:36 ` Gix, Brian
1 sibling, 0 replies; 3+ messages in thread
From: anurag biradar @ 2020-01-05 15:50 UTC (permalink / raw)
To: Anurag Biradar; +Cc: linux-bluetooth
On Fri, Dec 6, 2019 at 9:46 AM Anurag Biradar <biradar.a@samsung.com> wrote:
>
> When a stream socket peer has performed an orderly shutdown,
> then return value will be 0.
> ---
> tools/mesh-gatt/gatt.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/mesh-gatt/gatt.c b/tools/mesh-gatt/gatt.c
> index bff5947..1bd9868 100644
> --- a/tools/mesh-gatt/gatt.c
> +++ b/tools/mesh-gatt/gatt.c
> @@ -416,7 +416,7 @@ static bool sock_read(struct io *io, bool prov, void *user_data)
> msg.msg_iovlen = 1;
>
> while ((len = recvmsg(fd, &msg, MSG_DONTWAIT))) {
> - if (len <= 0) {
> + if (len < 0) {
> if (errno == EAGAIN)
> break;
> return false;
> @@ -431,6 +431,11 @@ static bool sock_read(struct io *io, bool prov, void *user_data)
> net_data_ready(res, len_sar);
> }
> }
> +
> + /* When socket is orderly closed, then recvmsg returns 0 */
> + if (len == 0)
> + return false;
> +
> return true;
> }
>
> --
> 2.7.4
>
Gentle Ping.
Thanks
Anurag
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] meshctl: Fix infinite sock read
2019-12-06 4:13 ` [PATCH 1/1] meshctl: Fix infinite sock read Anurag Biradar
2020-01-05 15:50 ` anurag biradar
@ 2020-01-06 15:36 ` Gix, Brian
1 sibling, 0 replies; 3+ messages in thread
From: Gix, Brian @ 2020-01-06 15:36 UTC (permalink / raw)
To: biradar.a, linux-bluetooth
Applied
On Fri, 2019-12-06 at 09:43 +0530, Anurag Biradar wrote:
> When a stream socket peer has performed an orderly shutdown,
> then return value will be 0.
> ---
> tools/mesh-gatt/gatt.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/mesh-gatt/gatt.c b/tools/mesh-gatt/gatt.c
> index bff5947..1bd9868 100644
> --- a/tools/mesh-gatt/gatt.c
> +++ b/tools/mesh-gatt/gatt.c
> @@ -416,7 +416,7 @@ static bool sock_read(struct io *io, bool prov, void *user_data)
> msg.msg_iovlen = 1;
>
> while ((len = recvmsg(fd, &msg, MSG_DONTWAIT))) {
> - if (len <= 0) {
> + if (len < 0) {
> if (errno == EAGAIN)
> break;
> return false;
> @@ -431,6 +431,11 @@ static bool sock_read(struct io *io, bool prov, void *user_data)
> net_data_ready(res, len_sar);
> }
> }
> +
> + /* When socket is orderly closed, then recvmsg returns 0 */
> + if (len == 0)
> + return false;
> +
> return true;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-06 15:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20191206041323epcas5p35d6b7b22e50698d10af05d669001fd5a@epcas5p3.samsung.com>
2019-12-06 4:13 ` [PATCH 1/1] meshctl: Fix infinite sock read Anurag Biradar
2020-01-05 15:50 ` anurag biradar
2020-01-06 15:36 ` Gix, Brian
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).