Commit graph

1880 commits

Author SHA1 Message Date
Andy Green
7c15eb1e42 only report CLIENT_CONNECTION_ERROR once on some paths
In most cases the close api will see it should send the CCE because
we are still in the waiting server reply state until the end of the
interpretation.  Only if we completed the interpretation and moved
on to ESTABLISHED do we need to handle sending it ourselves.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-14 11:38:31 +08:00
Andy Green
389a4bb9f0 remove double free attempts from no ACCEPT server response cleanup path
The generic wsi close code is smart enough to clean up after these allocations itself

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-13 18:48:50 +08:00
Andy Green
8308073464 fuzzer eliminate hsecond ah free path firing assert sentinel
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-13 05:01:17 +08:00
Andy Green
9928cccdb6 fuzzer rx overflow mitigate
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-12 23:05:02 +08:00
Andy Green
5b3736682d lws_client_connect_via_info
https://github.com/warmcat/libwebsockets/issues/396

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-12 17:22:06 +08:00
Andy Green
b6289d1153 test client remove abs modulo
llvm and gcc 5.3 do different things with it

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

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-12 08:46:56 +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
58ad3d6e09 clean libev.c style
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-09 08:13:55 +08:00
Andy Green
5783b1a169 libev set events to match revents
https://github.com/warmcat/libwebsockets/issues/393

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-09 04:12:46 +08:00
Andy Green
5eeb4bd0d3 partial always use partial buffering if send incomplete
After "rerelease"

https://github.com/warmcat/libwebsockets/issues/392#issuecomment-170003294

Since we introduced partial buffering a long while ago,
user code shold never see partial sends and very few
user callbsck attempt to deal with them.

Let's just eliminate the whole concept of user callback
partial send handling under any circumstances.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-08 21:52:47 +08:00
Denis Osvald
27174e64de properly skip protocols with NULL name
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-01-07 06:57:59 +08:00
Denis Osvald
034e514a0d fix callback typedefs and declarations
Remove declarations of callback and extension_callback as these are
functions declared in header but not defined anywhere.

Also rename typedefs callback_function and extension_callback_function
to lws_callback_function and lws_extension_callback_function so all
symbolx exported by header have lws prefix;

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-01-07 06:44:38 +08:00
Andy Green
0c7e5a9418 doc improve docs around header access apis
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-30 14:53:50 +08:00
Andy Green
2b35e123f4 ext negotiation tolerate semicolon args
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-30 12:12:58 +08:00
Andy Green
86c1ef1e7c utf8 check compatible with extensions
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-30 11:43:36 +08:00
Andy Green
9b81d3c967 optimize utf8 check tests into state bit
Considering we go through it once per incoming char, the tests to see if we
should be checking utf-8 are too expensive... move them to a bit that lives
in the wsi and set them once per frame (except for CLOSE who has to update
after the close code has been skipped).

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-29 12:28:48 +08:00
Andy Green
44a7f65e1a introduce LWS_SERVER_OPTION_VALIDATE_UTF8
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-29 11:20:09 +08:00
Andy Green
0c7b38b144 autobahn check utf8 on TEXT and CLOSE
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-29 09:46:03 +08:00
Andy Green
7c2868486e autobahn reject forbidden close code ranges
Complain like autobahn expects if we get a funny close code

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 22:29:57 +08:00
Andy Green
fde3684384 autobahn README.test apps.md
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 22:29:57 +08:00
Andy Green
91d624e38a autobahn reject noncontinuation based on pending FIN state
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 22:29:57 +08:00
Andy Green
977734ee07 autobahn detect disordered continuation
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 22:29:57 +08:00
Andy Green
44e0b088fa autobahn add same serverside rxflow cache to client
Server side has had immediate RX flow control for quite a while.

But client side made do with RX continuing until what had been received was exhausted.

For what Autobahn tests, that's not enough.

This patch gives clientside RX flow control the same immediate effect as the server
side enjoys, re-using the same code.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 21:47:46 +08:00
Andy Green
f05167dee6 autobahn reject on reserved opcode or bits
Because extensions may use them, we didn't reject on reserved opc or bits set,
just ignored.  But the standard does say we should, so now we do.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 20:53:43 +08:00
Andy Green
d5be3bf749 autobahn test echo extend max echo and follow message boundary
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 13:43:59 +08:00
Andy Green
7dbf21efc2 autobahn extend max ping pong close payload to 125
We only supported those specific control packet payloads up to 124.
125 is the correct limit.

Lws was consistent about the wrong limit so there are no other
issues.  It doesn't affect user ABI correcting it either.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 13:40:54 +08:00
Andy Green
41434fad53 autobahn report final frag only on final rx bufload
If the final message fragment contains a payload that has to be
handled in multiple RX callbacks, until now we reported the ws
fragment header FIN state in lws_is_final_fragment().

That was correct, but it's kind of not useful to hear that the
intermediate bufferloads are "final".  So now we delay
reporting the logical ws fragment FIN until the final part of
his payload is delivered.

This gets us Autobahn 1.1.6 working.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 12:45:52 +08:00
Andy Green
4c9d895768 autobahn requires zero length tx allowed
Again we treat user code sending zero length things as a bug in user code.

But Autobahn insists to be able to do it, so now we allow it.

