Commit graph

2159 commits

Author SHA1 Message Date
Andy Green
0fba8e6ef8 coverity 158146 test fraggle sprintf bounds
Well, just in the test app arg processing, but yes...

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 21:07:09 +08:00
Andy Green
27966c29e1 coverity 158145 lws_header_table_detatch must handle no ah attached
callers should protect it so this doesn't make a problem.  But
Coverity is correct the code is confused about it.

Make it okay if we close a connection before the ah got attached.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 21:03:51 +08:00
Andy Green
1e32c2b67a release checklist coverity
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 21:03:51 +08:00
Andy Green
c62d882939 api doc update pre 1.7
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 21:03:51 +08:00
Andy Green
200a6a296e timeout settable from info
This adds an info member that allows the user code to
set the library's network action timeout in seconds.

If left at the default 0, the build-time default
AWAITING_TIMEOUT continues to be used.

As suggested

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

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 20:39:07 +08:00
Andy Green
eb91ad0964 release checklist api updates
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 20:39:07 +08:00
Andy Green
c9259876d2 http_transaction_completed handle two completions in detach reset order
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 19:05:43 +08:00
Andy Green
2c218e705f ah owns rxbuf
This is intended to solve a longstanding problem with the
relationship between http/1.1 keep-alive and the service
loop.

Ah now contain an rx buffer which is used during header
processing, and the ah may not be detached from the wsi
until the rx buffer is exhausted.

Having the rx buffer in the ah means we can delay using the
rx until a later service loop.

Ah which have pending rx force POLLIN service on the wsi
they are attached to automatically, so we can interleave
general service / connections with draining each ah rx
buffer.

The possible http/1.1 situations and their dispositions are:

 1) exactly one set of http headers come.  After processing,
    the ah is detached since no pending rx left.  If more
    headers come later, a fresh ah is aqcuired when available
    and the rx flow control blocks the read until then.

 2) more that one whole set of headers come and we remain in
    http mode (no upgrade).  The ah is left attached and
    returns to the service loop after the first set of headers.
    We will get forced service due to the ah having pending
    content (respecting flowcontrol) and process the pending
    rx in the ah.  If we use it all up, we will detach the
    ah.

 3) one set of http headers come with ws traffic appended.
    We service the headers, do the upgrade, and keep the ah
    until the remaining ws content is used.  When we
    exhausted the ws traffix in the ah rx buffer, we
    detach the ah.

Since there can be any amount of http/1.1 pipelining on a
connection, and each may be expensive to service, it's now
enforced there is a return to the service loop after each
header set is serviced on a connection.

When I added the forced service for ah with pending buffering,
I added support for it to the windows plat code.  However this
is untested.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 14:57:55 +08:00
Andy Green
8acdd2e7ed autobahn wait for all fork completion
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 14:57:55 +08:00
Andy Green
b414d52066 autobahn put back 2.10 2.11
The test ordering breaks if we try to skip them, just
leave them in.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 14:57:55 +08:00
Andy Green
42f93ffbfa attack.sh add http1.1 pipelining check
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 14:57:55 +08:00
Andy Green
21f128433b release checklist qa
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 12:37:23 +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
Alex Hultman
19bb09133d port test-server-libuv.c from libev to libuv 2016-02-14 09:28:28 +08:00
Alex Hultman
a43c2ac272 libuv initial replace libev version 2016-02-14 07:31:44 +08:00
Andy Green
082e33b91f release-checklist 2016-02-13 12:08:30 +08:00
Dan Albert
cd5e7bff82 Ask sysconf for Android's getdtablesize. 2016-02-12 08:58:16 +08:00
f9267170a3 fixed LWS_PRE description 2016-02-09 15:52:32 +08:00
Andy Green
502521e728 specfile add fuzxy
https://github.com/warmcat/libwebsockets/issues/419

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-09 09:37:11 +08:00
Andy Green
892f03a7d8 lws_reset_header_table dont reset NULL
This is only a temporary, fragile solution.

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

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-09 09:15:02 +08:00
Andy Green
083c73e7e9 license clarification and test apps CC zero
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-08 08:44:21 +08:00
Andy Green
d2c140c8ed lws_parse_uri fix test client use and add more docs
https://github.com/warmcat/libwebsockets/issues/414

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-07 07:28:21 +08:00
Andy Green
99e876d8f7 ah pool take care about freeing headers after parsing
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-06 09:00:09 +08:00
Andy Green
1b89b933a6 debug spew remove ah reset logging
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-03 07:06:52 +08:00
Andy Green
4939a708f8 LWS_WARN_DEPRECATED and fixup older test apps
Enforce no more internal use of deprecated apis (esp in the test apps)

