This patch gets deflate-stream working with x-google-mux.
It adds a clean veto system where are extension can veto the proposal
of any extension when opening a new connection. x-google-mux uses that
in its callback to defeat any use of deflate-stream on mux children.
However deflate stream is allowed on the parent connection and works
transparently now alongside x-google-mux.
Signed-off-by: Andy Green <andy@warmcat.com>
This establishes a pre-close extension check to allow an extension to
veto a close. x-google-mux then uses this to stop ch1 going down
(subchannel 1 is the original socket connection that turns into a mux
parent) if it has active mux children; it just marks ch1 as closed in
its conn struct in that case and returns 1 from the callback to veto.
Code is also added to take care of the case ch1 is 'closed', and the
last child is subsequently closed, it actively calls close on the mux
parent then.
Signed-off-by: Andy Green <andy@warmcat.com>
This also changes the wsi_children array to be indexed by subchannel - 2,
non-existent channels are NULL in there and highest_child_subchannel
is a highwater mark for the highest subchannel ever used. That way we
can immediately get the wsi for a subchannel at the cost of some extra
sparse skipping during management.
This also takes care of scanning for empty slots on allocation and
NULLing on close of subchannel instead of deletion.
Signed-off-by: Andy Green <andy@warmcat.com>
Accidentally included half-done MUX_REAL_CHILD_INDEX_OFFSET addition a couple
of patches back after late night hacking, this patch completes it.
This makes mux added channels start at channel index 2.
1 is reserved for original carrier channel, 0 for as-yet badly defined global mux commands
Signed-off-by: Andy Green <andy@warmcat.com>
This implements clean client and server close for mux child connections,
and deals with accounting for parent child lists.
The mux link can then survive constant connection bringup and teardown
found in the new test client.
Signed-off-by: Andy Green <andy@warmcat.com>
This changes the test client so that for the mirror protocol socket,
the lifetime of the connection is decided randomly to last on the order
of a second or so, then the connection is closed and a new one opened when
the close is complete.
This is to enhance testing of connection bringup and teardown especially
in mux case.
The overall functionality remains the same, spamming circles to all clients.
Signed-off-by: Andy Green <andy@warmcat.com>
Zero length payloads aren't handled properly. This patch
should solve that.
Reported-by: Chee Wooi Saw <cheewooi@gtwholdings.com>
Signed-off-by: Andy Green <andy@warmcat.com>
Client does auto-service server's ping, but then it
fell through and issued it as payload. This fixes that
so there is no payload issued.
Reported-by: Chee Wooi Saw <cheewooi@gtwholdings.com>
Signed-off-by: Andy Green <andy@warmcat.com>
This is initial x-google-mux support. It's disabled by default
since it's very pre-alpha.
1) To enable it, reconfigure with --enable-x-google-mux
2) It conflicts with deflate-stream, use the -u switch on
the test client to disable deflate-stream
3) It deviates from the google standard by sending full
headers in the addchannel subcommand rather than just
changed ones from original connect
4) Quota is not implemented yet
5) Close of subchannel is not really implemented yet
6) Google opcode 0xf is changed to 0x7 to account for
v7 protocol changes to opcode layout
However despite those caveats, in fact it can run the
test client reliably over one socket (both dumb-increment
and lws-mirror-protocol), you can open a browser on the
same test server too and see the circles, etc.
Signed-off-by: Andy Green <andy@warmcat.com>
Mozilla implementationcan issue window of up to 15,
need to match it
Reported-by: Patrick McManus <pmcmanus@mozilla.com>
Signed-off-by: Andy Green <andy@warmcat.com>
Server handshake reply might not come in one packet as pointed out by
Pavel Borzenkov. This replaces his fix with one directly in the packet
state machine.
Signed-off-by: Andy Green <andy@warmcat.com>
Since 'shift' has unsigned integer type,
the following code may lead to infinite cycle
and segfault:
while (shift >= 0) {
if (shift)
buf[0 - pre + n] =
((len >> shift) & 127) | 0x80;
else
buf[0 - pre + n] =
((len >> shift) & 127);
n++;
shift -= 7;
}
Change type to signed integer.
Signed-off-by: Pavel Borzenkov <pavel.borzenkov@auriga.com>
While performing handshake recv() is called only once.
It may return only part of the data and handshake
will fail. This patch modifies libwebsocket_service_fd()
to ensure that there is not data left in the socket.
Signed-off-by: Pavel Borzenkov <pavel.borzenkov@auriga.com>
For the IETF revision 00 send 'Upgrade: WebSocket' header
instead of 'Upgrade: websocket' as described in the IETF standard.
Some servers (for example, phpdaemon) are case-sensitive.
Signed-off-by: Pavel Borzenkov <pavel.borzenkov@auriga.com>
Patrick McManus from Mozilla pointed out that the spec requires a specific kind
of zlib compression, which is raw. You can select that by using a funny api in
zlib. Mozilla are correcting their compression to this, pywebsockets already did
it right in the first place, libwebsockets should now work OK with those.
Signed-off-by: Andy Green <andy@warmcat.com>