Skip to contentSkip to conversation

meshctl: Retry recvmsg if data is not ready

PATCH Applied Steve Brown 2 participants 2 messages May 21, 2019 – May 24, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 meshctl: Retry recvmsg if data is not ready

Commit d6eec1b67d6d ("meshctl: Switch from write to sendmsg for Acquire*") causes a regression by returning an error if recvmsg has no data available. Fix it by retrying until data is received.
---
Changes in v2:
* Reword commit message

 tools/mesh/gatt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/mesh/gatt.c +4 -1
index 2269a20cf..0a942d4eb 100644
@@ -415,8 +415,11 @@ 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;
+		}
 
 		res = buf;
 		len_sar = mesh_gatt_sar(&res, len);
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw

Hi Steve,

Quoted 28 lines · Steve Brown

Commit d6eec1b67d6d ("meshctl: Switch from write to sendmsg for Acquire*") causes a regression by returning an error if recvmsg has no data available. Fix it by retrying until data is received.
---
Changes in v2:
* Reword commit message

 tools/mesh/gatt.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/mesh/gatt.c +4 -2
index 2269a20cf..0a942d4eb 100644
@@ -415,8 +415,11 @@ 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;
+               }
 
                res = buf;
                len_sar = mesh_gatt_sar(&res, len);
--
Quoted 1 line

2.20.1

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz