[PATCH 1/1] meshctl: Fix infinite sock read

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux