platform/upstream/libwebsockets.git
8 years agohttp1.1 keepalive drop ah betweentimes
Andy Green [Fri, 29 Jan 2016 01:06:22 +0000 (09:06 +0800)]
http1.1 keepalive drop ah betweentimes

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

Tested with

wget -O- http://localhost:7681/test.html http://localhost:7681/test.html http://localhost:7681/test.html http://localhost:7681/test.html http://localhost:7681/test.html

and confirm no connection processing during that on server side

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agowin dont redefine _WINSOCK_DEPRECATED_NO_WARNINGS
Andy Green [Thu, 28 Jan 2016 17:26:31 +0000 (01:26 +0800)]
win dont redefine _WINSOCK_DEPRECATED_NO_WARNINGS

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolextable add x-real-ip
Danomi Czaski [Thu, 28 Jan 2016 01:40:53 +0000 (09:40 +0800)]
lextable add x-real-ip

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoreduce debug logging mark socket dead when pollert
Andy Green [Wed, 27 Jan 2016 00:50:31 +0000 (08:50 +0800)]
reduce debug logging mark socket dead when pollert

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolws_adopt_socket
Andy Green [Tue, 26 Jan 2016 13:40:32 +0000 (21:40 +0800)]
lws_adopt_socket

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agomultithread stability
Andy Green [Tue, 26 Jan 2016 12:56:56 +0000 (20:56 +0800)]
multithread stability

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agombed simplify
Andy Green [Tue, 26 Jan 2016 12:45:10 +0000 (20:45 +0800)]
mbed simplify

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agopthreads only as needed
Andy Green [Mon, 25 Jan 2016 13:39:07 +0000 (21:39 +0800)]
pthreads only as needed

This just lets you build lws 1.6 without pthreads if your OS / toolchain
makes that possible, in the case you don't build the test apps
(libwebsockets-test-server-pthreads needs it)

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agofuzxy some toolchains need sys socket.h
Andy Green [Mon, 25 Jan 2016 13:00:37 +0000 (21:00 +0800)]
fuzxy some toolchains need sys socket.h

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agofuzzer handle junk after upgrade header
Andy Green [Thu, 21 Jan 2016 02:54:14 +0000 (10:54 +0800)]
fuzzer handle junk after upgrade header

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agounify bounds checking in parser
Andy Green [Thu, 21 Jan 2016 02:57:39 +0000 (10:57 +0800)]
unify bounds checking in parser

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agofuzxy add test parser and some tests
Andy Green [Thu, 21 Jan 2016 02:54:51 +0000 (10:54 +0800)]
fuzxy add test parser and some tests

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agowin add dummy LWS_WARN_UNUSED_RESULT
Andy Green [Thu, 21 Jan 2016 02:56:20 +0000 (10:56 +0800)]
win add dummy LWS_WARN_UNUSED_RESULT

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agombed align with pt changes
Andy Green [Wed, 20 Jan 2016 09:35:18 +0000 (17:35 +0800)]
mbed align with pt changes

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agointroduce LWS_WARN_UNUSED_RESULT
Andy Green [Wed, 20 Jan 2016 08:56:06 +0000 (16:56 +0800)]
introduce LWS_WARN_UNUSED_RESULT

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoheader fragment reject empty early
Andy Green [Wed, 20 Jan 2016 01:44:04 +0000 (09:44 +0800)]
header fragment reject empty early

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agotolower remove
Andy Green [Tue, 19 Jan 2016 23:55:41 +0000 (07:55 +0800)]
tolower remove

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoparser issue_char audit
Andy Green [Tue, 19 Jan 2016 23:40:13 +0000 (07:40 +0800)]
parser issue_char audit

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agotimeout also fixup for0middle guy deletion case
Andy Green [Tue, 19 Jan 2016 15:11:39 +0000 (23:11 +0800)]
timeout also fixup for0middle guy deletion case

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agotimeout check take copies since he may be deleted
Andy Green [Tue, 19 Jan 2016 14:34:44 +0000 (22:34 +0800)]
timeout check take copies since he may be deleted

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agotest server http dont print junk if string too long
Andy Green [Tue, 19 Jan 2016 14:20:18 +0000 (22:20 +0800)]
test server http dont print junk if string too long

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agocoverity 156864 fuzxy close socket if connect fails
Andy Green [Tue, 19 Jan 2016 13:44:20 +0000 (21:44 +0800)]
coverity 156864 fuzxy close socket if connect fails

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agocoverity 156863 fuzxy handle cant get socket
Andy Green [Tue, 19 Jan 2016 13:40:41 +0000 (21:40 +0800)]
coverity 156863 fuzxy handle cant get socket

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agocoverity 156860 wsi dereference before NULL check
Andy Green [Tue, 19 Jan 2016 13:32:08 +0000 (21:32 +0800)]
coverity 156860 wsi dereference before NULL check

