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>
With these explicit casts that are not needed in C, it's possible to build
the test server using g++ like this, after building and installing the
library.
g++ -DINSTALL_DATADIR=\"/usr/share\" -ocpptest test.cpp -lwebsockets
Add a small documentation to README.coding
Signed-off-by: Andy Green <andy.green@linaro.org>
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>
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>
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>
Either generate debug sections in output or optimize aggressively,
controlled by the existing --disable-debug
Signed-off-by: Andy Green <andy.green@linaro.org>
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>
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>
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>
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>
This puts some numbers of library size with the various --without
and --disable options and about dynamic memory allocation
performance
Signed-off-by: Andy Green <andy.green@linaro.org>