
A new protocol member is defined that controls the size of rx buffer allocation per connection. For compatibility 0 size allocates 4096, but you should adapt your protocol definition array in the user code to declare an appropriate value. See the changelog for more detail. The advantage is the rx frame buffer size is now tailored to what is expected from the protocol, rather than being fixed to a default of 4096. If your protocol only sends frames of a dozen bytes this allows you to only allocate an rx frame buffer of the same size. For example the per-connection allocation (excluding headers) for the test server fell from ~4500 to < 750 bytes with this. Signed-off-by: Andy Green <andy.green@linaro.org>
20 lines
542 B
C
20 lines
542 B
C
|
|
#include <zlib.h>
|
|
|
|
#define DEFLATE_STREAM_CHUNK 128
|
|
#define DEFLATE_STREAM_COMPRESSION_LEVEL 1
|
|
|
|
struct lws_ext_deflate_stream_conn {
|
|
z_stream zs_in;
|
|
z_stream zs_out;
|
|
int remaining_in;
|
|
unsigned char buf_in[LWS_MAX_SOCKET_IO_BUF];
|
|
unsigned char buf_out[LWS_MAX_SOCKET_IO_BUF];
|
|
};
|
|
|
|
extern int lws_extension_callback_deflate_stream(
|
|
struct libwebsocket_context *context,
|
|
struct libwebsocket_extension *ext,
|
|
struct libwebsocket *wsi,
|
|
enum libwebsocket_extension_callback_reasons reason,
|
|
void *user, void *in, size_t len);
|