Commit graph

34 commits

Author SHA1 Message Date
Andy Green
014481e912 documentation convert to doxygen
Signed-off-by: Andy Green <andy@warmcat.com>
2016-07-14 08:57:27 +08:00
Andy Green
c5376b141a extensions add api for user code option manipulation
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-08 09:45:49 +08:00
Andy Green
d526c50c22 introduce vhosts
This patch splits out some lws_context members into a new lws_vhost struct.

 - ssl state and options per vhost
 - SSL_CTX for serving and client per vhost
 - protocols[] per vhost
 - extensions[] per vhost

lws_context maintains a linked list of lws_vhosts.

The same lws_context_creation_info struct is used to regulate both the
context creation and to create vhosts: for backward compatibility if you
didn't provide the new LWS_SERVER_OPTION_EXPLICIT_VHOSTS option, then
a default vhost is created at context creation time using the same info
data as the context itself.

If you will have multiple vhosts though, you should give the
LWS_SERVER_OPTION_EXPLICIT_VHOSTS option at context creation time,
create the context first and then the vhosts afterwards using

  lws_create_vhost(contest, &info);

Although there is a lot of housekeeping to implement this change, there
is almost no additional overhead if you don't use multiple vhosts and
very little api impact (no changes to test apps).

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-28 10:15:25 +08:00
Andy Green
86ed65ff00 libuv integration
This gets the libuv stuff plumbed in and working.

Currently it's only workable for some service thread, and there
is an isolated valgrind problem left

==28425== 128 bytes in 1 blocks are definitely lost in loss record 3 of 3
==28425==    at 0x4C28C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28425==    by 0x4C2AB1E: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28425==    by 0x58BBB27: maybe_resize (core.c:748)
==28425==    by 0x58BBB27: uv__io_start (core.c:787)
==28425==    by 0x58C1B80: uv__signal_loop_once_init (signal.c:225)
==28425==    by 0x58C1B80: uv_signal_init (signal.c:260)
==28425==    by 0x58BF7A6: uv_loop_init (loop.c:66)
==28425==    by 0x4157F5: lws_uv_initloop (libuv.c:89)
==28425==    by 0x405536: main (test-server-libuv.c:284)

libuv wants to sign off on all libuv 'handles' that will close, and
callback to do the close confirmation asynchronously.  The wsi close function
is adapted when libuv is in use to work with libuv accordingly and exit the uv
loop the number of remaining wsi is zero.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-14 09:31:13 +08:00
Andy Green
1b2c9a23e1 clean pre 1.7
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 23:17:43 +08:00
Andy Green
2ec7c85e99 coverity 156862 unused return value
Not exactly a problem...

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 21:27:44 +08:00
Andy Green
3f63560876 fix broken ext arg parsing
This gets us back to all the Autobahn tests passing

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 20:02:34 +08:00
Andy Green
6711266a50 extension permessage deflate
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-11 11:34:01 +08:00
Andy Green
6d64539fcb lws_get_context not _ctx
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 18:25:25 +08:00
Andy Green
54806b1541 clean internal refactor
- Mainly symbol length reduction
 - Whitespace clean
 - Code refactor for linear flow
 - Audit @Context for API docs vs changes

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 17:03:59 +08:00
Andy Green
71e267574d clean misc 1
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 08:30:06 +08:00
Andy Green
11c05bfa09 public api remove superfluous context params API BREAK
Extend the cleanout caused by wsi having a context pointer
into the public api.

There's no point keeping the 1.5 compatibility work,
we have changed the api in several places and
rebuilt wasn't going to be enough a while ago.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-16 18:19:08 +08:00
Andy Green
6b5de70f4f refactor needless context with wsi paramater passing
Now we bit the bullet and gave each wsi an lws_context *, many
internal apis that take both a context and wsi parameter only
need the wsi.

Also simplify parser code by making a temp var for
allocated_headers * instead of the longwinded
dereference chain everywhere.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 21:15:58 +08:00
Andy Green
40110e84ab whitespace trailing mass cleanout
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 08:52:03 +08:00
Andy Green
d2ac22c27a 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>
2015-12-14 06:43:26 +08:00
Andy Green
8203be6742 lws_get_ctx conversion
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:43:24 +08:00
Andy Green
4b85c1d4ac api rationalization: eliminate all libwebsocket[s]_ prefixes
This nukes all the oldstyle prefixes except in the compatibility code.

struct libwebsockets becomes struct lws too.

