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>
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>
Gregory Junker <ggjunker@gmail.com> noticed the binary flag is not
getting set right, or at all on client side. This should improve
matters.
Signed-off-by: Andy Green <andy.green@linaro.org>
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>
Solve some unchecked return codes in the new daemonization file
AG adapted a bit
Signed-off-by: Edwin van den Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>