[Libwebsockets] [PATCH v2 8/9] libev: change test-client and test-server to set info->event_ops for -e

Alejandro Mery amery at geeks.cl
Wed Dec 17 22:20:30 CET 2014


Signed-off-by: Alejandro Mery <alejandro.mery at opensynergy.com>
---
 changelog                 |  4 ++--
 test-server/test-client.c | 12 +++++++++++-
 test-server/test-server.c |  2 ++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/changelog b/changelog
index 5e48a24..98afa9f 100644
--- a/changelog
+++ b/changelog
@@ -204,8 +204,8 @@ your list of live wsi by doing it from ESTABLISHED and CLOSED callbacks
 
 If you configure cmake with -DLWS_WITH_LIBEV=1 then the code allowing the libev
 eventloop instead of the default poll() one will also be compiled in.  But to
-use it, you must also set the LWS_SERVER_OPTION_LIBEV flag on the context
-creation info struct options member.
+use it, you must also info->event_ops = &lws_libev_event_ops when creating the
+context.
 
 IPV6 is supported and enabled by default except for Windows, you can disable
 the support at build-time by giving -DLWS_IPV6=, and disable use of it even if
diff --git a/test-server/test-client.c b/test-server/test-client.c
index e94dbed..e431e66 100644
--- a/test-server/test-client.c
+++ b/test-server/test-client.c
@@ -249,6 +249,7 @@ static struct option options[] = {
 	{ "undeflated",	no_argument,		NULL, 'u' },
 	{ "nomux",	no_argument,		NULL, 'n' },
 	{ "longlived",	no_argument,		NULL, 'l' },
+	{ "libev",	no_argument,		NULL, 'e' },
 	{ NULL, 0, 0, 0 }
 };
 
@@ -264,6 +265,7 @@ int main(int argc, char **argv)
 	struct libwebsocket *wsi_dumb;
 	int ietf_version = -1; /* latest */
 	struct lws_context_creation_info info;
+	struct lws_event_ops *event_ops = NULL;
 
 	memset(&info, 0, sizeof info);
 
@@ -275,10 +277,17 @@ int main(int argc, char **argv)
 		goto usage;
 
 	while (n >= 0) {
-		n = getopt_long(argc, argv, "nuv:hsp:d:l", options, NULL);
+		n = getopt_long(argc, argv, "enuv:hsp:d:l", options, NULL);
 		if (n < 0)
 			continue;
 		switch (n) {
+		case 'e':
+#ifdef LWS_USE_LIBEV
+			event_ops = &lws_libev_event_ops;
+#else
+			fprintf(stderr, "libev backend not supported, ignoring.\n");
+#endif
+			break;
 		case 'd':
 			lws_set_log_level(atoi(optarg), NULL);
 			break;
@@ -325,6 +334,7 @@ int main(int argc, char **argv)
 #ifndef LWS_NO_EXTENSIONS
 	info.extensions = libwebsocket_get_internal_extensions();
 #endif
+	info.event_ops = event_ops;
 	info.gid = -1;
 	info.uid = -1;
 
diff --git a/test-server/test-server.c b/test-server/test-server.c
index 079eeca..bce10b0 100644
--- a/test-server/test-server.c
+++ b/test-server/test-server.c
@@ -806,6 +806,8 @@ int main(int argc, char **argv)
 		case 'e':
 #ifdef LWS_USE_LIBEV
 			event_ops = &lws_libev_event_ops;
+#else
+			fprintf(stderr, "libev backend not supported, ignoring.\n");
 #endif
 			break;
 #ifndef LWS_NO_DAEMONIZE
-- 
2.2.0




More information about the Libwebsockets mailing list