The api docs are updated accordingly as are the READMEs that mention
those apis.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 11:08:32 +08:00
Andy Green
6230476455 api rationalization use new names internally
Change all internal uses of rationalized public apis to reflect the
new names.

Theer are a few things that got changed as side effect of search/replace
matches, but these are almost all internal.  I added a compatibility define
for the public enum that got renamed.

Theoretically existing code should not notice the difference from these
two patches.  And new code will find the new names.

https://github.com/warmcat/libwebsockets/issues/357

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 08:43:54 +08:00
Andy Green
5549998ac3 coverity 83678 unused assignment
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 12:40:32 +08:00
kolis
981fb47f9b partial send handling 2014-07-06 09:36:44 +08:00
Andy Green
dfca3abfa1 clean partial send handling warning
Reported-by: Michael Haberler <mail17@mah.priv.at>
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-05-22 11:12:15 +08:00
kolis
f77e6e33d1 Partial send handling
AG removed what looked like redundant set eff_buf.token_len <- n
2014-05-20 12:38:29 +08:00
Andy Green
cdb9bf9bdd refactor move ssl server service to ssl.c
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-12 10:07:02 +08:00
Andy Green
a1a24d26a6 close should flush any truncated send before really closing
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-10 14:25:24 +08:00
Andy Green
e40aa9b920 plat change to build selection by cmake
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-02 21:04:03 +08:00
Andy Green
2c24ec0211 refactor out most NO_EXTENSIONS
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-02 19:45:42 +08:00
Peter Pentchev
9a4fef7ed6 Hide private library symbols
Signed-off-by: Peter Pentchev <roam@ringlet.net>
2013-03-30 09:52:21 +08:00
Joakim Soderberg
f272cb0624 Fixed DLL compilation on Windows for CMake.
- Define LWS_DLL and LWS_INTERNAL when websockets_shared is compiled.

- The websocket_shared target compiles to websocket.lib / websocket.dll
  (websocket.lib contains the exported functions for websocket.dll, and is
  the file that is linked to when a program wants to use the dll)

- The websocket target compiles to websocket_static.lib on windows.

- Replaced any "extern" with "LWS_EXTERN" on libwebsockets.h for proper
  DLL function exports.

- Created a LIB_LIST with all the libwebsocket dependencies, instead of
  multiple calls to target_link_libraries, only one call is made for both
  the static and shared library version. This makes it easy to add other
  variants if wanted in the future.

- Added ZLIB as a dependency for the libs, so that the build order will be
  correct at all times.

- Added a dependency for the websockets lib to the test apps, so it is
  built before them.

- Fixed the test-server-extpoll app to include the emulated_poll, and link
  to winsock on Windows.

- Removed the global export of libwebsocket_internal_extensions, and added
  a function libwebsocket_get_internal_extensions() that returns it
  instead. Using the global would not work with the DLL export on Windows.
2013-02-13 09:29:26 +08:00
Andy Green
b5b23199f6 style cleanup
This brings the library sources into compliance with checkpatch
style except for three or four exceptions like WIN32 related stuff
and one long string constant I don't want to break into multiple
sprintf calls.

There should be no functional or compilability change from all
this (hopefully).

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-11 17:13:32 +08:00
Andy Green
4a673a38ca deprecate x google mux
Unfortunately this code is beginning to rot due to lack of demand to
provide it and it being disabled by default.

If demand appears we can revert this and resume work on it, otherwise
let's bite the bullet for the moment.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 19:53:16 +08:00
David Galeano
85a092135e Added extension "deflate-frame".
Using by default instead of "deflate-stream".
2013-01-09 18:21:33 +08:00
Andy Green
a41314f3bf introduce x google mux very draft indeed
This is initial x-google-mux support.  It's disabled by default
since it's very pre-alpha.

1) To enable it, reconfigure with --enable-x-google-mux

2) It conflicts with deflate-stream, use the -u switch on
   the test client to disable deflate-stream

3) It deviates from the google standard by sending full
   headers in the addchannel subcommand rather than just
   changed ones from original connect

4) Quota is not implemented yet

5) Close of subchannel is not really implemented yet

6) Google opcode 0xf is changed to 0x7 to account for
   v7 protocol changes to opcode layout

However despite those caveats, in fact it can run the
test client reliably over one socket (both dumb-increment
and lws-mirror-protocol), you can open a browser on the
same test server too and see the circles, etc.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-23 10:00:03 +01:00
Andy Green
ce6a21dbda introduce deflate compression extension
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 13:32:53 +00:00
Andy Green
4cd87a0bd9 introduce internal extensions array
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 13:15:32 +00:00