Commit graph

1414 commits

Author SHA1 Message Date
Andy Green
af607da082 header fragment reject empty early
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-20 09:44:04 +08:00
Andy Green
f38ad33ddf tolower remove
https://github.com/warmcat/libwebsockets/issues/403

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-20 07:55:41 +08:00
Andy Green
bc4012916d parser issue_char audit
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-20 07:40:13 +08:00
Andy Green
05ae649b66 timeout also fixup for0middle guy deletion case
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 23:11:39 +08:00
Andy Green
72dba09932 timeout check take copies since he may be deleted
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 22:34:44 +08:00
Andy Green
e34d4b4b35 coverity 156860 wsi dereference before NULL check
... bit in reality, wsi can never be NULL

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 21:33:52 +08:00
Andy Green
2e3bf06139 coverity 156861 context destroy dereference context before NULL check
Context could be NULL only if context creation failed in the first
place and user error path is bad... no network connectivity at that
point...

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 21:33:52 +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
d3a5505542 multithreaded service
This adds support for multithreaded service to lws without adding any
threading or locking code in the library.

At context creation time you can request split the service part of the
context into n service domains, which are load-balanced so that the most
idle one gets the next listen socket accept.

There's a single listen socket on one port still.

User code may then spawn n threads doing n service loops / poll()s
simultaneously.  Locking is only required (I think) in the existing
FD lock callbacks already handled by the pthreads server example,
and that locking takes place in user code.  So the library remains
completely agnostic about the threading / locking scheme.

And by default, it's completely compatible with one service thread
so no changes are required by people uninterested in multithreaded
service.

However for people interested in extremely lightweight mass http[s]/
ws[s] service with minimum provisioning, the library can now do
everything out of the box.

To test it, just try

$ libwebsockets-test-server-pthreads -j 8

where -j controls the number of service threads

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 20:02:36 +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
d738f84ed1 timeout move to doubly linked list
In the case we have a lot of connections, checking them all for timeout state
once a second becomes burdensome.  At the moment if you have 100K connections,
once a second they all get checked for timeout in a loop.

This patch adds a doubly-linked list based in the context to each wsi, and
only wsi with pending timeouts appear on it.  At checking time, we traverse
the list, which costs nothing if empty because nobody has a pending timeout.

Similarly adding and removing from the list costs almost nothing since no
iteration is required no matter how big the list.

The extra 8 or 16 bytes in the wsi are offset a little bit by demoting .pps
from int to char (save 3 bytes).  And trim max act exts to 2, since we only
provide one, saving 8 /16 bytes by itself if exts enabled.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 04:32:14 +08:00
Andy Green
9a9d5eaeeb avoid using deallocated things during context dedtroy
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-18 12:07:07 +08:00
Andy Green
a547554aa2 cleaning
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-18 11:16:20 +08:00
Andy Green
1d719ec87f lws_interface_to_sa
Expose interface handling code as an api
2016-01-16 12:09:38 +08:00
Andy Green
d5060d25a1 use lws_close not raw close
https://github.com/warmcat/libwebsockets/issues/400

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-16 11:14:46 +08:00
Andy Green
29cfeebcde permessage deflate male callback VISIBLE
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-15 22:16:54 +08:00
Andy Green
7c507e4700 fix client getting hung up on at negotiation
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-15 19:34:33 +08:00
Andy Green
809d69aa85 redirect
This adds redirect support to the client side.  Lws will follow
server redirects (301) up to three deep.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-15 19:32:47 +08:00
Andy Green
7a0fcf2fc5 parse_uri
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-15 19:32:47 +08:00
Vijay Khurdiya
e73d446461 ssl add ECDH server support
(AG clean style add option flag and docs)
2016-01-15 16:21:51 +08:00
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
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
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
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
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
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