make protocols const require explicit context API BREAK
authorAndy Green <andy.green@linaro.org>
Fri, 11 Dec 2015 02:45:35 +0000 (10:45 +0800)
committerAndy Green <andy.green@linaro.org>
Sun, 13 Dec 2015 22:43:26 +0000 (06:43 +0800)
commitd2ac22c27abf34d3cccb3a6fe1e2c6d92123f436
treea6001d3a781da31eed96cec2000f0fcbf824a6cb
parent8203be6742d8187cd3d3c0f9007c64f4f5f67c08
make protocols const require explicit context API BREAK

The user protocols struct has not been const until now.

This has been painful for a while because the semantics of the protocols
struct look like it's going to be treated as const.

At context creation, the protocols struct has been getting marked with the context,
and three apis exploited that to only need to be passed a pointer to a protocol to
get access to the context.

This patch removes the two writeable members in the context (these were never directly
used by user code), changes all pointers to protocols to be const, and adds an explicit
first argument to the three affected apis so they can have access to context.

The three affected apis are these

 LWS_VISIBLE LWS_EXTERN int
-lws_callback_on_writable_all_protocol(const struct lws_protocols *protocol);
+lws_callback_on_writable_all_protocol(const struct lws_context *context,
+                                     const struct lws_protocols *protocol);

 LWS_VISIBLE LWS_EXTERN int
-lws_callback_all_protocol(const struct lws_protocols *protocol, int reason);
+lws_callback_all_protocol(struct lws_context *context,
+                         const struct lws_protocols *protocol, int reason);

 LWS_VISIBLE LWS_EXTERN void
-lws_rx_flow_allow_all_protocol(const struct lws_protocols *protocol);
+lws_rx_flow_allow_all_protocol(const struct lws_context *context,
+                              const struct lws_protocols *protocol);

unfortunately the original apis can no longer be emulated and users of them must update.

Signed-off-by: Andy Green <andy.green@linaro.org>
17 files changed:
lib/client.c
lib/context.c
lib/extension-deflate-frame.c
lib/extension-deflate-frame.h
lib/extension-deflate-stream.c
lib/extension-deflate-stream.h
lib/extension.c
lib/libwebsockets.c
lib/libwebsockets.h
lib/pollfd.c
lib/private-libwebsockets.h
lib/server-handshake.c
test-server/test-client.c
test-server/test-echo.c
test-server/test-server-mirror.c
test-server/test-server-pthreads.c
test-server/test-server.c