Commit graph

111 commits

Author SHA1 Message Date
Andy Green
3182ece3a4 introduce without extensions
The new --without-extensions config flag completely removes all code
and data related to extensions from the build throughout the library
when given.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-20 17:08:31 +08:00
Andy Green
a1ce6be947 refactor and introduce without server configure option
Move server-only stuff into their own files and make building
that depend on not having --without-server on the configure

Make fragments in other places conditional as well

Remove client-related members from struct libwebscket when
building LWS_NO_CLIENT

Apps:

normal: build test server, client, fraggle, ping
--without-client: build test server
--without-server: build test client, ping

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-18 11:43:21 +08:00
Andy Green
6d1fcb7a95 add lexical parser for headers
Profiling what happens during the ab test, one of the hotspots
was strcasecmp in a loop looking for header name matches each time.

This patch introduces a lexical parser that creates a state machine
in 276 bytes that encodes all the known header names.  The fsm is
walked bytewise as chaacters come in... most states do not need any
recursion to match or fail.

The state machine output is cut-and-pasted into parsers.c as an
unsigned char array.

The fsm generator is a bit rough and ready, included in the tree but
not built since normal mortals won't need to touch it.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-18 01:55:48 +08:00
Andy Green
f7248f8dfa update ping test client and stop exposing payload to extensions
Ping and Pong payload in control messages need to be
above the fray of extension payload munging

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-16 15:12:33 +08:00
Andy Green
03674a655d configure without client
This leverages the refactor patches to introduce the ability to
disable building any client side code in the library or the client
side test apps.

This will be a considerable size saving for embedded server-only
case.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-16 12:35:46 +08:00
Andy Green
d280b6ecb3 http service break into outer loop states
Previously we sat and looped to dump a file over http protocol.

Actually that's a source of blocking to the other sockets being serviced.

This patch breaks up the file service into a roundtrip around the poll()
loop for each 512-byte packet.  It doesn't make much difference if the
server is idle, but if it's busy it makes sure everyone else is getting
service while the file is sent.

It doesn't try to optimize multiple users of the file or to keep the
descriptor open, the point of this patch is to establish the breaking up
of the file send action into the poll loop.

On the user side, there are two differences:

 - context is now needed in the first argument to libwebsockets_serve_http_file()
that's not too bad since we provide context in the callback.

 - file send is now asynchronous to the user code, you get a new callback coming
in protocol 0 when it's done, LWS_CALLBACK_HTTP_FILE_COMPLETION

libwebsockets-test-server is updated accordingly.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-15 16:00:36 +08:00
Andy Green
f7609e9ada logging ensure everyone has a newline
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-15 15:41:15 +08:00
Andy Green
41c5803d0f audit and make all malloc check for OOM
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-12 13:21:08 +08:00
Andy Green
43db045ff8 introduce logging api and convert all library output to use it
- multiple debug context calls lwsl_ err, warn, debug, parser, ext, client

 - api added to set which contexts output to stderr using a bitfield log_level

 - --disable-debug on configure removes all code that is not err or warn severity

 - err and warn contexts always output to stderr unless disabled by log_level

 - err and warn enabled by default in log_level

Signed-off-by: Andy Green <andy@warmcat.com>
2013-01-10 22:16:37 +08:00
Aaron Zinman
4550f1d7b5 compile in xcode, privatize debug macro 2013-01-10 22:14:52 +08:00
David Galeano
651544312c Close connection if LWS_CALLBACK_HTTP returns non-zero. 2013-01-10 12:45:54 +08:00
David Galeano
584b316700 Pass URI length to LWS_CALLBACK_HTTP. 2013-01-10 12:45:53 +08:00
David Galeano
cb19368e14 Fixed compiler warnings on Windows. 2013-01-09 15:29:00 +08:00
Andy Green
cf56e4dd0f cleanup extra wrapping needed on braced define
Signed-off-by: Andy Green <andy.green@linaro.org>
2012-05-03 11:17:08 +08:00
Pasi Mankinen
4d80662a65 workaround osx compiler bug
Signed-off-by: Pasi Mankinen <pasi.t.mankinen@student.jyu.fi>
2012-04-14 07:30:25 +08:00
Andy Green
6ee372fcd8 style cleaning
Signed-off-by: Andy Green <andy.green@linaro.org>
2012-04-09 15:24:22 +08:00
Nick Dowell
f803c0d9df fix heap corruption if HTTP callback calls libwebsocket_close_and_free_session
Signed-off-by: Nick Dowell <nick@nickdowell.com>
2012-04-05 10:29:29 +08:00
Nick Dowell
5519d9f054 handle unsupported protocol correctly
Hi Andy,

First off, thanks for libwebsockets :-)

I've encountered a crash when a client connects to a libwebsockets server
but speicifies an unsupported protocol (Sec-WebSocket-Protocol).
handshake.c should probably be checking that wsi->protocol->name is not
null before doing a strcmp with it...
Attached is a patch for your consideration.

Cheers!
Nick

Signed-off-by: Nick Dowell <nick@nickdowell.com>
2012-04-04 08:27:35 +08:00
Andy Green
15601fd8f1 fix issuing null extension header if none supported
Josh realized that with new Chrome, because we don't support the type of
compression extension yet we returned a null extension header.

This patch fixes that by deferring issuing the extension header until we
find we have something to say.

tested OK on google-chrome 19.0.1081.2-129295