That buys us a pass on Autobahn test 1.1.1 (the first of a bazillion)

Reproduce with

libwebsockets-test-echo --client localhost --port 9001 -u "/runCase?case=1&agent=libwebsockets" -v -d 65535 -n 1

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 11:14:04 +08:00
Andy Green
20db310908 autobahn requires zero length rx allowed
We suppress zero length rx from getting to userland, but autobahn
requires it... oh well.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 11:12:05 +08:00
Andy Green
e7d8e20f56 autobahn test echo meddling
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 11:12:05 +08:00
Andy Green
07f194686f clean windows warnings
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-27 18:16:32 +08:00
Andy Green
40e607b876 test server libev
If we enabled libev support, generate a test server variant that uses it.

Libev has sets its face against fixing its warnings and says -Werror is
"stupid".  So we work around it for the problems their apis cause in
Travis.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-27 09:43:44 +08:00
Andy Green
4e2ac7685d clarify changelog
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 20:26:11 +08:00
Andy Green
daa6b8ff25 update api docs
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 17:36:29 +08:00
Andy Green
1fb95e8084 close add api to control sent close frame contents
This adds an api lws_close_reason() which lets you control what will
be sent in the close frame when the connection is closed by returning
nonzero from the user callback.

The test server demo is extended to prove it works in both directions.

With this, we should have nice close support.

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

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 17:20:34 +08:00
Andy Green
066a7a1801 close add callback to get peer close reason
https://github.com/warmcat/libwebsockets/issues/196

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 15:47:06 +08:00
Andy Green
a24b40860f mbed3 remove forcing _DEBUG
It saves us ~4KB of lwsl_info / _debug etc strings.

The test app comes in at 114KB then, including 19KB of html, png and ico assets.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 15:07:45 +08:00
Andy Green
5b85e39d99 mbed3 remove unused allocations
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 13:23:11 +08:00
Andy Green
3246ebb3f5 deprecate LWS_SEND_BUFFER_POST_PADDING
The only guy who cared about this for a long while
(since I eliminated the pre-standard protocol variants)
was sending a close frame.

 - Set it to 0 so old code remains happy.  It only affects
user code buffer commit, if there's overcommit no harm
done so no effect directly on user ABI.

 - Remove all uses inside the library.  The sample apps
don't have it any more and that's the recommendation now.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 12:03:06 +08:00
Andy Green
de1a6a539f output eliminate redundant post calculation
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 10:07:17 +08:00
Andy Green
87bac69f55 remove MAX_MUX_RECURSION from PRE padding
The old google mux thing is long dead

This only affects app buffer sizing, if old apps overcommit, no worries.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 09:08:06 +08:00
Andy Green
aa775fd9b0 rearrange private struct packing 2
Further reduces lws size to 512 on x86_64 "for free"

Both this and the last patch only rearrange private struct members.

Also convert win32-specific member from BOOL to bitfield:1.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 08:56:58 +08:00
Peter Pentchev
da2eab3f66 Recognize Debian GNU/kFreeBSD as FreeBSD-ish.
Some of the FreeBSD-specific code in libwebsockets is related to
the FreeBSD kernel, not the general build environment.  Thus, it is
important to make this distinction, especially when building on
platforms that have a FreeBSD kernel and a non-FreeBSD userland build
environment, such as Debian GNU/kFreeBSD.

When checking for FreeBSD kernel features, also check for the newly
introduced __FreeBSD_kernel__ preprocessor constant; it is present in
the GNU/kFreeBSD kernel and also in FreeBSD itself since the 9.1 release
about three years ago.
2015-12-25 21:15:21 +08:00
Andy Green
de132b94b1 rearrange struct packing
Surprisingly it's enough to reduce wsi from 536 to 520 on x86_64

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-25 14:49:54 +08:00
Andy Green
3df580066b http header malloc pool implement pool
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-25 14:34:20 +08:00
Andy Green
b3d21f164d http header malloc pool allow listen accept flow control
Add a private api to enable and disable server listen socket POLLIN

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-25 14:34:13 +08:00
Andy Green
ba38a7e6b4 ws ping buffer allocate in wsi ws union member
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-25 14:34:10 +08:00
Andy Green
a4244f08ad info struct add padding pool
The info struct is too fragile against additions being able to keep soname.

Because if we add something, the library can't count on the user code being
built against latest headers with largest info struct size.  Then the user
code may not have zeroed down enough of the struct and give us junk in the
new members.

Add a pool at the end of the info struct that exists so it will be zeroed
down even though no current use for those future members, then later
library versions can compatibly use them without breaking soname if it is
understood 0 means default.

Because keeping sizeof info straight if you add something is now a thing,
also add an lwsl_info letting you confirm it easily.

It's fine if the size of info differs on different platforms.  But when
we add things to the struct we need to balance the padding using a scheme
like

       short  new_member;
       unsigned char _padding1[sizeof(void *) - sizeof(short)];

which is immune to differences in platform differences in sizeof void *.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-25 09:23:25 +08:00
Andy Green
c35b36b1cf detect service tid once and use wsi with valid context to do it
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-24 13:00:54 +08:00
Andy Green
400e5a7fed libev complete unix plat context init
https://github.com/warmcat/libwebsockets/issues/381

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-23 11:55:06 +08:00