1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00
Commit graph

562 commits

Author SHA1 Message Date
Andy Green
acfa1a879e throw out lws_websocket_related cruft
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-11 00:34:43 +08:00
Andy Green
d91d5e8d22 optimize wsi using bitfields and enums to chars
Also max protocols to 5 (overridable by configure) and max extensions
from 10 to 3 by default (also overridable by configure).

wsi is down to 608 on x86_64 with this.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-11 00:34:43 +08:00
Andy Green
e48ba315b8 use context service buffer instead of stack for clent_connect
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-11 00:34:43 +08:00
Andy Green
f54a94b494 use context service buffer instead of stack for clent_connect_2
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-11 00:34:42 +08:00
Andy Green
e310b0c443 use context service buffer instead of stack for create_context
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-11 00:34:42 +08:00
Andy Green
2b40b79e6d fix non ssl changes missed from context api change
http://libwebsockets.org/trac/ticket/11#comment:5

Reported-by: amn
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-10 22:22:01 +08:00
Andy Green
c97067cf69 use context service buffer instead of stack for lws_client_socket_service
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-10 11:03:32 +08:00
Andy Green
0390608a39 use context service buffer instead of stack for server_socket_service
Reduces lws_server_socket_service from 4208 to 80 stack allocation
on x86_64

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-10 10:49:15 +08:00
Andy Green
5f348a80a0 add static stack analysis
You can get a worst-first list of stack allocators like this