... bit in reality, wsi can never be NULL

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agocoverity 156861 context destroy dereference context before NULL check
Andy Green [Tue, 19 Jan 2016 13:29:34 +0000 (21:29 +0800)]
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>
8 years agocoverity 156862 unused return value
Andy Green [Tue, 19 Jan 2016 13:27:44 +0000 (21:27 +0800)]
coverity 156862 unused return value

Not exactly a problem...

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agomultithreaded service
Andy Green [Mon, 18 Jan 2016 19:34:24 +0000 (03:34 +0800)]
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>
8 years agofix broken ext arg parsing
Andy Green [Tue, 19 Jan 2016 12:01:33 +0000 (20:01 +0800)]
fix broken ext arg parsing

This gets us back to all the Autobahn tests passing

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agotimeout move to doubly linked list
Andy Green [Mon, 18 Jan 2016 20:32:14 +0000 (04:32 +0800)]
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>
8 years agoFrom 8dc784c121fb387f1871245b3194eae662bddfa3 Mon Sep 17 00:00:00 2001
Andrew Cooks [Sun, 17 Jan 2016 06:23:55 +0000 (14:23 +0800)]
From 8dc784c121fb387f1871245b3194eae662bddfa3 Mon Sep 17 00:00:00 2001
Subject: [PATCH] bump version in rpm spec file.

8 years agoFrom 1e933db07bed7a0b5ac8dc49146815348ae37ded Mon Sep 17 00:00:00 2001
Andrew Cooks [Sun, 17 Jan 2016 06:08:59 +0000 (14:08 +0800)]
From 1e933db07bed7a0b5ac8dc49146815348ae37ded Mon Sep 17 00:00:00 2001
Subject: [PATCH] rpm specfile fixes: group, license, build requires, files

8 years agoFrom 7f39ea761e98ea96f79a7e69d4cdeee0c39d316e Mon Sep 17 00:00:00 2001
Andrew Cooks [Sun, 17 Jan 2016 05:54:13 +0000 (13:54 +0800)]
From 7f39ea761e98ea96f79a7e69d4cdeee0c39d316e Mon Sep 17 00:00:00 2001
Subject: [PATCH] fix missing ${LIB_SUFFIX} on cmake config dir

8 years agoGenerate the API documentation in a reproducible way.
Peter Pentchev [Sun, 17 Jan 2016 00:03:10 +0000 (02:03 +0200)]
Generate the API documentation in a reproducible way.

Sort the list of source files before passing them to the kernel-doc
script so that it always outputs the discovered functions and
structures in the same order.

8 years agoavoid using deallocated things during context dedtroy
Andy Green [Mon, 18 Jan 2016 03:49:41 +0000 (11:49 +0800)]
avoid using deallocated things during context dedtroy

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agofuzxy
Andy Green [Mon, 18 Jan 2016 01:24:35 +0000 (09:24 +0800)]
fuzxy

This is the initial push of a fuzzing proxy we will use for testing lws.