Also signal clearly to users what is on the way out.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-02 09:02:24 +08:00
Andy Green
70e065b5db autobahn add test script
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-01 17:38:15 +08:00
Andy Green
8e1b7cb692 attack.sh exit 0 on success
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-31 11:53:49 +08:00
Andy Green
4019aab8da ah http1.1 deal with pipelined headers properly
Connections must hold an ah for the whole time they are
processing one header set, even if eg, the headers are
fragmented and it involves network roundtrip times.

However on http1.1 / keepalive, it must drop the ah when
there are no more header sets to deal with, and reacquire
the ah later when more data appears.  It's because the
time between header sets / http1.1 requests is unbounded
and the ah would be tied up forever.

But in the case that we got pipelined http1.1 requests,
even partial already buffered, we must keep the ah,
resetting it instead of dropping it.  Because we store
the rx data conveniently in a per-tsi buffer since it only
does one thing at a time per thread, we cannot go back to
the event loop to await a new ah inside one service action.

But no problem since we definitely already have an ah,
let's just reuse it at http completion time if more rx is
already buffered.

NB: attack.sh makes request with echo | nc, this
accidentally sends a trailing '\n' from the echo showing
this problem.  With this patch attack.sh can complete well.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-30 11:43:10 +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
ada3531aff coverity 157401 dont test SHUTDOWN state in mode switch
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 23:17:40 +08:00
Andy Green
e6dbaa236a coverity 157402 explicitly disallow handling invalid sockfd
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 15:40:08 +08:00
Andy Green
6f4e2d297b coverity 157403 fuzxy handle currently impossible error
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 15:35:01 +08:00
Andy Green
b39a151c9c coverity 157404 get rid of needless NULL check
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 15:30:05 +08:00
Andy Green
92f96f3edf cleanup test app startup messages
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 09:35:58 +08:00
Andy Green
4bcbfe1ad4 restrict SO_REUSEPORT to multithreading only so no unexpected change otherwise
SO_REUSEPORT means you don't get any error any more if another
server instance is already running, this will be quite unexpected
for singlethreaded users.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 09:20:00 +08:00
Andy Green
6dd7e86f23 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>
2016-01-29 09:06:22 +08:00
Andy Green
9c444d2709 win dont redefine _WINSOCK_DEPRECATED_NO_WARNINGS
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 01:26:31 +08:00
Danomi Czaski
4e9c7f3504 lextable add x-real-ip
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-28 09:40:53 +08:00
Andy Green
8d5351a0c4 reduce debug logging mark socket dead when pollert
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-27 08:50:31 +08:00
Andy Green
ba119e9057 lws_adopt_socket
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-26 21:40:32 +08:00
Andy Green
8c1f6026a7 multithread stability
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-26 20:56:56 +08:00
Andy Green
dcbe30a28e mbed simplify
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-26 20:45:10 +08:00
Andy Green
aa3c8cd371 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>
2016-01-25 21:39:07 +08:00
Andy Green
0b09734953 fuzxy some toolchains need sys socket.h
https://github.com/warmcat/libwebsockets/issues/407

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-25 21:00:37 +08:00
Andy Green
9666e1d438 fuzzer handle junk after upgrade header
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-21 10:59:07 +08:00
Andy Green
5a0e7866d3 unify bounds checking in parser
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-21 10:57:39 +08:00
Andy Green
7d83bf93e4 fuzxy add test parser and some tests
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-21 10:56:26 +08:00
Andy Green
cb17ad8740 win add dummy LWS_WARN_UNUSED_RESULT
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-21 10:56:20 +08:00
Andy Green
5086597878 mbed align with pt changes
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-20 17:35:18 +08:00
Andy Green
e99a83cb96 introduce LWS_WARN_UNUSED_RESULT
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-20 16:56:06 +08:00