[Libwebsockets] Make the echo client's --times option work.

Peter Pentchev roam at ringlet.net
Mon Mar 12 21:29:18 CET 2018


Hi,

Thanks for keeping libwebsockets alive and kicking!

What do you think about the attached trivial patches that make
the echo client's --times option actually work?  The first one
makes the client exit after receiving all the replies expected,
and the second one makes the counting account for the one decrease
at the start, before connecting.

Keep up the great work!

G'luck,
Peter

-- 
Peter Pentchev  roam at ringlet.net roam at FreeBSD.org pp at storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
-------------- next part --------------
From 2d10da5961d0e038aadaa118715cc509989f4086 Mon Sep 17 00:00:00 2001
From: Peter Pentchev <roam at ringlet.net>
Date: Mon, 12 Mar 2018 22:24:05 +0200
Subject: [PATCH 1/2] The "echo" test should exit if --times is specified.

---
 test-apps/test-echo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test-apps/test-echo.c b/test-apps/test-echo.c
index 4082bd64..b45345e5 100644
--- a/test-apps/test-echo.c
+++ b/test-apps/test-echo.c
@@ -143,6 +143,8 @@ do_rx:
 			goto do_rx;
 #endif
 		lwsl_notice("Client RX: %s", (char *)in);
+		if (times == 0)
+			force_exit = 1;
 		break;
 
 	case LWS_CALLBACK_CLIENT_WRITEABLE:
-- 
2.16.1

-------------- next part --------------
From b27cc59291a47d8d7aa0ad102e84c2b8198cf345 Mon Sep 17 00:00:00 2001
From: Peter Pentchev <roam at ringlet.net>
Date: Mon, 12 Mar 2018 22:24:39 +0200
Subject: [PATCH 2/2] Fix an off-by-one error in the "echo" client's --times
 handling.

---
 test-apps/test-echo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test-apps/test-echo.c b/test-apps/test-echo.c
index b45345e5..af27efe7 100644
--- a/test-apps/test-echo.c
+++ b/test-apps/test-echo.c
@@ -352,7 +352,7 @@ int main(int argc, char **argv)
 			_interface = interface_name;
 			break;
 		case 'n':
-			times = atoi(optarg);
+			times = atoi(optarg) + 1;
 			break;
 		case '?':
 		case 'h':
-- 
2.16.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20180312/56349c44/attachment.sig>


More information about the Libwebsockets mailing list