Run libwebsockets-test-fuzxy and the test server if it's local.

Then run the test client with

http_proxy=localhost:8880 libwebsockets-test-client localhost (or whatever)

Right now he only fuzzes one thing but he is operational as a proxy.

8 years agocleaning
Andy Green [Mon, 18 Jan 2016 01:49:24 +0000 (09:49 +0800)]
cleaning

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolws_interface_to_sa
Andy Green [Sat, 16 Jan 2016 04:09:38 +0000 (12:09 +0800)]
lws_interface_to_sa

Expose interface handling code as an api

8 years agouse lws_close not raw close
Andy Green [Sat, 16 Jan 2016 03:14:46 +0000 (11:14 +0800)]
use lws_close not raw close

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoSubject: [PATCH] Make echo test app option consistent with the other test
David Andrade [Fri, 15 Jan 2016 14:45:30 +0000 (09:45 -0500)]
Subject: [PATCH] Make echo test app option consistent with the other test
 options

8 years agopermessage deflate male callback VISIBLE
Andy Green [Fri, 15 Jan 2016 14:16:54 +0000 (22:16 +0800)]
permessage deflate male callback VISIBLE

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agofix client getting hung up on at negotiation
Andy Green [Thu, 14 Jan 2016 07:17:28 +0000 (15:17 +0800)]
fix client getting hung up on at negotiation

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoredirect
Andy Green [Thu, 14 Jan 2016 03:37:56 +0000 (11:37 +0800)]
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>
8 years agoparse_uri
Andy Green [Thu, 14 Jan 2016 05:39:02 +0000 (13:39 +0800)]
parse_uri

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agossl add ECDH server support
Vijay Khurdiya [Fri, 15 Jan 2016 08:21:51 +0000 (16:21 +0800)]
ssl add ECDH server support

(AG clean style add option flag and docs)

