Commit graph

1414 commits

Author SHA1 Message Date
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
Joakim Soderberg
f57751f92b Fixed compilation on NetBSD. 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
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
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
Andy Green
81bbae0375 remove one more mention of broadcast callback
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-01 11:17:02 +08:00
Andy Green
7b40545e92 introduce library version plus git hash
This exposes the library version and git head hash it was built from
into LWS_LIBRARY_VERSION and LWS_BUILD_HASH.

These are combined into a version string that's both printed as a
notice log by the library and made available to the app using a new
api lws_get_library_version().  The version looks like

 1.1 178d78c

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-01 10:50:15 +08:00
Andy Green
2da89dccb0 bump version to 1.1 and soname to 2
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-31 11:01:38 +08:00
Andy Green
98feb4be18 clean out remaining mentions of deprecated broadcast
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-31 11:01:35 +08:00
Andy Green
d09d7d45f8 get error from getnameinfo if unable to improve hostname and use hostname
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-31 10:05:43 +08:00
Andy Green
cbb3122ab4 fixes for without server and without client
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-31 09:57:05 +08:00
Jack Mitchell
daed4fbd54 fix unused var if no enable openssl
Signed-off-by: Jack Mitchell <ml@communistcode.co.uk>
2013-01-30 18:53:36 +08:00
Andy Green
467c7ef552 add info about why we close to more places
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-30 12:28:34 +08:00
Andy Green
96d882a9d8 roubustness handle problems in read loop better
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-30 12:27:27 +08:00
Andy Green
5fc75a9b6b server allow NULL protocol map to protocol 0
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-30 12:26:14 +08:00
Andy Green
aaf0b9f514 change get_peer_addresses to use context wsi latency
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-30 08:49:13 +08:00
Andy Green
e000a709b3 instrument latency
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-30 08:49:12 +08:00
Andy Green
d636e35c2b introduce lws_latency
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-30 08:32:15 +08:00
Andy Green
6f520a5195 evict all broadcast support
Libwebsockets is fundamentally singlethreaded... the existence of the
fork and broadcast support, especially in the sample server is
giving the wrong idea about how to use it.

This replaces broadcast in the sample server with
libwebsocket_callback_on_writable_all_protocol().  The whole idea of
'broadcast' is removed.

All of the broadcast proxy stuff is removed: data must now be sent
from the callback only.  Doing othherwise is not reliable since the
service loop may close the socket and free the wsi at any time,
invalidating a wsi pointer held by another thread (don't do that!)

Likewise the confirm_legit_wsi api added recently does not help the
other thread case, since if the wsi has been freed dereferencing the
wsi to study if it is legit or not will segfault in that case.  So
this is removed too.

The overall effect is to push user code to only operate inside the
protocol callbacks or external poll loops, ie, single thread context.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-29 22:13:55 +08:00
Matthieu Riviere
5e1b7fff3a FreeBSD compatibility
Seems we just need to take care about __FreeBSD__ along with
__APPLE__ in a couple of places.

Signed-off-by: Matthieu Riviere <matthieu.riviere@leukensis.org>
2013-01-29 06:57:21 +08:00
Andy Green
ea0642abb2 trac 6 expose libwebsockets read with note about not normally needed
Comes in handy if the original application poll loop is the boss,
in this case libwebsockets is optional and can't be the boss poll
loop

Requested-by: ajandhyala@wms.com
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-29 06:52:00 +08:00
Edwin van den Oetelaar
0794af94eb fix ssl bits outside of ifdef coverage
Signed-off-by: Edwin van den Oetelaar <oetelaar.automatisering@gmail.com>
2013-01-28 21:53:53 +08:00
Andy Green
c4d05a5fa2 force client ssl bio nonblocking
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-28 17:49:55 +08:00
Andy Green
1167dd4a6e force ssl rw bios nonblocking
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-28 17:49:52 +08:00
Andy Green
ba85a7dbbd timeout coverage for ssl accept
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-28 17:49:51 +08:00
Andy Green
e21607136c break up ssl accept action
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-28 12:19:10 +08:00
Andy Green
6f047eea6c ensure accept is nonblocking
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-28 11:23:52 +08:00
Andy Green
52f28ce67a autocreate foreign broadcast sockets on broadcast
Also introduce libwebsockets_broadcast_foreign() separate from libwebsockets_broadcast()

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-25 17:52:16 +08:00
Andy Green
fefc6585db trac 5 sa_restorer deprecated
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-23 08:32:03 +08:00
Andy Green
d88146da6a trac 3 document write and context_user
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-22 23:09:01 +08:00
Andy Green
75006171d7 trac 4 correct libebsocket_service_fd
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-22 12:32:11 +08:00
Andy Green
35f332bb46 more LWS_NO_DAEMONIZE
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 13:06:38 +08:00
Andy Green
bdd6bf3ccd bind gcc debug generation to_DEBUG
Either generate debug sections in output or optimize aggressively,
controlled by the existing --disable-debug

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 12:19:30 +08:00
Andy Green
623a98dab0 unionize mutually exclusive wsi members
Large chunks of struct libwebsocket members actually have a mutually
exclusive lifecycle, eg, once the http headers are finished they sit
there unused until the instance is destroyed.

This makes a big improvement in memory efficiency by making four
categories of member: always needed, needed for header processing,
needed for http processing, and needed for ws processing.  The last
three are mutually exclusive and bound into a union inside the wsi.

Care needs taking now at "union transitions", although we zeroed down
the struct at init, the other union siblings have been writing the
same memory by the time later member siblings start to use it.  So
it must be cleared down appropriately when we cross from one
mutually-exclusive use to another.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 11:06:34 +08:00
Andy Green
80f168b4ee key_b64 doesnt need to be in wsi
It's only used in some client code and never seen again

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 11:04:49 +08:00
Andy Green
f862463e2e avoid PATH_MAX in bss in daemonize
PATH_MAX is typically 4KB, let's malloc space for the
actual path instead and just have the pointer in bss

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 10:36:12 +08:00
Andy Green
5738c0e838 remove all support for pre v13 protocols
Since v13 was defined as the released ietf version the older versions
are deprecated.  This patch strips out everything to do with the older
versions and gets rid of the option to send stuff unmasked.

The in-tree md5 implementation is then also deleted as nothing needs
it any more, 1280 loc are shed in all

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 09:53:35 +08:00
Andy Green
f5bc1306ef disable private broadcast sockets if enable no fork config option
The whole thing about count_protocols + 1 broadcast sockets and
associated dummy wsis is a workaround for getting a broadcast from
a different process context, if we are running with --enable-no-fork
then we don't need any of it in.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 09:09:52 +08:00
Andy Green
a17c692cd3 log major dynamic allocation info
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-20 20:21:54 +08:00
Andy Green
13ba5bbc63 zlib not needed if no extensions
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-20 18:26:20 +08:00
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
Edwin van den Oetelaar
f6eeabc749 syslog requires format string
Signed-off-by: Edwin van den Oetelaar <oetelaar.automatisering@gmail.com>
2013-01-19 20:01:01 +08:00
Andy Green
24cba92c7e make use of lock file
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 14:39:24 +08:00
FNA
0bf3ef605d windows compatibility changes for private libwebsockets
Signed-off-by: FNA <aqiruse@gmail.com>
2013-01-19 13:58:06 +08:00
Andy Green
fd6764a1fb test server add daemonization flag
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 13:13:48 +08:00
Andy Green
058ba81017 test server use syslog logging
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 13:11:26 +08:00