Reported-by: Josh Roberson <josh@asteriasgi.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
2012-03-29 09:27:13 +08:00
Andy Green
cc01247c50 debug move most spew into debug macro
This quietens the spew so all typical debug info now is coming from
the user code (mirror protocol in the sample server / client case).

Signed-off-by: Andy Green <andy@warmcat.com>
2011-11-07 19:53:23 +08:00
Alex Bligh
49146dbcce Add libwebsockets_ensure_user_space
This patch unifies the code for per-connection user allocation, and allows
it to be allocated earlier, duiring HTTP service time.  It's also OK to
attempt allocation multiple times, it will just return any existing
allocation.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
2011-11-07 17:19:25 +08:00
Andy Green
d85cb2083d v08v13 add support v13 default
Signed-off-by: Andy Green <andy@warmcat.com>
2011-09-25 09:32:54 +01:00
Andy Green
66a16f393e x google mux implement child close
This implements clean client and server close for mux child connections,
and deals with accounting for parent child lists.

The mux link can then survive constant connection bringup and teardown
found in the new test client.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 22:07:45 +01: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
33872cd376 carry over 06 stuff to 07
Signed-off-by: Andy Green <andy@warmcat.com>
2011-04-24 05:49:44 +01:00
Andy Green
46c2ea0d6f pass ext pointer in ext callback
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-22 09:04:01 +00:00
Patrick McManus
4bf91d7224 libwebsockets - gcc warnings
you have your makefiles set up to treat warnings as errors, and my gcc
4.4.5 (64 bit) compiler generates 3 warnings that need fixing:

(that sprintf() one is a real bug.. if ext_name contains formatting
characters you are looking at a potential segv).

Signed-off-by: Patrick McManus <mcmanus@ducksong.com>
2011-03-09 07:18:28 +00:00
Andy Green
da527dfdee add extra state for waiting on close ack with timeout
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-07 07:08:12 +00:00
Andy Green
6e5f95e401 allow extensions for parsing
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 13:15:34 +00:00
Andy Green
c511482c78 create server extension response dynamically
This goes through the extentsions the client requested, selects the ones
that we support at the server, and then further calls back to the appropriate
protocol callback in user code to check it's OK to actually use that
extension in this context.  If it is (callback unhandled == it is) then
it's added to the list of extensions sent back to the client.

Accepted extensions are also added to the connection's active extension
list and the private "user" memory allocation for the extension context is
done and bound to the connection.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 10:29:35 +00:00
Peter Hinz
56885f3084 introduce win32 build capability
This adds win32 build compatability to libwebsockets.

The patch is from Peter Hinz, Andy Green has cleaned it up a bit and
possibly broken win32 compatability since I can't test it, so there
may be followup patches.  It compiles fine under Linux after this
patch anyway.

Much of the patch is changing a reserved keyword for Visual C compiler
"this" to "context", but there is no real C99 support in the MSFT
compiler even though it is 2011 so C99 style array declarations
have been mangled back into "ancient C" style.

Some windows-isms are also added like closesocket() but these are
quite localized.  Win32 random is just using C library random() call
at the moment vs Linux /dev/urandom.  canonical hostname detection is
broken in win32 at the moment.

Signed-off-by: Peter Hinz <cerebusrc@gmail.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-02 22:03:47 +00:00
Andy Green
9514bf8839 carry over 05 specific stuff to 06
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-26 11:13:56 +00:00
Andy Green
687b0188bc require close reason argument on close and free session
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-26 11:04:01 +00:00
Andy Green
6274baf8c0 only send sec webscoket nonce on 04
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-26 10:31:41 +00:00
Andy Green
7942dfe282 make origin optional on server
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-26 10:28:15 +00:00
Andy Green
62c54d2f56 introduce this param in callback fix server close on client socket
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-14 09:14:25 +00:00
Andy Green
4b6fbe125e unify server and client close
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-14 08:03:48 +00:00
Andy Green
c85619dbcd introduce-user-handshake-filter-callback.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-02-13 08:25:26 +00:00
Andy Green
44eee688ac optimize-random-device-open.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-02-10 09:32:24 +00:00
Andy Green
18910c5920 parse-and-reject-extensions-header.patch
Signed-off-by: Andy Green <andy@linaro.org>
2011-02-09 08:58:42 +00:00
Andy Green
bfb051f3a3 introduce-ietf-05-framing-and-commandline-options.patch
This adds 05 support, and -v switches on test-client and test-ping
to allow setting their ietf protocol version to 4 or 5.

It also optimizes the masking to us a function pointer, which
takes some conditionals out of the fast path.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-09 08:49:14 +00:00
Andy Green
f3d3b40364 change-client-mode-to-enum.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-09 07:16:34 +00:00
Andy Green
90c7cbcc00 introduce-ssl-client-connections--flow-control.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-27 06:26:52 +00:00
Andy Green
6964bb5ee5 clean--fix-sigpipe.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-23 16:50:33 +00:00
Andy Green
4739e5c450 introduce-client-support.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-22 12:51:57 +00:00
Andy Green
38e57bbd71 introduce-04-control-frames.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-19 12:20:27 +00:00
Andy Green
f85e830f7b introduce-new-04-masking-key-computation.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-18 17:45:00 +00:00
Andy Green
e252217633 introduce-new-04-handshake.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-18 17:14:03 +00:00
Andy Green
d1b11e3d6c introduce-new-04-headers-logic.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-18 15:39:02 +00:00
Andy Green
70dfebde50 use-libcrypto-hash-implementations.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2010-12-20 09:35:03 +00:00