8 years agoonly report CLIENT_CONNECTION_ERROR once on some paths
Andy Green [Thu, 14 Jan 2016 03:38:31 +0000 (11:38 +0800)]
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>
8 years agoremove double free attempts from no ACCEPT server response cleanup path
Andy Green [Wed, 13 Jan 2016 10:48:50 +0000 (18:48 +0800)]
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>
8 years agofuzzer eliminate hsecond ah free path firing assert sentinel
Andy Green [Tue, 12 Jan 2016 21:01:17 +0000 (05:01 +0800)]
fuzzer eliminate hsecond ah free path firing assert sentinel

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agofuzzer rx overflow mitigate
Andy Green [Tue, 12 Jan 2016 15:05:02 +0000 (23:05 +0800)]
fuzzer rx overflow mitigate

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolws_client_connect_via_info
Andy Green [Tue, 12 Jan 2016 09:22:06 +0000 (17:22 +0800)]
lws_client_connect_via_info

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agotest client remove abs modulo
Andy Green [Tue, 12 Jan 2016 00:46:56 +0000 (08:46 +0800)]
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>
8 years agoextension permessage deflate
Andy Green [Mon, 11 Jan 2016 03:34:01 +0000 (11:34 +0800)]
extension permessage deflate

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclean libev.c style
Andy Green [Sat, 9 Jan 2016 00:13:55 +0000 (08:13 +0800)]
clean libev.c style

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolibev set events to match revents
Andy Green [Fri, 8 Jan 2016 20:12:46 +0000 (04:12 +0800)]
libev set events to match revents

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agopartial always use partial buffering if send incomplete
Andy Green [Fri, 8 Jan 2016 13:52:47 +0000 (21:52 +0800)]
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>
8 years agoproperly skip protocols with NULL name
Denis Osvald [Mon, 21 Dec 2015 15:39:59 +0000 (16:39 +0100)]
properly skip protocols with NULL name

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
8 years agofix callback typedefs and declarations
Denis Osvald [Mon, 21 Dec 2015 17:06:38 +0000 (18:06 +0100)]
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>
8 years agodoc improve docs around header access apis
Andy Green [Wed, 30 Dec 2015 06:53:50 +0000 (14:53 +0800)]
doc improve docs around header access apis

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoext negotiation tolerate semicolon args
Andy Green [Wed, 30 Dec 2015 04:12:58 +0000 (12:12 +0800)]
ext negotiation tolerate semicolon args

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoutf8 check compatible with extensions
Andy Green [Wed, 30 Dec 2015 03:43:36 +0000 (11:43 +0800)]
utf8 check compatible with extensions

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agooptimize utf8 check tests into state bit
Andy Green [Tue, 29 Dec 2015 04:28:48 +0000 (12:28 +0800)]
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>
8 years agointroduce LWS_SERVER_OPTION_VALIDATE_UTF8
Andy Green [Tue, 29 Dec 2015 03:20:09 +0000 (11:20 +0800)]
introduce LWS_SERVER_OPTION_VALIDATE_UTF8

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn check utf8 on TEXT and CLOSE
Andy Green [Tue, 29 Dec 2015 01:46:03 +0000 (09:46 +0800)]
autobahn check utf8 on TEXT and CLOSE

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn reject forbidden close code ranges
Andy Green [Mon, 28 Dec 2015 10:29:06 +0000 (18:29 +0800)]
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>
8 years agoautobahn README.test apps.md
Andy Green [Mon, 28 Dec 2015 09:11:31 +0000 (17:11 +0800)]
autobahn README.test apps.md

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn reject noncontinuation based on pending FIN state
Andy Green [Mon, 28 Dec 2015 09:05:40 +0000 (17:05 +0800)]
autobahn reject noncontinuation based on pending FIN state

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn detect disordered continuation
Andy Green [Mon, 28 Dec 2015 08:51:08 +0000 (16:51 +0800)]
autobahn detect disordered continuation

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn add same serverside rxflow cache to client
Andy Green [Mon, 28 Dec 2015 06:24:49 +0000 (14:24 +0800)]
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>
8 years agoautobahn reject on reserved opcode or bits
Andy Green [Mon, 28 Dec 2015 06:12:10 +0000 (14:12 +0800)]
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>
8 years agoautobahn test echo extend max echo and follow message boundary
Andy Green [Mon, 28 Dec 2015 04:45:05 +0000 (12:45 +0800)]
autobahn test echo extend max echo and follow message boundary

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoautobahn extend max ping pong close payload to 125
Andy Green [Mon, 28 Dec 2015 05:40:54 +0000 (13:40 +0800)]
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>
8 years agoautobahn report final frag only on final rx bufload
Andy Green [Mon, 28 Dec 2015 04:45:52 +0000 (12:45 +0800)]
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>
8 years agoautobahn requires zero length tx allowed
Andy Green [Mon, 28 Dec 2015 03:14:04 +0000 (11:14 +0800)]
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>
8 years agoautobahn requires zero length rx allowed
Andy Green [Mon, 28 Dec 2015 03:11:55 +0000 (11:11 +0800)]
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>
8 years agoautobahn test echo meddling
Andy Green [Mon, 28 Dec 2015 03:11:06 +0000 (11:11 +0800)]
autobahn test echo meddling

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclean windows warnings
Andy Green [Sun, 27 Dec 2015 10:16:32 +0000 (18:16 +0800)]
clean windows warnings

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agotest server libev
Andy Green [Sun, 27 Dec 2015 01:43:44 +0000 (09:43 +0800)]
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>
8 years agoclarify changelog
Andy Green [Sat, 26 Dec 2015 12:26:11 +0000 (20:26 +0800)]
clarify changelog

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoupdate api docs
Andy Green [Sat, 26 Dec 2015 09:36:29 +0000 (17:36 +0800)]
update api docs

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoclose add api to control sent close frame contents
Andy Green [Sat, 26 Dec 2015 09:20:34 +0000 (17:20 +0800)]
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>
8 years agoclose add callback to get peer close reason
Andy Green [Sat, 26 Dec 2015 07:47:06 +0000 (15:47 +0800)]
close add callback to get peer close reason

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agombed3 remove forcing _DEBUG
Andy Green [Sat, 26 Dec 2015 07:07:45 +0000 (15:07 +0800)]
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>
8 years agombed3 remove unused allocations
Andy Green [Sat, 26 Dec 2015 05:23:11 +0000 (13:23 +0800)]
mbed3 remove unused allocations

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agodeprecate LWS_SEND_BUFFER_POST_PADDING
Andy Green [Sat, 26 Dec 2015 04:03:06 +0000 (12:03 +0800)]
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>
8 years agooutput eliminate redundant post calculation
Andy Green [Sat, 26 Dec 2015 02:07:17 +0000 (10:07 +0800)]
output eliminate redundant post calculation

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoremove MAX_MUX_RECURSION from PRE padding
Andy Green [Sat, 26 Dec 2015 01:08:06 +0000 (09:08 +0800)]
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>
8 years agorearrange private struct packing 2
Andy Green [Sat, 26 Dec 2015 00:56:58 +0000 (08:56 +0800)]
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>
8 years agoRecognize Debian GNU/kFreeBSD as FreeBSD-ish.
Peter Pentchev [Fri, 25 Dec 2015 11:35:40 +0000 (13:35 +0200)]
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.