$ cat ./lib/.libs/*.su | sort -k2g | tac

On x86_64, currently the ones above 100 bytes are

server.c:126:5:lws_server_socket_service	4208	static
client.c:42:5:lws_client_socket_service	1584	static
libwebsockets.c:1539:1:libwebsocket_create_context	1136	static
libwebsockets.c:783:1:libwebsocket_service_fd	656	static
client-handshake.c:3:22:__libwebsocket_client_connect_2	592	static
libwebsockets.c:2149:6:_lws_log	496	static
server-handshake.c:33:1:handshake_0405	464	static
libwebsockets.c:2102:13:lwsl_emit_stderr	352	static
client.c:351:1:lws_client_interpret_server_handshake	240	static
daemonize.c:93:1:lws_daemonize	224	static
libwebsockets.c:434:1:libwebsockets_get_peer_addresses	208	static
client.c:694:1:libwebsockets_generate_client_handshake	208	static
output.c:534:5:libwebsockets_serve_http_file	192	static
output.c:51:6:lwsl_hexdump	176	static
sha-1.c:316:1:SHA1	160	static
libwebsockets.c:157:1:libwebsocket_close_and_free_session	144	static

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-10 10:49:15 +08:00
Andy Green
f0b79e238c dont try figure out listen_service_fd position if unset
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-10 10:49:11 +08:00
Andy Green
a47865fa19 dont try set per socket keepalive timing on bsds
As per http://libwebsockets.org/trac/ticket/10
BSD doesn't support setting keepalive info per-socket

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-10 09:39:47 +08:00
Andy Green
9e4c917c27 fix broken listen socket piggybacking
As reported here

http://libwebsockets.org/trac/ticket/11

the code for connection storm handling had rotted, fds[0] is no longer
always related to the listen socket when serving.

This patch updates it to determine the listen socket correctly to stop
infinite recursion here.

Reported-by: amn
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-10 09:06:38 +08:00
Andy Green
a690cd066e introduce keepalive option and make common socket options function
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-09 14:27:38 +08:00
Andy Green
da1fb0b89f remove receiving timeout for client
Now we enforce nonblocking everywhere, hopefully properly,
this rx timeout stuff shouldn't be needed.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-09 14:27:30 +08:00
Andy Green
8e0c98484e correct test client to close synchronously with last send
Noticed previously the test client lifetime is decoupled from
the actual send activity.  With SSL if the connection starts but
there is a period of SSL-layer "blocking" (actually fail-and-retry)
the mirror lifetime could be exhausted before the connection really
completed, making it stall after it was then closed.

This corrects that so connection lifetime management is done in the
send callback.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-09 14:27:24 +08:00
Andy Green
e7c97e8429 align max frame for mirror protocol to what the code does
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-09 14:27:15 +08:00
Andy Green
1b26527e72 change context creation params to struct
*** This patch changes an API all apps use ***

Context creation parameters are getting a bit out of control, this
patch creates a struct to contain them.

All the test apps are updated accordingly.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-09 14:01:09 +08:00
Andy Green
0480f6420c handshake bail3 should be bail
Reported-by: Jack Mitchell <ml@communistcode.co.uk>
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-08 20:10:03 +08:00
Andy Green
5449511d3e remove fixed rx buffer allow definition per protocol
A new protocol member is defined that controls the size of rx
buffer allocation per connection.  For compatibility 0 size
allocates 4096, but you should adapt your protocol definition
array in the user code to declare an appropriate value.

See the changelog for more detail.

The advantage is the rx frame buffer size is now tailored to
what is expected from the protocol, rather than being fixed
to a default of 4096.  If your protocol only sends frames of
a dozen bytes this allows you to only allocate an rx frame
buffer of the same size.

For example the per-connection allocation (excluding headers)
for the test server fell from ~4500 to < 750 bytes with this.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-08 13:16:07 +08:00
Andy Green
f27034201f account for context in static allocation figure
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-08 13:11:50 +08:00
Andy Green
9b09dc0213 remove all PATH_MAX or MAX_PATH
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-08 13:11:47 +08:00
Andy Green
e84652c4ea use context service buf in place of large stack arrays
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-08 13:01:02 +08:00
Andy Green
b8b247d3e1 remove need for filepath buffer on http file serve
This gets rid of the stack buffer while serving files, and the
PATH_MAX char array that used to hold the filepath in the wsi.

It holds an extra file descriptor open while serving the file,
however it attempts to stuff the socket with as much of the
file as it can take.  For files of a few KB, that typically
completes (without blocking) in the call to
libwebsockets_serve_http_file() and then closes the file
descriptor before returning.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-08 12:19:01 +08:00
Andy Green
c11b587aed add static linking exception to LICENSE
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 23:44:21 +08:00
Andy Green
750200121e add unchanged lgpl 2.1 in LICENSE
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 23:43:56 +08:00
Peter Pentchev
3b233cbc24 Fix memory leaks when creating a context. 2013-02-07 23:36:52 +08:00
Peter Pentchev
4d46cb5a3f Generate the API reference in text format, too. 2013-02-07 23:36:37 +08:00
Peter Pentchev
c74964ec44 Fix two typos. 2013-02-07 23:23:10 +08:00
Andy Green
ed334463e8 changelog header lifecycle
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 21:14:33 +08:00
Andy Green
23c5f2ecd0 add autotools bits for cyassl
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 20:30:56 +08:00
Andy Green
68a672bb44 unionize header token array
This reduces the size of struct libwebscocket from 4840 to 4552
on x86_64

There are also big benefits on malloc pool fragmentation and
allocation, the header allocations only exist between the first
peer communication and websocket connection establishment for
both server and client.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 20:30:56 +08:00
Andy Green
a2b3a36e44 document header lifecycle change
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 20:30:56 +08:00
Andy Green
2b57a34677 headers deleted after websocket established
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 20:30:56 +08:00
Andy Green
e4dffc99df leverage TOKEN_SKIPPING better in parser
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 20:30:56 +08:00
Andy Green
177ca78921 simplify parsing complete
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 20:30:56 +08:00
Andy Green
3455e676d8 act on fatal parse problems
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 20:30:56 +08:00
Andy Green
c5dc32ab48 remove deprecated vcxproj
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 20:25:28 +08:00
Andy Green
df60b0c089 update changelog about cmake
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-07 20:25:28 +08:00
Joakim Soderberg
7df9908148 Added build instructions for CMake.
Also changed it so that specifying the include directories for CyaSSL is nicer.
2013-02-07 20:24:19 +08:00
Andy Green
039ce8fc7f add README
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-06 16:07:27 +09:00
Joakim Soderberg
f57751f92b Fixed compilation on NetBSD. 2013-02-06 15:49:13 +09:00
Joakim Söderberg
cb4156d437 Cleaned up the CyaSSL linking in the CMake project a bit.
Separated the CyaSSL linking and OpenSSL linking for more clearity.
Now tested on both OSX and Windows as well.
2013-02-06 15:49:13 +09:00
Joakim Soderberg
91de93391c Fixed windows build.
- Fixed the original visual studio project so that inline gets defined.
- Fix error in CMake with zlib.
2013-02-06 15:49:13 +09:00
Joakim Soderberg
e9a42119f6 Added some minor changes to CMake build file.
- Added options for compiling without server/client parts.
- Fixed a syntax error on printing an error on CyaSSL compilation.
- Don't compile server-extpoll either when the server isn't compiled.
2013-02-06 15:49:12 +09:00
Joakim Soderberg
b378ce9d18 Added support for CyaSSL replacement of OpenSSL.
http://www.yassl.com/yaSSL/Products-cyassl.html
- Small Size: 20-100kB
- Runtime Memory:  1-36kB
- 20X smaller than OpenSSL

So far only tested on Linux.

Note that this requires a bugfix in cyassl, otherwise it will crash. Pull request has been made to the official repos, in the meantime the following repos can be used: git://github.com/JoakimSoderberg/cyassl.git
2013-02-06 15:49:12 +09:00
Joakim Soderberg
4f4a38bae0 Added check for inline keyword availability.
Both to CMake project and Autoconf. inline will be defined to whatever inline replacement exists on the system, such as __inline or __inline__
2013-02-06 15:49:12 +09:00
Joakim Söderberg
68e8d730b8 Fixed build on OSX.
- For some reason the "extern int pid_daemon" usage in libwebsockets.c would cause an "undefined symbols" linker error for the test-apps. This only happens with the CMake project, not the normal Makefiles. I have no clue why this is. Fixed it by getting the pid via a function instead.

- Added test-server-extpoll

- Renamed the library from libwebsocket -> libwebsockets
2013-02-06 15:49:12 +09:00
Joakim Soderberg
d2edfec5fa Fixed linux compilation and added more compile options.
- Tested and works on Linux now also, including SSL support.
- Look for ZLIB not zlib.
- Added CMake options for setting all LWS_ defines.
2013-02-06 15:49:12 +09:00
Joakim Soderberg
4c53123677 CMake support + fixed windows build.
- Finalized CMake support (tested on windows only so far).
  - Uses a generated lws_config.h that is included in
  private-libwebsocket to pass defines, only used if CMAKE_BUILD is set.
  - Support for SSL on Windows.
  - Initial support for CyaSSL replacement of OpenSSL (This has been added
    to my older CMake-fork but haven't been tested on this version yet).
- Fixed windows build (see below for details).
- Fixed at least the 32-bit Debug build for the existing Visual Studio
  Project. (Not to keen fixing all the others when we have CMake support
  anyway (which can generate much better project files)...)
- BUGFIXES:
  - handshake.c
    - used C99 definition of handshake_0405 function
  - libwebsocket.c
    - syslog not available on windows, put in ifdefs.
    - Fixed previous known crash bug on Windows where WSAPoll in
      Ws2_32.dll would not be present, causing the poll function pointer
      being set to NULL.
    - Uninitialized variable context->listen_service_extraseen would
      result in stack overflow because of infinite recursion. Fixed by
      initializing in libwebsocket_create_context
    - SO_REUSADDR means something different on Windows compared to Unix.
    - Setting a socket to nonblocking is done differently on Windows.
      (This should probably broken out into a helper function instead)
    - lwsl_emit_syslog -> lwsl_emit_stderr on Windows.
  - private-libwebsocket.h
    - PATH_MAX is not available on Windows, define as MAX_PATH
    - Always define LWS_NO_DAEMONIZE on windows.
    - Don't define lws_latency as inline that does nothing. inline is not
      support by the Microsoft compiler, replaced with an empty define
      instead. (It's __inline in MSVC)
  - server.c
    - Fixed nonblock call on windows
  - test-ping.c
    - Don't use C99 features (Microsoft compiler does not support it).
    - Move non-win32 headers into ifdefs.
    - Skip use of sighandler on Windows.
  - test-server.c
    - ifdef syslog parts on Windows.
2013-02-06 15:49:12 +09:00
Joakim Soderberg
add3926b17 Some more Cmake stuff. 2013-02-06 15:49:12 +09:00