Fix build failure against Atmel ASF3 SDK that does not provide a file
API conforming to POSIX.
libwebsockets/lib/core/libwebsockets.c: In function 'lws_open':
libwebsockets/lib/core/libwebsockets.c:187:18: error: 'O_CREAT' undeclared (first use in this function)
if (((__oflag & O_CREAT) == O_CREAT)
^~~~~~~
In the case http client doesn't get a response and closes, currently
it is confused, it reports it as a CLIENT_CONNECTION_ERROR but then
also a CLOSED_CLIENT_HTTP.
Adapt the logic so we only go that way for ws connection... not getting
the server headers means not reaching ESTABLISHED, which makes it a
CCE not a CLOSE.
Also make sure we never issue a CLOSE type callback if we issued a CCE.
Currently only the low 8 bits of an SS state are proxied in a total packet
length of 8 octets. Keep that format and behaviour since all the defined
states fit in 8 bits, but also allow for 32-bit states using a packet length
of 11 octets with the same command.
This lets us proxy user states (from http mapping) which start at a user
base of 1000.
EXTERNAL_POLL is not recommended for use for a while, it's a hack to allow
integration of lws with random application poll() loops.
While lws is very happy to do that secondary job for any event lib using the
foreign loop support (for uv, event, glib, and ev), for random roll-your-
own poll() waits there's no api because there's no event lib. The solution
with a future is upgrade your application to use an event loop.
The test app that supports EXTERNAL_POLL was broken in Apr 2018, so it's
apparently good news nobody has been using it in new implementations
since then. This patch adds in the missing pieces so we can test it until
it is formally deprecated.
The type of the fields in rtentry is sockaddr, and it is
casted to sockaddr_in. Size-wise it is ok, they should both
be the same size. But casting a pointer breaks build with
optimizations with the following error:
unix-sockets.c:434: error: dereferencing pointer 'addr' does break strict-aliasing rules
Amends commit 3c95483518.
For server, if the adoption of the incoming connection proceeds but then
fails early on, eg, tls alert due to hostname mismatch with cert, the
wsi close happens but it doesn't clean up the invalidated reference to
itself in the server ss object... if it became established, that's handled
by the ss protocol callback.
This patch helps the close path to understand there is a related ss object
and to clean up after itself.
The per-pt priv for event libs ended up overallocated at the context,
and pointed-to by a single pointer composed into each pt. That means
we can't do pointer arithmetic on it any more.
Update a couple of stragglers in libuv event lib to use a pointer in
the pt-priv for the event lib back to the pt instead.
Also in foreign case if we start idle, there may not be anything
happening to trigger the initial idle. So let each pt start with
its idle active.
Before this we simply proxy the CREATING state from the proxy
version of the stream to the client version of the stream.
However this can result in disordering of onward connection
attempt request happening before the client has called back its
CREATING (*state()), meaning that any metadata set in the
state handler is missed for the onward connection.
This patch suppresses the CREATING forwarded from the proxy
and instead does its own local CREATING state callback at the
time the proxy indicates that the remote stream creation
(ie, with the requested policy streamtype) succeeded.
This then guarantees that the client has seen CREATING, and
had a chance to set metadata there, before the onward connection
request goes out. Since metadata has higher priority at the
writeable than the onward connection request it also means
any metadata set in client CREATING gets sync'd to the proxy
before the onward connection.
Formalize the LWSSSSRET_ enums into a type "lws_ss_state_return_t"
returned by the rx, tx and state callbacks, and some private helpers
lws_ss_backoff() and lws_ss_event_helper().
Remove LWSSSSRET_SS_HANDLE_DESTROYED concept... the two helpers that could
have destroyed the ss and returned that, now return LWSSSSRET_DESTROY_ME
to the caller to perform or pass up to their caller instead.
Handle helper returns in all the ss protocols and update the rx / tx
calls to have their returns from rx / tx / event helper and ss backoff
all handled by unified code.