8 years agorearrange struct packing
Andy Green [Fri, 25 Dec 2015 05:48:20 +0000 (13:48 +0800)]
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>
8 years agohttp header malloc pool implement pool
Andy Green [Fri, 25 Dec 2015 04:44:12 +0000 (12:44 +0800)]
http header malloc pool implement pool

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agohttp header malloc pool allow listen accept flow control
Andy Green [Fri, 25 Dec 2015 01:12:08 +0000 (09:12 +0800)]
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>
8 years agows ping buffer allocate in wsi ws union member
Andy Green [Fri, 25 Dec 2015 05:14:09 +0000 (13:14 +0800)]
ws ping buffer allocate in wsi ws union member

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoinfo struct add padding pool
Andy Green [Fri, 25 Dec 2015 01:17:15 +0000 (09:17 +0800)]
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>
8 years agodetect service tid once and use wsi with valid context to do it
Andy Green [Thu, 24 Dec 2015 05:00:54 +0000 (13:00 +0800)]
detect service tid once and use wsi with valid context to do it

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolibev complete unix plat context init
Andy Green [Wed, 23 Dec 2015 03:55:06 +0000 (11:55 +0800)]
libev complete unix plat context init

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agolibev context destroy
gaby64 [Tue, 22 Dec 2015 04:41:12 +0000 (12:41 +0800)]
libev context destroy

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

8 years agotest ping android compatibility
Andy Green [Tue, 22 Dec 2015 00:17:34 +0000 (08:17 +0800)]
test ping android compatibility

After "emptyVoid" at

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

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agoSubject: [PATCH] Typo in macro name.
Roger A. Light [Sat, 19 Dec 2015 01:26:53 +0000 (01:26 +0000)]
Subject: [PATCH] Typo in macro name.

8 years agouridecoding lws_hdr_fragment_length
Andy Green [Fri, 18 Dec 2015 23:35:23 +0000 (07:35 +0800)]
uridecoding lws_hdr_fragment_length

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agowhitespace tidy
Andy Green [Fri, 18 Dec 2015 23:18:55 +0000 (07:18 +0800)]
whitespace tidy

Signed-off-by: Andy Green <andy.green@linaro.org>
8 years agouridecode no need to require length plus 2
Andy Green [Fri, 18 Dec 2015 08:40:02 +0000 (16:40 +0800)]
uridecode no need to require length plus 2

length + 1 (for the '\0' is enough)

Signed-off-by: Andy Green <andy.green@linaro.org>