[PATCH wpan-tools 3/4] wpan-ping: do not try to send data back to origin if we got an error from recvfrom

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

 



In the case of a length of -1 from recvfrom we print out the error code but we
never left the current loop iteration. That might be problematic when we try to
send the data back with sendto. Instead we now continue with the next iteration
from now on if we get an error.

CID: 32115
Signed-off-by: Stefan Schmidt <stefan@xxxxxxxxxxxxxxx>
---
 wpan-ping/wpan-ping.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/wpan-ping/wpan-ping.c b/wpan-ping/wpan-ping.c
index 8f4c13c..616e0dd 100644
--- a/wpan-ping/wpan-ping.c
+++ b/wpan-ping/wpan-ping.c
@@ -345,12 +345,14 @@ static void init_server(struct config *conf, int sd) {
 		len = recvfrom(sd, buf, MAX_PAYLOAD_LEN, 0, (struct sockaddr *)&src, &addrlen);
 		if (len < 0) {
 			perror("recvfrom");
+			continue;
 		}
 		//dump_packet(buf, len);
 		/* Send same packet back */
 		len = sendto(sd, buf, len, 0, (struct sockaddr *)&src, addrlen);
 		if (len < 0) {
 			perror("sendto");
+			continue;
 		}
 	}
 	free(buf);
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wpan" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux