whitespace trailing mass cleanout

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2015-12-14 08:52:03 +08:00
parent a01fb52d09
commit 40110e84ab
37 changed files with 392 additions and 410 deletions

View file

@ -127,7 +127,7 @@ lws_client_connect_2(struct lws_context *context, struct lws *wsi)
res = res->ai_next;
}
if (!p) {
freeaddrinfo(result);
goto oom4;
@ -409,7 +409,7 @@ lws_client_connect(struct lws_context *context, const char *address,
* can handle this and then we don't need an actual socket for this
* connection.
*/
if (lws_ext_callback_for_each_extension_type(context, wsi,
LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION,
(void *)address, port) > 0) {

View file

@ -359,7 +359,7 @@ ping_drop:
eff_buf.token = &wsi->u.ws.rx_user_buffer[
LWS_SEND_BUFFER_PRE_PADDING];
eff_buf.token_len = wsi->u.ws.rx_user_buffer_head;
if (lws_ext_callback_for_each_active(wsi,
LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX,
&eff_buf, 0) <= 0) { /* not handle or fail */
@ -385,7 +385,7 @@ ping_drop:
eff_buf.token = &wsi->u.ws.rx_user_buffer[
LWS_SEND_BUFFER_PRE_PADDING];
eff_buf.token_len = wsi->u.ws.rx_user_buffer_head;
if (lws_ext_callback_for_each_active(wsi,
LWS_EXT_CALLBACK_PAYLOAD_RX,
&eff_buf, 0) < 0) /* fail */

View file

@ -85,12 +85,12 @@ int lws_client_socket_service(struct lws_context *context,
n = recv(wsi->sock, (char *)context->service_buffer,
sizeof(context->service_buffer), 0);
if (n < 0) {
if (LWS_ERRNO == LWS_EAGAIN) {
lwsl_debug("Proxy read returned EAGAIN... retrying\n");
return 0;
}
lws_close_and_free_session(context, wsi,
LWS_CLOSE_STATUS_NOSTATUS);
lwsl_err("ERROR reading from proxy socket\n");
@ -236,7 +236,7 @@ int lws_client_socket_service(struct lws_context *context,
context, wsi);
some_wait:
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_SSL;
return 0; /* no error */
}
n = -1;
@ -247,7 +247,7 @@ some_wait:
* retry if new data comes until we
* run into the connection timeout or win
*/
n = ERR_get_error();
if (n != SSL_ERROR_NONE) {
lwsl_err("SSL connect error %lu: %s\n",
@ -261,21 +261,21 @@ some_wait:
wsi->ssl = NULL;
/* fallthru */
case LWS_CONNMODE_WS_CLIENT_WAITING_SSL:
if (wsi->use_ssl) {
if (wsi->mode == LWS_CONNMODE_WS_CLIENT_WAITING_SSL) {
lws_latency_pre(context, wsi);
n = SSL_connect(wsi->ssl);
lws_latency(context, wsi,
"SSL_connect LWS_CONNMODE_WS_CLIENT_WAITING_SSL",
n, n > 0);
if (n < 0) {
n = SSL_get_error(wsi->ssl, n);
if (n == SSL_ERROR_WANT_READ)
goto some_wait;
@ -292,15 +292,15 @@ some_wait:
* are getting serviced inbetweentimes)
* us to get called back when writable.
*/
lwsl_info("SSL_connect WANT_WRITE... retrying\n");
lws_callback_on_writable(context, wsi);
goto some_wait;
}
n = -1;
}
if (n <= 0) {
/*
* retry if new data comes until we
@ -315,7 +315,7 @@ some_wait:
}
}
}
#ifndef USE_WOLFSSL
/*
* See comment above about wolfSSL certificate
@ -343,7 +343,7 @@ some_wait:
} else
wsi->ssl = NULL;
#endif
wsi->mode = LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE2;
lws_set_timeout(wsi, PENDING_TIMEOUT_AWAITING_CLIENT_HS_SEND,
AWAITING_TIMEOUT);

View file

@ -133,7 +133,7 @@ lws_create_context(struct lws_context_creation_info *info)
lwsl_err("info->ka_interval can't be 0 if ka_time used\n");
return NULL;
}
#ifdef LWS_USE_LIBEV
/* (Issue #264) In order to *avoid breaking backwards compatibility*, we
* enable libev mediated SIGINT handling with a default handler of
@ -226,7 +226,7 @@ lws_create_context(struct lws_context_creation_info *info)
if (lws_ext_callback_for_each_extension_type(context, NULL,
LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT, NULL, 0) < 0)
goto bail;
return context;
bail:

View file

@ -18,8 +18,6 @@ struct lws_ext_deflate_frame_conn {
};
extern int lws_extension_callback_deflate_frame(
struct lws_context *context,
const struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len);
struct lws_context *context, const struct lws_extension *ext,
struct lws *wsi, enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len);

View file

@ -7,12 +7,12 @@
#define LWS_ZLIB_WINDOW_BITS 15
#define LWS_ZLIB_MEMLEVEL 8
int lws_extension_callback_deflate_stream(
struct lws_context *context,
const struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len)
int
lws_extension_callback_deflate_stream(struct lws_context *context,
const struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len)
{
struct lws_ext_deflate_stream_conn *conn =
(struct lws_ext_deflate_stream_conn *)user;
@ -38,7 +38,7 @@ int lws_extension_callback_deflate_stream(
n = deflateInit2(&conn->zs_out,
DEFLATE_STREAM_COMPRESSION_LEVEL, Z_DEFLATED,
-LWS_ZLIB_WINDOW_BITS, LWS_ZLIB_MEMLEVEL,
Z_DEFAULT_STRATEGY);
Z_DEFAULT_STRATEGY);
if (n != Z_OK) {
lwsl_err("deflateInit returned %d\n", n);
return 1;

View file

@ -13,8 +13,6 @@ struct lws_ext_deflate_stream_conn {
};
extern int lws_extension_callback_deflate_stream(
struct lws_context *context,
const struct lws_extension *ext,
struct lws *wsi,
enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len);
struct lws_context *context, const struct lws_extension *ext,
struct lws *wsi, enum lws_extension_callback_reasons reason,
void *user, void *in, size_t len);

View file

@ -64,7 +64,7 @@ int lws_ext_callback_for_each_active(struct lws *wsi, int reason,
if (m > handled)
handled = m;
}
return handled;
}
@ -90,7 +90,7 @@ int lws_ext_callback_for_each_extension_type(
ext++;
n++;
}
return 0;
}

View file

@ -61,8 +61,7 @@
#include "getifaddrs.h"
static int
getifaddrs2(struct ifaddrs **ifap,
int af, int siocgifconf, int siocgifflags,
getifaddrs2(struct ifaddrs **ifap, int af, int siocgifconf, int siocgifflags,
size_t ifreq_sz)
{
int ret;
@ -74,7 +73,6 @@ getifaddrs2(struct ifaddrs **ifap,
size_t sz;
struct sockaddr sa_zero;
struct ifreq *ifr;
struct ifaddrs *start, **end = &start;
buf = NULL;
@ -262,8 +260,8 @@ int
main()
{
struct ifaddrs *a = NULL, *b;
getifaddrs2(&a, AF_INET, SIOCGIFCONF,
SIOCGIFFLAGS, sizeof(struct ifreq));
getifaddrs2(&a, AF_INET, SIOCGIFCONF, SIOCGIFFLAGS,
sizeof(struct ifreq));
print_ifaddrs(a);
printf("---\n");
getifaddrs(&b);

View file

@ -201,16 +201,16 @@ static int lws_frag_start(struct lws *wsi, int hdr_token_idx)
if (!hdr_token_idx)
return 1;
if (ah->next_frag_index >= ARRAY_SIZE(ah->frag_index))
return 1;
ah->frags[ah->next_frag_index].offset = ah->pos;
ah->frags[ah->next_frag_index].len = 0;
ah->frags[ah->next_frag_index].next_frag_index = 0;
ah->frag_index[hdr_token_idx] = ah->next_frag_index;
return 0;
}
@ -220,7 +220,7 @@ static int lws_frag_append(struct lws *wsi, unsigned char c)
ah->data[ah->pos++] = c;
ah->frags[ah->next_frag_index].len++;
return ah->pos >= sizeof(ah->data);
}
@ -245,11 +245,11 @@ static int
lws_token_from_index(struct lws *wsi, int index, char **arg, int *len)
{
struct hpack_dynamic_table *dyn;
/* dynamic table only belongs to network wsi */
wsi = lws_http2_get_network_wsi(wsi);
dyn = wsi->u.http2.hpack_dyn_table;
if (index < ARRAY_SIZE(static_token))
@ -257,16 +257,16 @@ lws_token_from_index(struct lws *wsi, int index, char **arg, int *len)
if (!dyn)
return 0;
index -= ARRAY_SIZE(static_token);
if (index >= dyn->num_entries)
return 0;
if (arg && len) {
*arg = dyn->args + dyn->entries[index].arg_offset;
*len = dyn->entries[index].arg_len;
}
return dyn->entries[index].token;
}
@ -275,7 +275,7 @@ lws_hpack_add_dynamic_header(struct lws *wsi, int token, char *arg, int len)
{
struct hpack_dynamic_table *dyn;
int ret = 1;
wsi = lws_http2_get_network_wsi(wsi);
dyn = wsi->u.http2.hpack_dyn_table;
@ -284,7 +284,7 @@ lws_hpack_add_dynamic_header(struct lws *wsi, int token, char *arg, int len)
if (!dyn)
return 1;
wsi->u.http2.hpack_dyn_table = dyn;
dyn->args = lws_malloc(1024);
if (!dyn->args)
goto bail1;
@ -294,25 +294,25 @@ lws_hpack_add_dynamic_header(struct lws *wsi, int token, char *arg, int len)
goto bail2;
dyn->num_entries = 20;
}
if (dyn->next == dyn->num_entries)
return 1;
if (dyn->args_length - dyn->pos < len)
return 1;
dyn->entries[dyn->next].token = token;
dyn->entries[dyn->next].arg_offset = dyn->pos;
if (len)
memcpy(dyn->args + dyn->pos, arg, len);
dyn->entries[dyn->next].arg_len = len;
lwsl_info("%s: added dynamic hdr %d, token %d (%s), len %d\n",
__func__, dyn->next, token, lws_token_to_string(token), len);
dyn->pos += len;
dyn->next++;
return 0;
bail2:
@ -343,7 +343,7 @@ static int lws_write_indexed_hdr(struct lws *wsi, int idx)
}
if (lws_frag_end(wsi))
return 1;
lws_dump_header(wsi, tok);
return 0;
@ -378,14 +378,14 @@ int lws_hpack_interpret(struct lws_context *context,
/* weight */
wsi->u.http2.hpack = HPKS_TYPE;
break;
case HPKS_TYPE:
if (wsi->u.http2.count > (wsi->u.http2.length - wsi->u.http2.padding)) {
lwsl_info("padding eat\n");
break;
}
if (c & 0x80) { /* indexed header field only */
/* just a possibly-extended integer */
wsi->u.http2.hpack_type = HPKT_INDEXED_HDR_7;
@ -430,7 +430,7 @@ int lws_hpack_interpret(struct lws_context *context,
switch(c & 0xf0) {
case 0x10: /* literal header never index */
case 0: /* literal header without indexing */
/*
/*
* follows 0x40 except 4-bit hdr idx
* and don't add to index
*/
@ -469,7 +469,7 @@ int lws_hpack_interpret(struct lws_context *context,
break;
}
break;
case HPKS_IDX_EXT:
wsi->u.http2.hpack_len += (c & 0x7f) << wsi->u.http2.hpack_m;
wsi->u.http2.hpack_m += 7;
@ -508,7 +508,7 @@ pre_data:
wsi->u.http2.hpack_m = 0;
wsi->u.http2.hpack = HPKS_HLEN_EXT;
break;
case HPKS_HLEN_EXT:
wsi->u.http2.hpack_len += (c & 0x7f) <<
wsi->u.http2.hpack_m;
@ -532,7 +532,7 @@ pre_data:
continue;
c1 = wsi->u.http2.hpack_pos & 0x7fff;
wsi->u.http2.hpack_pos = 0;
if (!c1 && prev == HUFTABLE_0x100_PREV)
; /* EOT */
} else {
@ -545,11 +545,11 @@ pre_data:
} else { /* name */
if (lws_parse(context, wsi, c1))
return 1;
}
}
if (--wsi->u.http2.hpack_len == 0) {
switch (wsi->u.http2.hpack_type) {
case HPKT_LITERAL_HDR_VALUE_INCR:
case HPKT_INDEXED_HDR_6_VALUE_INCR: // !!!
@ -562,7 +562,7 @@ pre_data:
default:
break;
}
n = 8;
if (wsi->u.http2.value) {
if (lws_frag_end(wsi))
@ -578,7 +578,7 @@ pre_data:
wsi->u.http2.hpack = HPKS_TYPE;
} else { /* name */
if (wsi->u.hdr.parser_state < WSI_TOKEN_COUNT)
wsi->u.http2.value = 1;
wsi->u.http2.hpack = HPKS_HLEN;
}
@ -590,7 +590,7 @@ pre_data:
wsi->u.http2.hpack = HPKS_TYPE;
break;
}
return 0;
}
@ -603,11 +603,11 @@ static int lws_http2_num(int starting_bits, unsigned long num,
*((*p)++) |= num;
return *p >= end;
}
*((*p)++) |= mask;
if (*p >= end)
return 1;
num -= mask;
while (num >= 128) {
*((*p)++) = 0x80 | (num & 0x7f);
@ -615,7 +615,7 @@ static int lws_http2_num(int starting_bits, unsigned long num,
return 1;
num >>= 7;
}
return 0;
}
@ -625,9 +625,9 @@ int lws_add_http2_header_by_name(struct lws_context *context, struct lws *wsi,
unsigned char **p, unsigned char *end)
{
int len;
lwsl_info("%s: %p %s:%s\n", __func__, *p, name, value);
len = strlen((char *)name);
if (len)
if (name[len - 1] == ':')
@ -647,10 +647,10 @@ int lws_add_http2_header_by_name(struct lws_context *context, struct lws *wsi,
*(*p) = 0; /* non-HUF */
if (lws_http2_num(7, length, p, end))
return 1;
memcpy(*p, value, length);
*p += length;
return 0;
}
@ -664,7 +664,7 @@ int lws_add_http2_header_by_token(struct lws_context *context, struct lws *wsi,
name = lws_token_to_string(token);
if (!name)
return 1;
return lws_add_http2_header_by_name(context, wsi, name, value,
length, p, end);
}
@ -675,9 +675,9 @@ int lws_add_http2_header_status(struct lws_context *context, struct lws *wsi,
{
unsigned char status[10];
int n;
wsi->u.http2.send_END_STREAM = !!(code >= 400);
n = sprintf((char *)status, "%u", code);
if (lws_add_http2_header_by_token(context, wsi,
WSI_TOKEN_HTTP_COLON_STATUS, status,

View file

@ -44,10 +44,10 @@ lws_http2_wsi_from_id(struct lws *wsi, unsigned int sid)
do {
if (wsi->u.http2.my_stream_id == sid)
return wsi;
wsi = wsi->u.http2.next_child_wsi;
} while (wsi);
return NULL;
}
@ -56,16 +56,16 @@ lws_create_server_child_wsi(struct lws_context *context, struct lws *parent_wsi,
unsigned int sid)
{
struct lws *wsi = lws_create_new_server_wsi(context);
if (!wsi)
return NULL;
/* no more children allowed by parent */
if (parent_wsi->u.http2.child_count + 1 ==
parent_wsi->u.http2.peer_settings.setting[
LWS_HTTP2_SETTINGS__MAX_CONCURRENT_STREAMS])
return NULL;
lws_http2_init(&wsi->u.http2.peer_settings);
lws_http2_init(&wsi->u.http2.my_settings);
wsi->u.http2.stream_id = sid;
@ -75,19 +75,19 @@ lws_create_server_child_wsi(struct lws_context *context, struct lws *parent_wsi,
wsi->u.http2.next_child_wsi = parent_wsi->u.http2.next_child_wsi;
parent_wsi->u.http2.next_child_wsi = wsi;
parent_wsi->u.http2.child_count++;
wsi->u.http2.my_priority = 16;
wsi->u.http2.tx_credit = 65535;
wsi->state = WSI_STATE_HTTP2_ESTABLISHED;
wsi->mode = parent_wsi->mode;
wsi->protocol = &context->protocols[0];
lws_ensure_user_space(wsi);
lwsl_info("%s: %p new child %p, sid %d, user_space=%p\n", __func__,
parent_wsi, wsi, sid, wsi->user_space);
return wsi;
}
@ -100,10 +100,10 @@ int lws_remove_server_child_wsi(struct lws_context *context, struct lws *wsi)
(wsi->u.http2.parent_wsi)->u.http2.child_count--;
return 0;
}
w = &((*w)->u.http2.next_child_wsi);
} while (*w);
lwsl_err("%s: can't find %p\n", __func__, wsi);
return 1;
}
@ -113,13 +113,13 @@ lws_http2_interpret_settings_payload(struct http2_settings *settings,
unsigned char *buf, int len)
{
unsigned int a, b;
if (!len)
return 0;
if (len < LWS_HTTP2_SETTINGS_LENGTH)
return 1;
while (len >= LWS_HTTP2_SETTINGS_LENGTH) {
a = (buf[0] << 8) | buf[1];
if (a < LWS_HTTP2_SETTINGS__COUNT) {
@ -130,10 +130,10 @@ lws_http2_interpret_settings_payload(struct http2_settings *settings,
len -= LWS_HTTP2_SETTINGS_LENGTH;
buf += LWS_HTTP2_SETTINGS_LENGTH;
}
if (len)
return 1;
return 0;
}
@ -141,7 +141,7 @@ struct lws *lws_http2_get_network_wsi(struct lws *wsi)
{
while (wsi->u.http2.parent_wsi)
wsi = wsi->u.http2.parent_wsi;
return wsi;
}
@ -161,11 +161,11 @@ int lws_http2_frame_write(struct lws *wsi, int type, int flags,
*p++ = sid >> 16;
*p++ = sid >> 8;
*p++ = sid;
lwsl_info("%s: %p (eff %p). type %d, flags 0x%x, sid=%d, len=%d\n",
__func__, wsi, wsi_eff, type, flags, sid, len,
wsi->u.http2.tx_credit);
if (type == LWS_HTTP2_FRAME_TYPE_DATA) {
if (wsi->u.http2.tx_credit < len)
lwsl_err("%s: %p: sending payload len %d"
@ -178,7 +178,7 @@ int lws_http2_frame_write(struct lws *wsi, int type, int flags,
len + LWS_HTTP2_FRAME_HEADER_LENGTH);
if (n >= LWS_HTTP2_FRAME_HEADER_LENGTH)
return n - LWS_HTTP2_FRAME_HEADER_LENGTH;
return n;
}
@ -212,13 +212,13 @@ lws_http2_parser(struct lws_context *context, struct lws *wsi, unsigned char c)
wsi->state = WSI_STATE_HTTP2_ESTABLISHED_PRE_SETTINGS;
wsi->u.http2.count = 0;
wsi->u.http2.tx_credit = 65535;
/*
/*
* we must send a settings frame -- empty one is OK...
* that must be the first thing sent by server
* and the peer must send a SETTINGS with ACK flag...
*/
lws_set_protocol_write_pending(context, wsi,
LWS_PPS_HTTP2_MY_SETTINGS);
}
@ -279,7 +279,7 @@ lws_http2_parser(struct lws_context *context, struct lws *wsi, unsigned char c)
}
if (wsi->u.http2.count != wsi->u.http2.length)
break;
/* end of frame */
wsi->u.http2.frame_state = 0;
@ -314,7 +314,7 @@ lws_http2_parser(struct lws_context *context, struct lws *wsi, unsigned char c)
lwsl_info("%s: %p: waiting_tx_credit -> wait on writeable\n", __func__, wsi);
swsi->u.http2.waiting_tx_credit = 0;
lws_callback_on_writable(context, swsi);
}
}
break;
}
break;
@ -346,17 +346,17 @@ lws_http2_parser(struct lws_context *context, struct lws *wsi, unsigned char c)
lwsl_info("frame: type 0x%x, flags 0x%x, sid 0x%x, len 0x%x\n",
wsi->u.http2.type, wsi->u.http2.flags, wsi->u.http2.stream_id, wsi->u.http2.length);
wsi->u.http2.count = 0;
wsi->u.http2.stream_wsi = wsi;
if (wsi->u.http2.stream_id)
wsi->u.http2.stream_wsi = lws_http2_wsi_from_id(wsi, wsi->u.http2.stream_id);
switch (wsi->u.http2.type) {
case LWS_HTTP2_FRAME_TYPE_SETTINGS:
/* nonzero sid on settings is illegal */
if (wsi->u.http2.stream_id)
return 1;
if (wsi->u.http2.flags & LWS_HTTP2_FLAG_SETTINGS_ACK) { // ack
} else
/* non-ACK coming in means we must ACK it */
@ -379,21 +379,21 @@ lws_http2_parser(struct lws_context *context, struct lws *wsi, unsigned char c)
return 1;
if (!wsi->u.http2.stream_wsi)
wsi->u.http2.stream_wsi = lws_create_server_child_wsi(context, wsi, wsi->u.http2.stream_id);
/* END_STREAM means after servicing this, close the stream */
wsi->u.http2.END_STREAM = !!(wsi->u.http2.flags & LWS_HTTP2_FLAG_END_STREAM);
lwsl_info("%s: headers END_STREAM = %d\n",__func__, wsi->u.http2.END_STREAM);
update_end_headers:
/* no END_HEADERS means CONTINUATION must come */
wsi->u.http2.END_HEADERS = !!(wsi->u.http2.flags & LWS_HTTP2_FLAG_END_HEADERS);
swsi = wsi->u.http2.stream_wsi;
if (!swsi)
return 1;
/* prepare the hpack parser at the right start */
swsi->u.http2.flags = wsi->u.http2.flags;
swsi->u.http2.length = wsi->u.http2.length;
swsi->u.http2.END_STREAM = wsi->u.http2.END_STREAM;
@ -419,7 +419,7 @@ update_end_headers:
}
break;
}
return 0;
}
@ -430,7 +430,7 @@ int lws_http2_do_pps_send(struct lws_context *context, struct lws *wsi)
int n, m = 0;
lwsl_debug("%s: %p: %d\n", __func__, wsi, wsi->pps);
switch (wsi->pps) {
case LWS_PPS_HTTP2_MY_SETTINGS:
for (n = 1; n < LWS_HTTP2_SETTINGS__COUNT; n++)
@ -459,26 +459,26 @@ int lws_http2_do_pps_send(struct lws_context *context, struct lws *wsi)
/* this is the end of the preface dance then? */
if (wsi->state == WSI_STATE_HTTP2_ESTABLISHED_PRE_SETTINGS) {
wsi->state = WSI_STATE_HTTP2_ESTABLISHED;
wsi->u.http.fd = LWS_INVALID_FILE;
if (lws_is_ssl(lws_http2_get_network_wsi(wsi))) {
lwsl_info("skipping nonexistant ssl upgrade headers\n");
break;
}
/*
/*
* we need to treat the headers from this upgrade
* as the first job. These need to get
* shifted to stream ID 1
*/
lwsl_info("%s: setting up sid 1\n", __func__);
swsi = wsi->u.http2.stream_wsi = lws_create_server_child_wsi(context, wsi, 1);
/* pass on the initial headers to SID 1 */
swsi->u.http.ah = wsi->u.http.ah;
wsi->u.http.ah = NULL;
lwsl_info("%s: inherited headers %p\n", __func__, swsi->u.http.ah);
swsi->u.http2.tx_credit = wsi->u.http2.peer_settings.setting[LWS_HTTP2_SETTINGS__INITIAL_WINDOW_SIZE];
lwsl_info("initial tx credit on conn %p: %d\n", swsi, swsi->u.http2.tx_credit);
@ -503,7 +503,7 @@ int lws_http2_do_pps_send(struct lws_context *context, struct lws *wsi)
default:
break;
}
return 0;
}

View file

@ -39,13 +39,13 @@ static const char *set[] = {
"sec-websocket-key:",
"sec-websocket-version:",
"sec-websocket-origin:",
":authority:",
":method:",
":path:",
":scheme:",
":status:",
"accept-charset:",
"accept-ranges:",
"access-control-allow-origin:",
@ -80,7 +80,7 @@ static const char *set[] = {
"via:",
"www-authenticate:",
"proxy ",
"patch",
"put",
"delete",

View file

@ -29,11 +29,12 @@ void lws_feature_status_libev(struct lws_context_creation_info *info)
lwsl_notice("libev support compiled in but disabled\n");
}
static void
static void
lws_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
{
struct lws_pollfd eventfd;
struct lws_io_watcher *lws_io = container_of(watcher, struct lws_io_watcher, watcher);
struct lws_io_watcher *lws_io = container_of(watcher,
struct lws_io_watcher, watcher);
struct lws_context *context = lws_io->context;
if (revents & EV_ERROR)
@ -51,8 +52,7 @@ lws_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
}
LWS_VISIBLE void
lws_sigint_cb(struct ev_loop *loop,
struct ev_signal *watcher, int revents)
lws_sigint_cb(struct ev_loop *loop, struct ev_signal *watcher, int revents)
{
ev_break(loop, EVBREAK_ALL);
}
@ -87,7 +87,7 @@ lws_initloop(
loop = ev_default_loop(0);
context->io_loop = loop;
/*
* Initialize the accept w_accept with the listening socket
* and register a callback for read operations:
@ -142,10 +142,10 @@ lws_libev_accept(struct lws_context *context,
if (!LWS_LIBEV_ENABLED(context))
return;
new_wsi->w_read.context = context;
new_wsi->w_write.context = context;
ev_io_init(r, lws_accept_cb, accept_fd, EV_READ);
ev_io_init(w, lws_accept_cb, accept_fd, EV_WRITE);
new_wsi->w_read.context = context;
new_wsi->w_write.context = context;
ev_io_init(r, lws_accept_cb, accept_fd, EV_READ);
ev_io_init(w, lws_accept_cb, accept_fd, EV_WRITE);
}
LWS_VISIBLE void

View file

@ -121,7 +121,7 @@ lws_close_and_free_session(struct lws_context *context,
* are his extensions okay with him closing? Eg he might be a mux
* parent and just his ch1 aspect is closing?
*/
if (lws_ext_callback_for_each_active(wsi,
LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE, NULL, 0) > 0) {
lwsl_ext("extension vetoed close\n");
@ -269,7 +269,7 @@ just_kill_connection:
wsi->mode, old_state);
/* deallocate any active extension contexts */
if (lws_ext_callback_for_each_active(wsi, LWS_EXT_CALLBACK_DESTROY,
NULL, 0) < 0)
lwsl_warn("extension destruction failed\n");
@ -335,7 +335,7 @@ lws_get_addresses(struct lws_context *context, void *ads, char *name,
getnameinfo((struct sockaddr *)ads,
sizeof(struct sockaddr_in6), name,
name_len, NULL, 0, 0);
return 0;
} else
#endif
@ -440,7 +440,7 @@ lws_get_peer_addresses(struct lws_context *context, struct lws *wsi,
lwsl_warn("getpeername: %s\n", strerror(LWS_ERRNO));
goto bail;
}
ret = lws_get_addresses(context, p, name, name_len, rip, rip_len);
bail:
@ -667,7 +667,7 @@ int user_callback_handle_rxflow(callback_function callback_function,
* @context: pointer to struct lws_context you want set proxy to
* @proxy: pointer to c string containing proxy in format address:port
*
* Returns 0 if proxy string was parsed and proxy was setup.
* Returns 0 if proxy string was parsed and proxy was setup.
* Returns -1 if @proxy is NULL or has incorrect format.
*
* This is only required if your OS does not provide the http_proxy
@ -685,7 +685,7 @@ lws_set_proxy(struct lws_context *context, const char *proxy)
{
char *p;
char authstring[96];
if (!proxy)
return -1;
@ -703,7 +703,7 @@ lws_set_proxy(struct lws_context *context, const char *proxy)
goto auth_too_long;
lwsl_notice(" Proxy auth in use\n");
proxy = p + 1;
} else
context->proxy_basic_auth_token[0] = '\0';
@ -876,11 +876,11 @@ lws_is_ssl(struct lws *wsi)
* write on this connection is still buffered, and can't be cleared without
* returning to the service loop and waiting for the connection to be
* writeable again.
*
*
* If you will try to do >1 lws_write call inside a single
* WRITEABLE callback, you must check this after every write and bail if
* set, ask for a new writeable callback and continue writing from there.
*
*
* This is never set at the start of a writeable callback, but any write
* may set it.
*/
@ -888,7 +888,7 @@ lws_is_ssl(struct lws *wsi)
LWS_VISIBLE int
lws_partial_buffered(struct lws *wsi)
{
return !!wsi->truncated_send_len;
return !!wsi->truncated_send_len;
}
void lws_set_protocol_write_pending(struct lws_context *context,
@ -896,7 +896,7 @@ void lws_set_protocol_write_pending(struct lws_context *context,
enum lws_pending_protocol_send pend)
{
lwsl_info("setting pps %d\n", pend);
if (wsi->pps)
lwsl_err("pps overwrite\n");
wsi->pps = pend;
@ -914,7 +914,7 @@ lws_get_peer_write_allowance(struct lws *wsi)
/* user is only interested in how much he can send, or that he can't */
if (wsi->u.http2.tx_credit <= 0)
return 0;
return wsi->u.http2.tx_credit;
#else
(void)wsi;

View file

@ -104,7 +104,7 @@ public:
public:
TCPStream *ts;
public:
struct lws *wsi;
char buffer[BUFFER_SIZE];
@ -144,7 +144,7 @@ extern "C" {
#else
#define LWS_POSIX 1
#endif
#include "lws_config.h"
#if defined(WIN32) || defined(_WIN32)
@ -178,13 +178,13 @@ extern "C" {
#else
#define LWS_EXTERN
#endif
#define LWS_INVALID_FILE INVALID_HANDLE_VALUE
#define LWS_O_RDONLY _O_RDONLY
#else /* NOT WIN32 */
#include <unistd.h>
#define LWS_INVALID_FILE -1
#define LWS_O_RDONLY O_RDONLY
@ -214,7 +214,7 @@ extern "C" {
#ifndef LWS_EXTERN
#define LWS_EXTERN extern
#endif
#ifdef _WIN32
#define random rand
#else
@ -318,7 +318,7 @@ enum lws_context_options {
LWS_SERVER_OPTION_DISABLE_IPV6 = 32,
LWS_SERVER_OPTION_DISABLE_OS_CA_CERTS = 64,
LWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED = 128,
/****** add new things just above ---^ ******/
};
@ -423,9 +423,9 @@ typedef int lws_filefd_type;
* passed in via 'in'
*/
struct lws_pollargs {
lws_sockfd_type fd; /* applicable socket descriptor */
int events; /* the new event mask */
int prev_events; /* the previous event mask */
lws_sockfd_type fd; /* applicable socket descriptor */
int events; /* the new event mask */
int prev_events; /* the previous event mask */
};
/**
@ -507,13 +507,13 @@ enum lws_write_protocol {
/* Same as write_http but we know this write ends the transaction */
LWS_WRITE_HTTP_FINAL = 7,
/* HTTP2 */
LWS_WRITE_HTTP_HEADERS = 8,
/****** add new things just above ---^ ******/
/* flags */
LWS_WRITE_NO_FIN = 0x40,
@ -587,7 +587,7 @@ enum lws_token_indexes {
WSI_TOKEN_HTTP_COLON_PATH = 37,
WSI_TOKEN_HTTP_COLON_SCHEME = 38,
WSI_TOKEN_HTTP_COLON_STATUS = 39,
WSI_TOKEN_HTTP_ACCEPT_CHARSET = 40,
WSI_TOKEN_HTTP_ACCEPT_RANGES = 41,
WSI_TOKEN_HTTP_ACCESS_CONTROL_ALLOW_ORIGIN = 42,
@ -622,13 +622,13 @@ enum lws_token_indexes {
WSI_TOKEN_HTTP_VIA = 71,
WSI_TOKEN_HTTP_WWW_AUTHENTICATE = 72,
WSI_TOKEN_PROXY,
WSI_TOKEN_PATCH_URI = 73,
WSI_TOKEN_PUT_URI = 74,
WSI_TOKEN_DELETE_URI = 75,
WSI_TOKEN_HTTP_URI_ARGS = 76,
/* use token storage to stash these */
_WSI_TOKEN_CLIENT_SENT_PROTOCOLS = 77,
@ -636,9 +636,9 @@ enum lws_token_indexes {
_WSI_TOKEN_CLIENT_URI = 79,
_WSI_TOKEN_CLIENT_HOST = 80,
_WSI_TOKEN_CLIENT_ORIGIN = 81,
/****** add new things just above ---^ ******/
/* always last real token index*/
WSI_TOKEN_COUNT,
@ -762,7 +762,7 @@ enum lws_close_status {
LWS_CLOSE_STATUS_EXTENSION_REQUIRED = 1010,
LWS_CLOSE_STATUS_UNEXPECTED_CONDITION = 1011,
LWS_CLOSE_STATUS_TLS_FAILURE = 1015,
/****** add new things just above ---^ ******/
LWS_CLOSE_STATUS_NOSTATUS_CONTEXT_DESTROY = 9999,
@ -910,7 +910,7 @@ struct lws_extension;
* receiving anything. Because this happens immediately after the
* network connection from the client, there's no websocket protocol
* selected yet so this callback is issued only to protocol 0.
*
*
* LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED: A new client just had
* been connected, accepted, and instantiated into the pool. This
* callback allows setting any relevant property to it. Because this
@ -1263,7 +1263,7 @@ struct lws_extension {
* extensions this context supports. If you configured with
* --without-extensions, you should give NULL here.
* @token_limits: NULL or struct lws_token_limits pointer which is initialized
* with a token length limit for each possible WSI_TOKEN_***
* with a token length limit for each possible WSI_TOKEN_***
* @ssl_cert_filepath: If libwebsockets was compiled to use ssl, and you want
* to listen using SSL, set to the filepath to fetch the
* server cert from, otherwise NULL for unencrypted
@ -1278,7 +1278,7 @@ struct lws_extension {
* @http_proxy_address: If non-NULL, attempts to proxy via the given address.
* If proxy auth is required, use format
* "username:password@server:port"
* @http_proxy_port: If http_proxy_address was non-NULL, uses this port at the address
* @http_proxy_port: If http_proxy_address was non-NULL, uses this port at the address
* @gid: group id to change to after setting listen socket, or -1.
* @uid: user id to change to after setting listen socket, or -1.
* @options: 0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK
@ -1336,7 +1336,7 @@ lwsl_emit_syslog(int level, const char *line);
LWS_VISIBLE LWS_EXTERN struct lws_context *
lws_create_context(struct lws_context_creation_info *info);
LWS_VISIBLE LWS_EXTERN int
lws_set_proxy(struct lws_context *context, const char *proxy);
@ -1360,7 +1360,7 @@ lws_add_http_header_by_name(struct lws_context *context,
int length,
unsigned char **p,
unsigned char *end);
LWS_VISIBLE LWS_EXTERN int
LWS_VISIBLE LWS_EXTERN int
lws_finalize_http_header(struct lws_context *context,
struct lws *wsi,
unsigned char **p,
@ -1380,11 +1380,9 @@ lws_add_http_header_content_length(struct lws_context *context,
unsigned char **p,
unsigned char *end);
LWS_VISIBLE LWS_EXTERN int
lws_add_http_header_status(struct lws_context *context,
struct lws *wsi,
unsigned int code,
unsigned char **p,
unsigned char *end);
lws_add_http_header_status(struct lws_context *context, struct lws *wsi,
unsigned int code, unsigned char **p,
unsigned char *end);
LWS_EXTERN int
lws_http_transaction_completed(struct lws *wsi);
@ -1393,23 +1391,18 @@ lws_http_transaction_completed(struct lws *wsi);
typedef void (lws_ev_signal_cb)(EV_P_ struct ev_signal *w, int revents);
LWS_VISIBLE LWS_EXTERN int
lws_sigint_cfg(
struct lws_context *context,
int use_ev_sigint,
lws_ev_signal_cb* cb);
lws_sigint_cfg(struct lws_context *context, int use_ev_sigint,
lws_ev_signal_cb *cb);
LWS_VISIBLE LWS_EXTERN int
lws_initloop(
struct lws_context *context, struct ev_loop *loop);
lws_initloop(struct lws_context *context, struct ev_loop *loop);
LWS_VISIBLE void
lws_sigint_cb(
struct ev_loop *loop, struct ev_signal *watcher, int revents);
lws_sigint_cb(struct ev_loop *loop, struct ev_signal *watcher, int revents);
#endif /* LWS_USE_LIBEV */
LWS_VISIBLE LWS_EXTERN int
lws_service_fd(struct lws_context *context,
struct lws_pollfd *pollfd);
lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd);
LWS_VISIBLE LWS_EXTERN void *
lws_context_user(struct lws_context *context);
@ -1435,7 +1428,7 @@ enum pending_timeout {
PENDING_TIMEOUT_HTTP_CONTENT = 10,
PENDING_TIMEOUT_AWAITING_CLIENT_HS_SEND = 11,
PENDING_FLUSH_STORED_SEND_BEFORE_CLOSE = 12,
/****** add new things just above ---^ ******/
};
@ -1460,8 +1453,7 @@ lws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs);
* // fill your part of the buffer... for example here it's all zeros
* memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, 128);
*
* lws_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128,
* LWS_WRITE_TEXT);
* lws_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128, LWS_WRITE_TEXT);
*
* When sending LWS_WRITE_HTTP, there is no protocol addition and you can just
* use the whole buffer without taking care of the above.
@ -1491,7 +1483,7 @@ lws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs);
#if __x86_64__
#define _LWS_PAD_SIZE 16 /* Intel recommended for best performance */
#else
#define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target architecture */
#define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target arch */
#endif
#define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? \
((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n))
@ -1554,14 +1546,14 @@ lws_remaining_packet_payload(struct lws *wsi);
* if the protocol does not have any guidance, returns -1. Currently only
* http2 connections get send window information from this API. But your code
* should use it so it can work properly with any protocol.
*
*
* If nonzero return is the amount of payload data the peer or intermediary has
* reported it has buffer space for. That has NO relationship with the amount
* of buffer space your OS can accept on this connection for a write action.
*
*
* This number represents the maximum you could send to the peer or intermediary
* on this connection right now without it complaining.
*
*
* lws manages accounting for send window updates and payload writes
* automatically, so this number reflects the situation at the peer or
* intermediary dynamically.
@ -1630,8 +1622,7 @@ LWS_VISIBLE LWS_EXTERN int
lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h);
LWS_VISIBLE LWS_EXTERN int
lws_hdr_copy(struct lws *wsi, char *dest, int len,
enum lws_token_indexes h);
lws_hdr_copy(struct lws *wsi, char *dest, int len, enum lws_token_indexes h);
/* get the active file operations struct */
LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops *

View file

@ -27,13 +27,13 @@ LWS_VISIBLE int lws_get_random(struct lws_context *context,
* MBED3 does not have a 'kernel' which takes copies of what userland wants
* to send. The user application must hold the tx buffer until it is informed
* that send of the user buffer was complete.
*
*
* So as soon as you send something the pipe is globally choked.
*
*
* There is no concept of additional sent things being maybe acceptable.
* You can send one thing up to 64KB at a time and may not try to send
* anything else until that is completed.
*
*
* You can send things on other sockets, but they cannot complete until they
* get their turn at the network device.
*/
@ -76,7 +76,7 @@ lws_poll_listen_fd(struct lws_pollfd *fd)
*
* This function let a call to lws_service() waiting for a timeout
* immediately return.
*
*
* There is no poll() in MBED3, he will fire callbacks when he feels like
* it.
*/

View file

@ -4,9 +4,9 @@
extern "C" void *mbed3_create_tcp_stream_socket(void)
{
lws_conn_listener *srv = new lws_conn_listener;
//lwsl_notice("%s: %p\r\n", __func__, (void *)srv);
return (void *)srv;
}
@ -14,9 +14,9 @@ extern "C" void *mbed3_create_tcp_stream_socket(void)
extern "C" void mbed3_delete_tcp_stream_socket(void *sock)
{
lws_conn *conn = (lws_conn *)sock;
conn->ts->close();
lwsl_notice("%s: wsi %p: conn %p\r\n", __func__, (void *)conn->wsi, sock);
delete conn;
}
@ -26,7 +26,7 @@ void lws_conn::serialized_writeable(struct lws *_wsi)
struct lws *wsi = (struct lws *)_wsi;
struct lws_pollfd pollfd;
lws_conn *conn = (lws_conn *)wsi->sock;
conn->awaiting_on_writeable = 0;
pollfd.fd = wsi->sock;
@ -41,7 +41,7 @@ void lws_conn::serialized_writeable(struct lws *_wsi)
extern "C" void mbed3_tcp_stream_bind(void *sock, int port, struct lws *wsi)
{
lws_conn_listener *srv = (lws_conn_listener *)sock;
lwsl_debug("%s\r\n", __func__);
/* associate us with the listening wsi */
((lws_conn *)srv)->set_wsi(wsi);
@ -63,7 +63,7 @@ lws_plat_change_pollfd(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pfd)
{
lws_conn *conn = (lws_conn *)wsi->sock;
(void)context;
if (pfd->events & POLLOUT) {
conn->awaiting_on_writeable = 1;
@ -72,12 +72,12 @@ lws_plat_change_pollfd(struct lws_context *context,
minar::Scheduler::postCallback(book.bind(wsi));
lwsl_debug("%s: wsi %p (booked callback)\r\n", __func__, (void *)wsi);
} else {
lwsl_debug("%s: wsi %p (set awaiting_on_writeable)\r\n", __func__, (void *)wsi);
}
} else
conn->awaiting_on_writeable = 0;
return 0;
}
@ -87,9 +87,9 @@ lws_ssl_capable_read_no_ssl(struct lws_context *context,
{
socket_error_t err;
size_t _len = len;
lwsl_debug("%s\r\n", __func__);
(void)context;
err = ((lws_conn *)wsi->sock)->ts->recv((char *)buf, &_len);
if (err == SOCKET_ERROR_NONE) {
@ -116,10 +116,10 @@ lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len)
lws_conn *conn = (lws_conn *)wsi->sock;
lwsl_debug("%s: wsi %p: write %d (from %p)\n", __func__, (void *)wsi, len, (void *)buf);
lwsl_debug("%s: wsi %p: clear writeable\n", __func__, (void *)wsi);
conn->writeable = 0;
err = conn->ts->send((char *)buf, len);
if (err == SOCKET_ERROR_NONE)
return len;
@ -160,19 +160,19 @@ void lws_conn_listener::start(const uint16_t port)
void lws_conn::onRX(Socket *s)
{
struct lws_pollfd pollfd;
(void)s;
pollfd.fd = this;
pollfd.events = POLLIN;
pollfd.revents = POLLIN;
lwsl_debug("%s: lws %p\n", __func__, wsi);
lws_service_fd(lws_get_ctx(wsi), &pollfd);
}
/*
/*
* this gets called from the OS when the TCPListener gets a connection that
* needs accept()-ing. LWS needs to run the associated flow.
*/
@ -186,7 +186,7 @@ void lws_conn_listener::onIncoming(TCPListener *tl, void *impl)
onError(tl, SOCKET_ERROR_NULL_PTR);
return;
}
conn = new(lws_conn);
if (!conn) {
lwsl_err("OOM\n");
@ -196,7 +196,7 @@ void lws_conn_listener::onIncoming(TCPListener *tl, void *impl)
if (!conn->ts)
return;
/*
/*
* we use the listen socket wsi to get started, but a new wsi is
* created. mbed3_tcp_stream_accept() is also called from
* here to bind the conn and new wsi together
@ -265,14 +265,14 @@ void lws_conn::onSent(Socket *s, uint16_t len)
(void)s;
(void)len;
if (!awaiting_on_writeable) {
lwsl_debug("%s: wsi %p (setting writable=1)\r\n",
__func__, (void *)wsi);
writeable = 1;
return;
}
writeable = 1;
pollfd.fd = wsi->sock;
@ -280,7 +280,7 @@ void lws_conn::onSent(Socket *s, uint16_t len)
pollfd.revents = POLLOUT;
lwsl_debug("%s: wsi %p (servicing now)\r\n", __func__, (void *)wsi);
lws_service_fd(lws_get_ctx(wsi), &pollfd);
}

View file

@ -218,7 +218,7 @@ lws_plat_set_socket_options(struct lws_context *context, lws_sockfd_type fd)
DWORD dwBytesRet;
struct tcp_keepalive alive;
struct protoent *tcp_proto;
if (context->ka_time) {
/* enable keepalive on this socket */
optval = 1;
@ -230,7 +230,7 @@ lws_plat_set_socket_options(struct lws_context *context, lws_sockfd_type fd)
alive.keepalivetime = context->ka_time;
alive.keepaliveinterval = context->ka_interval;
if (WSAIoctl(fd, SIO_KEEPALIVE_VALS, &alive, sizeof(alive),
if (WSAIoctl(fd, SIO_KEEPALIVE_VALS, &alive, sizeof(alive),
NULL, 0, &dwBytesRet, NULL, NULL))
return 1;
}
@ -347,10 +347,10 @@ lws_plat_change_pollfd(struct lws_context *context,
struct lws *wsi, struct lws_pollfd *pfd)
{
long networkevents = LWS_POLLHUP;
if ((pfd->events & LWS_POLLIN))
networkevents |= LWS_POLLIN;
if ((pfd->events & LWS_POLLOUT))
networkevents |= LWS_POLLOUT;
@ -366,7 +366,7 @@ lws_plat_change_pollfd(struct lws_context *context,
LWS_VISIBLE const char *
lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt)
{
{
WCHAR *buffer;
DWORD bufferlen = cnt;
BOOL ok = FALSE;
@ -481,7 +481,7 @@ _lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
(void)len;
lwsl_err("%s: not implemented yet on this platform\n", __func__);
return -1;
}

View file

@ -36,7 +36,7 @@ static struct huf huf_literal[] = {
/* 0x09 */ { 0xffffea, 24 },
/* 0x0a */ { 0x3ffffffc, 30 },
/* 0x0b */ { 0xfffffe9, 28 },
/* 0x0c */ { 0xfffffea, 28 },
/* 0x0d */ { 0x3ffffffd, 30 },
/* 0x0e */ { 0xfffffeb, 28 },
@ -85,7 +85,7 @@ static struct huf huf_literal[] = {
/* 0x39 */ { 0x1f, 6 },
/* 0x3a */ { 0x5c, 7 },
/* 0x3b */ { 0xfb, 8 },
/* 0x3c */ { 0x7ffc, 15 },
/* 0x3d */ { 0x20, 6 },
/* 0x3e */ { 0xffb, 12 },
@ -134,7 +134,7 @@ static struct huf huf_literal[] = {
/* 0x69 */ { 0x6, 5 },
/* 0x6a */ { 0x74, 7 },
/* 0x6b */ { 0x75, 7 },
/* 0x6c */ { 0x28, 6 },
/* 0x6d */ { 0x29, 6 },
@ -184,7 +184,7 @@ static struct huf huf_literal[] = {
/* 0x99 */ { 0x1fffdc, 21 },
/* 0x9a */ { 0x3fffd8, 22 },
/* 0x9b */ { 0x7fffe5, 23 },
/* 0x9c */ { 0x3fffd9, 22 },
/* 0x9d */ { 0x7fffe6, 23 },
/* 0x9e */ { 0x7fffe7, 23 },
@ -233,7 +233,7 @@ static struct huf huf_literal[] = {
/* 0xc9 */ { 0x3ffffe3, 26 },
/* 0xca */ { 0x3ffffe4, 26 },
/* 0xcb */ { 0x7ffffde, 27 },
/* 0xcc */ { 0x7ffffdf, 27 },
/* 0xcd */ { 0x3ffffe5, 26 },
/* 0xce */ { 0xfffff1, 24 },
@ -282,7 +282,7 @@ static struct huf huf_literal[] = {
/* 0xf9 */ { 0xffffffe, 28 },
/* 0xfa */ { 0x7ffffec, 27 },
/* 0xfb */ { 0x7ffffed, 27 },
/* 0xfc */ { 0x7ffffee, 27 },
/* 0xfd */ { 0x7ffffef, 27 },
/* 0xfe */ { 0x7fffff0, 27 },
@ -338,7 +338,7 @@ int main(void)
int pos = 0;
int biggest = 0;
int fails = 0;
m = 0;
while (m < ARRAY_SIZE(state)) {
for (j = 0; j < PARALLEL; j++) {
@ -391,14 +391,14 @@ again:
if (state[n].state[0]) /* nonterminal */
pos += 2;
walk ++;
}
fprintf(stdout, "static unsigned char lextable[] = {\n");
#define TERMINAL_MASK 0x8000
walk = 0;
pos = 0;
q = 0;
@ -435,9 +435,9 @@ again:
walk++;
continue;
}
j = (state[saw].real_pos - q) >> 1;
if (j > biggest)
biggest = j;
@ -447,7 +447,7 @@ again:
state[n].real_pos, state[saw].real_pos);
return 1;
}
fprintf(stdout, " /* %d */ 0x%02X "
"/* (to 0x%04X state %3d) */,\n",
m,
@ -469,7 +469,7 @@ again:
fprintf(stdout, "0x%02x, ", terms[n]);
}
fprintf(stdout, "\n};\n");
/*
* Try to parse every legal input string
*/
@ -494,7 +494,7 @@ again:
y = walk & 0x7fff;
if (y == 0 && m == 29) {
y |= 0x100;
fprintf(stdout,
fprintf(stdout,
"\n/* state that points to "
"0x100 for disambiguation with "
"0x0 */\n"

View file

@ -22,11 +22,11 @@
* b7 = 0 = 1-byte seq
* 0x08 = fail
* 2-byte seq
* 0x00 - 0x07, then terminal as given in 2nd byte
* 0x00 - 0x07, then terminal as given in 2nd byte
3-byte seq
* no match: go fwd 3 byte, match: jump fwd by amt in +1/+2 bytes
* no match: go fwd 3 byte, match: jump fwd by amt in +1/+2 bytes
* = 1 = 1-byte seq
* no match: die, match go fwd 1 byte
* no match: die, match go fwd 1 byte
*/
unsigned char lextable[] = {
@ -51,7 +51,6 @@ int next = 1;
int lextable_decode(int pos, char c)
{
while (1) {
if (lextable[pos] & (1 << 7)) { /* 1-byte, fail on mismatch */
if ((lextable[pos] & 0x7f) != c)

View file

@ -93,7 +93,7 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
struct lws_context *context = lws_get_ctx(wsi);
size_t real_len = len;
int n, m;
if (!len)
return 0;
/* just ignore sends after we cleared the truncation buffer */
@ -441,7 +441,7 @@ send_raw:
if (wsi->u.http2.send_END_STREAM)
flags |= LWS_HTTP2_FLAG_END_STREAM;
}
if ((protocol == LWS_WRITE_HTTP || protocol == LWS_WRITE_HTTP_FINAL) && wsi->u.http.content_length) {
wsi->u.http.content_remain -= len;
lwsl_info("%s: content_remain = %lu\n", __func__, wsi->u.http.content_remain);
@ -450,7 +450,7 @@ send_raw:
protocol = LWS_WRITE_HTTP_FINAL;
}
}
if (protocol == LWS_WRITE_HTTP_FINAL && wsi->u.http2.END_STREAM) {
lwsl_info("%s: setting END_STREAM\n", __func__);
flags |= LWS_HTTP2_FLAG_END_STREAM;
@ -623,7 +623,7 @@ lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len)
(void)len;
// !!!
#endif
lwsl_debug("ERROR writing len %d to skt %d\n", len, n);
return LWS_SSL_CAPABLE_ERROR;
}

View file

@ -272,7 +272,7 @@ int lws_parse(struct lws_context *context, struct lws *wsi, unsigned char c)
wsi->u.hdr.esc_stash = c;
wsi->u.hdr.ues = URIES_SEEN_PERCENT_H1;
goto swallow;
case URIES_SEEN_PERCENT_H1:
if (char_to_hex(c) < 0) {
/* regurgitate */
@ -291,7 +291,7 @@ int lws_parse(struct lws_context *context, struct lws *wsi, unsigned char c)
}
/*
* special URI processing...
* special URI processing...
* convert /.. or /... or /../ etc to /
* convert /./ to /
* convert // or /// etc to /
@ -318,7 +318,7 @@ int lws_parse(struct lws_context *context, struct lws *wsi, unsigned char c)
case URIPS_SEEN_SLASH_DOT:
/* swallow second . */
if (c == '.') {
/*
/*
* back up one dir level if possible
* safe against header fragmentation because
* the method URI can only be in 1 fragment
@ -344,7 +344,7 @@ int lws_parse(struct lws_context *context, struct lws *wsi, unsigned char c)
wsi->u.hdr.ups = URIPS_IDLE;
issue_char(wsi, '.');
break;
case URIPS_SEEN_SLASH_DOT_DOT:
/* swallow prior .. chars and any subsequent . */
if (c == '.')
@ -891,7 +891,7 @@ spill:
wsi->u.ws.rx_user_buffer_head);
if (wsi->u.ws.ping_pending_flag) {
/*
/*
* there is already a pending ping payload
* we should just log and drop
*/
@ -904,7 +904,7 @@ process_as_ping:
lwsl_parser("DROP PING payload too large\n");
goto ping_drop;
}
/* if existing buffer is too small, drop it */
if (wsi->u.ws.ping_payload_buf &&
wsi->u.ws.ping_payload_alloc < wsi->u.ws.rx_user_buffer_head) {
@ -917,15 +917,15 @@ process_as_ping:
+ LWS_SEND_BUFFER_PRE_PADDING);
wsi->u.ws.ping_payload_alloc = wsi->u.ws.rx_user_buffer_head;
}
/* stash the pong payload */
memcpy(wsi->u.ws.ping_payload_buf + LWS_SEND_BUFFER_PRE_PADDING,
&wsi->u.ws.rx_user_buffer[LWS_SEND_BUFFER_PRE_PADDING],
wsi->u.ws.rx_user_buffer_head);
wsi->u.ws.ping_payload_len = wsi->u.ws.rx_user_buffer_head;
wsi->u.ws.ping_pending_flag = 1;
/* get it sent as soon as possible */
lws_callback_on_writable(lws_get_ctx(wsi), wsi);
ping_drop:
@ -978,7 +978,7 @@ ping_drop:
eff_buf.token = &wsi->u.ws.rx_user_buffer[
LWS_SEND_BUFFER_PRE_PADDING];
eff_buf.token_len = wsi->u.ws.rx_user_buffer_head;
if (lws_ext_callback_for_each_active(wsi,
LWS_EXT_CALLBACK_PAYLOAD_RX, &eff_buf, 0) < 0)
return -1;

View file

@ -54,7 +54,7 @@ insert_wsi_socket_into_fds(struct lws_context *context,
wsi->position_in_fds_table = context->fds_count;
context->fds[context->fds_count].fd = wsi->sock;
context->fds[context->fds_count].events = LWS_POLLIN;
lws_plat_insert_socket_into_fds(context, wsi);
/* external POLL support via protocol 0 */
@ -107,7 +107,7 @@ remove_wsi_socket_from_fds(struct lws_context *context,
* (still same fd pointing to same wsi)
*/
/* end guy's "position in fds table" changed */
wsi_from_fd(context,context->fds[context->fds_count].fd)->
wsi_from_fd(context,context->fds[context->fds_count].fd)->
position_in_fds_table = m;
/* deletion guy's lws_lookup entry needs nuking */
delete_from_fd(context,wsi->sock);
@ -140,7 +140,7 @@ lws_change_pollfd(struct lws *wsi, int _and, int _or)
if (!wsi || !wsi->protocol || wsi->position_in_fds_table < 0)
return 1;
context = lws_get_ctx(wsi);
if (!context)
return 1;
@ -171,7 +171,7 @@ lws_change_pollfd(struct lws *wsi, int _and, int _or)
if (pa.prev_events != pa.events)
#endif
{
if (lws_plat_change_pollfd(context, wsi, pfd)) {
lwsl_info("%s failed\n", __func__);
return 1;
@ -191,7 +191,7 @@ lws_change_pollfd(struct lws *wsi, int _and, int _or)
if (context->protocols[0].callback(context, wsi,
LWS_CALLBACK_UNLOCK_POLL, wsi->user_space, (void *) &pa, 0))
return -1;
return 0;
}
@ -213,20 +213,20 @@ lws_callback_on_writable(const struct lws_context *context, struct lws *wsi)
int already;
lwsl_info("%s: %p\n", __func__, wsi);
if (wsi->mode != LWS_CONNMODE_HTTP2_SERVING)
goto network_sock;
if (wsi->u.http2.requested_POLLOUT) {
lwsl_info("already pending writable\n");
return 1;
}
if (wsi->u.http2.tx_credit <= 0) {
/*
* other side is not able to cope with us sending
* anything so no matter if we have POLLOUT on our side.
*
*
* Delay waiting for our POLLOUT until peer indicates he has
* space for more using tx window command in http2 layer
*/
@ -234,21 +234,21 @@ lws_callback_on_writable(const struct lws_context *context, struct lws *wsi)
wsi->u.http2.waiting_tx_credit = 1;
return 0;
}
network_wsi = lws_http2_get_network_wsi(wsi);
already = network_wsi->u.http2.requested_POLLOUT;
/* mark everybody above him as requesting pollout */
wsi2 = wsi;
while (wsi2) {
wsi2->u.http2.requested_POLLOUT = 1;
lwsl_info("mark %p pending writable\n", wsi2);
wsi2 = wsi2->u.http2.parent_wsi;
}
/* for network action, act only on the network wsi */
wsi = network_wsi;
if (already)
return 1;

View file

@ -1,7 +1,7 @@
/*
* libwebsockets - small server side websockets and web server implementation
*
* Copyright (C) 2010 - 2013 Andy Green <andy@warmcat.com>
* Copyright (C) 2010 - 2015 Andy Green <andy@warmcat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -64,7 +64,7 @@
#define compatible_close(fd) closesocket(fd)
#define lws_set_blocking_send(wsi) wsi->sock_send_blocking = TRUE
#define lws_socket_is_valid(x) (!!x)
#define LWS_SOCK_INVALID 0
#define LWS_SOCK_INVALID 0
#include <winsock2.h>
#include <windows.h>
#include <tchar.h>
@ -343,7 +343,7 @@ enum lws_connection_states {
WSI_STATE_RETURNED_CLOSE_ALREADY,
WSI_STATE_AWAITING_CLOSE_ACK,
WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE,
WSI_STATE_HTTP2_AWAIT_CLIENT_PREFACE,
WSI_STATE_HTTP2_ESTABLISHED_PRE_SETTINGS,
WSI_STATE_HTTP2_ESTABLISHED,
@ -402,7 +402,7 @@ enum connection_mode {
LWS_CONNMODE_WS_SERVING,
LWS_CONNMODE_WS_CLIENT,
LWS_CONNMODE_HTTP2_SERVING,
/* transient, ssl delay hiding */
@ -532,7 +532,7 @@ struct lws_context {
#endif
const struct lws_token_limits *token_limits;
void *user_space;
struct lws_plat_file_ops fops;
};
@ -604,13 +604,13 @@ struct lws_fragments {
};
/* notice that these union members:
*
*
* hdr
* http
* http2
*
*
* all have a pointer to allocated_headers struct as their first member.
*
*
* It means for allocated_headers access, the three union paths can all be
* used interchangeably to access the same data
*/
@ -649,7 +649,7 @@ enum lws_http2_settings {
LWS_HTTP2_SETTINGS__INITIAL_WINDOW_SIZE,
LWS_HTTP2_SETTINGS__MAX_FRAME_SIZE,
LWS_HTTP2_SETTINGS__MAX_HEADER_LIST_SIZE,
LWS_HTTP2_SETTINGS__COUNT /* always last */
};
@ -664,7 +664,7 @@ enum lws_http2_wellknown_frame_types {
LWS_HTTP2_FRAME_TYPE_GOAWAY,
LWS_HTTP2_FRAME_TYPE_WINDOW_UPDATE,
LWS_HTTP2_FRAME_TYPE_CONTINUATION,
LWS_HTTP2_FRAME_TYPE_COUNT /* always last */
};
@ -686,22 +686,22 @@ struct http2_settings {
};
enum http2_hpack_state {
/* optional before first header block */
HPKS_OPT_PADDING,
HKPS_OPT_E_DEPENDENCY,
HKPS_OPT_WEIGHT,
/* header block */
HPKS_TYPE,
HPKS_IDX_EXT,
HPKS_HLEN,
HPKS_HLEN_EXT,
HPKS_DATA,
/* optional after last header block */
HKPS_OPT_DISCARD_PADDING,
};
@ -731,7 +731,7 @@ struct hpack_dynamic_table {
};
struct _lws_http2_related {
/*
/*
* having this first lets us also re-use all HTTP union code
* and in turn, http_mode_related has allocated headers in right
* place so we can use the header apis on the wsi directly still
@ -740,14 +740,14 @@ struct _lws_http2_related {
struct http2_settings my_settings;
struct http2_settings peer_settings;
struct lws *parent_wsi;
struct lws *next_child_wsi;
struct hpack_dynamic_table *hpack_dyn_table;
unsigned int count;
/* frame */
unsigned int length;
unsigned int stream_id;
@ -758,7 +758,7 @@ struct _lws_http2_related {
unsigned char padding;
unsigned char ping_payload[8];
unsigned short round_robin_POLLOUT;
unsigned short count_POLLOUT_children;
@ -779,7 +779,7 @@ struct _lws_http2_related {
unsigned int hpack_e_dep;
unsigned int huff:1;
unsigned int value:1;
/* negative credit is mandated by the spec */
int tx_credit;
unsigned int my_stream_id;
@ -833,10 +833,10 @@ struct lws {
/* lifetime members */
#ifdef LWS_USE_LIBEV
struct lws_io_watcher w_read;
struct lws_io_watcher w_write;
struct lws_io_watcher w_read;
struct lws_io_watcher w_write;
#endif /* LWS_USE_LIBEV */
struct lws_context *context;
struct lws_context *context;
const struct lws_protocols *protocol;
#ifndef LWS_NO_EXTENSIONS
const struct lws_extension *active_extensions[LWS_MAX_EXTENSIONS_ACTIVE];
@ -917,7 +917,9 @@ lws_rxflow_cache(struct lws *wsi, unsigned char *buf, int n, int len);
static inline void
lws_latency(struct lws_context *context, struct lws *wsi, const char *action,
int ret, int completion) {
do { (void)context; (void)wsi; (void)action; (void)ret; (void)completion;
do {
(void)context; (void)wsi; (void)action; (void)ret;
(void)completion;
} while (0);
}
static inline void
@ -950,13 +952,13 @@ lws_b64_selftest(void);
LWS_EXTERN struct lws *
wsi_from_fd(struct lws_context *context, lws_sockfd_type fd);
LWS_EXTERN int
LWS_EXTERN int
insert_wsi(struct lws_context *context, struct lws *wsi);
LWS_EXTERN int
delete_from_fd(struct lws_context *context, lws_sockfd_type fd);
#else
#define wsi_from_fd(A,B) A->lws_lookup[B]
#define wsi_from_fd(A,B) A->lws_lookup[B]
#define insert_wsi(A,B) A->lws_lookup[B->sock]=B
#define delete_from_fd(A,B) A->lws_lookup[B]=0
#endif
@ -1226,7 +1228,7 @@ lws_handshake_server(struct lws_context *context,
#define _lws_rx_flow_control(_a) (0)
#define lws_handshake_server(_a, _b, _c, _d) (0)
#endif
LWS_EXTERN int
lws_get_addresses(struct lws_context *context, void *ads, char *name,
int name_len, char *rip, int rip_len);

View file

@ -85,9 +85,8 @@ lws_extension_server_handshake(struct lws_context *context,
}
/*
* oh, we do support this one he
* asked for... but let's ask user
* code if it's OK to apply it on this
* oh, we do support this one he asked for... but let's
* ask user code if it's OK to apply it on this
* particular connection + protocol
*/
@ -99,9 +98,8 @@ lws_extension_server_handshake(struct lws_context *context,
wsi->user_space, ext_name, 0);
/*
* zero return from callback means
* go ahead and allow the extension,
* it's what we get if the callback is
* zero return from callback means go ahead and allow
* the extension, it's what we get if the callback is
* unhandled
*/
@ -234,7 +232,7 @@ handshake_0405(struct lws_context *context, struct lws *wsi)
/* end of response packet */
LWS_CPYAPP(p, "\x0d\x0a\x0d\x0a");
if (!lws_any_extension_handled(context, wsi,
LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX,
response, p - response)) {

View file

@ -50,7 +50,7 @@ int lws_context_init_server(struct lws_context_creation_info *info,
else
#endif
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1) {
#else
sockfd = mbed3_create_tcp_stream_socket();
@ -217,7 +217,7 @@ int lws_http_action(struct lws_context *context, struct lws *wsi)
#endif
};
#endif
/* it's not websocket.... shall we accept it as http? */
for (n = 0; n < ARRAY_SIZE(methods); n++)
@ -315,11 +315,11 @@ int lws_http_action(struct lws_context *context, struct lws *wsi)
lwsl_info("LWS_CALLBACK_HTTP closing\n");
return 1; /* struct ah ptr already nuked */ }
/*
/*
* If we're not issuing a file, check for content_length or
* HTTP keep-alive. No keep-alive header allocation for
* ISSUING_FILE, as this uses HTTP/1.0.
*
* ISSUING_FILE, as this uses HTTP/1.0.
*
* In any case, return 0 and let lws_read decide how to
* proceed based on state
*/
@ -367,16 +367,16 @@ int lws_handshake_server(struct lws_context *context, struct lws *wsi,
if (!lws_hdr_total_length(wsi, WSI_TOKEN_UPGRADE) ||
!lws_hdr_total_length(wsi, WSI_TOKEN_CONNECTION)) {
ah = wsi->u.hdr.ah;
lws_union_transition(wsi, LWS_CONNMODE_HTTP_SERVING_ACCEPTED);
wsi->state = WSI_STATE_HTTP;
wsi->u.http.fd = LWS_INVALID_FILE;
/* expose it at the same offset as u.hdr */
wsi->u.http.ah = ah;
n = lws_http_action(context, wsi);
return n;
@ -416,15 +416,15 @@ upgrade_h2c:
ah = wsi->u.hdr.ah;
lws_union_transition(wsi, LWS_CONNMODE_HTTP2_SERVING);
/* http2 union member has http union struct at start */
wsi->u.http.ah = ah;
lws_http2_init(&wsi->u.http2.peer_settings);
lws_http2_init(&wsi->u.http2.my_settings);
/* HTTP2 union */
lws_http2_interpret_settings_payload(&wsi->u.http2.peer_settings,
(unsigned char *)protocol_list, n);
@ -438,9 +438,9 @@ upgrade_h2c:
lwsl_debug("http2 switch: ERROR writing to socket\n");
return 1;
}
wsi->state = WSI_STATE_HTTP2_AWAIT_CLIENT_PREFACE;
return 0;
#endif
@ -633,7 +633,7 @@ lws_create_new_server_wsi(struct lws_context *context)
new_wsi->user_space = NULL;
new_wsi->ietf_spec_revision = 0;
new_wsi->sock = LWS_SOCK_INVALID;
/*
* outermost create notification for wsi
* no user_space because no protocol selection
@ -675,9 +675,9 @@ int lws_http_transaction_completed(struct lws *wsi)
/* If we're (re)starting on headers, need other implied init */
wsi->u.hdr.ues = URIES_IDLE;
lwsl_info("%s: keep-alive await new transaction\n", __func__);
return 0;
}
@ -740,7 +740,7 @@ int lws_server_socket_service(struct lws_context *context,
/* just ignore incoming if waiting for close */
if (wsi->state != WSI_STATE_FLUSHING_STORED_SEND_BEFORE_CLOSE) {
/*
* hm this may want to send
* (via HTTP callback for example)
@ -765,7 +765,7 @@ try_pollout:
/* one shot */
if (lws_change_pollfd(wsi, LWS_POLLOUT, 0))
goto fail;
lws_libev_io(context, wsi, LWS_EV_STOP | LWS_EV_WRITE);
if (wsi->state != WSI_STATE_HTTP_ISSUING_FILE) {
@ -796,7 +796,7 @@ try_pollout:
break;
/* listen socket got an unencrypted connection... */
clilen = sizeof(cli_addr);
lws_latency_pre(context, wsi);
accept_fd = accept(pollfd->fd, (struct sockaddr *)&cli_addr,
@ -848,7 +848,7 @@ try_pollout:
#if LWS_POSIX == 0
mbed3_tcp_stream_accept(accept_fd, new_wsi);
#endif
/*
* A new connection was accepted. Give the user a chance to
* set properties of the newly created wsi. There's no protocol
@ -950,7 +950,7 @@ LWS_VISIBLE int lws_serve_http_file(struct lws_context *context,
if (lws_finalize_http_header(context, wsi, &p, end))
return -1;
ret = lws_write(wsi, response, p - response, LWS_WRITE_HTTP_HEADERS);
if (ret != (p - response)) {
lwsl_err("_write returned %d from %d\n", ret, (p - response));
@ -963,7 +963,6 @@ LWS_VISIBLE int lws_serve_http_file(struct lws_context *context,
return lws_serve_http_file_fragment(context, wsi);
}
int lws_interpret_incoming_packet(struct lws *wsi, unsigned char *buf,
size_t len)
{

View file

@ -84,12 +84,12 @@ lws_handle_POLLOUT_event(struct lws_context *context, struct lws *wsi,
}
wsi->pps = LWS_PPS_NONE;
lws_rx_flow_control(wsi, 1);
return 0; /* leave POLLOUT active */
}
#endif
/* pending control packets have next priority */
if ((wsi->state == WSI_STATE_ESTABLISHED &&
wsi->u.ws.ping_pending_flag) ||
(wsi->state == WSI_STATE_RETURNED_CLOSE_ALREADY &&
@ -118,9 +118,9 @@ lws_handle_POLLOUT_event(struct lws_context *context, struct lws *wsi,
if (wsi->state == WSI_STATE_RETURNED_CLOSE_ALREADY)
goto user_service;
/* if nothing critical, user can get the callback */
m = lws_ext_callback_for_each_active(wsi, LWS_EXT_CALLBACK_IS_WRITEABLE,
NULL, 0);
#ifndef LWS_NO_EXTENSIONS
@ -145,7 +145,7 @@ lws_handle_POLLOUT_event(struct lws_context *context, struct lws *wsi,
eff_buf.token_len = 0;
/* give every extension a chance to spill */
m = lws_ext_callback_for_each_active(wsi,
LWS_EXT_CALLBACK_PACKET_TX_PRESEND,
&eff_buf, 0);
@ -221,19 +221,19 @@ user_service:
}
#ifdef LWS_USE_HTTP2
/*
/*
* we are the 'network wsi' for potentially many muxed child wsi with
* no network connection of their own, who have to use us for all their
* network actions. So we use a round-robin scheme to share out the
* POLLOUT notifications to our children.
*
*
* But because any child could exhaust the socket's ability to take
* writes, we can only let one child get notified each time.
*
*
* In addition children may be closed / deleted / added between POLLOUT
* notifications, so we can't hold pointers
*/
if (wsi->mode != LWS_CONNMODE_HTTP2_SERVING) {
lwsl_info("%s: non http2\n", __func__);
goto notify;
@ -244,7 +244,7 @@ user_service:
lwsl_info("pollout on uninitialized http2 conn\n");
return 0;
}
lwsl_info("%s: doing children\n", __func__);
wsi2 = wsi;
@ -263,9 +263,9 @@ user_service:
}
wsi2 = wsi;
} while (wsi2 != NULL && !lws_send_pipe_choked(wsi));
lwsl_info("%s: completed\n", __func__);
return 0;
notify:
#endif
@ -570,7 +570,7 @@ drain:
do {
more = 0;
m = lws_ext_callback_for_each_active(wsi,
LWS_EXT_CALLBACK_PACKET_RX_PREPARSE, &eff_buf, 0);
if (m < 0)
@ -632,7 +632,7 @@ handle_pending:
close_and_handled:
lwsl_debug("Close and handled\n");
lws_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS);
/*
/*
* pollfd may point to something else after the close
* due to pollfd swapping scheme on delete on some platforms
* we can't clear revents now because it'd be the wrong guy's revents

View file

@ -17,12 +17,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*
*
* Some or all of this file is based on code from nghttp2, which has the
* following license. Since it's more liberal than lws license, you're also
* at liberty to get the original code from
* https://github.com/tatsuhiro-t/nghttp2 under his liberal terms alone.
*
*
* nghttp2 - HTTP/2.0 C Library
*
* Copyright (c) 2012 Tatsuhiro Tsujikawa
@ -94,7 +94,7 @@ lws_context_init_http2_ssl(struct lws_context *context)
"\x08http/1.1", 6 + 9 };
SSL_CTX_set_next_protos_advertised_cb(context->ssl_ctx, npn_cb, &protos);
// ALPN selection callback
SSL_CTX_set_alpn_select_cb(context->ssl_ctx, alpn_cb, &protos);
lwsl_notice(" HTTP2 / ALPN enabled\n");
@ -114,12 +114,12 @@ void lws_http2_configure_if_upgraded(struct lws *wsi)
unsigned len;
SSL_get0_alpn_selected(wsi->ssl, &name, &len);
if (!len) {
SSL_get0_next_proto_negotiated(wsi->ssl, &name, &len);
method = "npn";
}
if (!len) {
lwsl_info("no npn/alpn upgrade\n");
return;
@ -129,7 +129,7 @@ void lws_http2_configure_if_upgraded(struct lws *wsi)
wsi->use_ssl = 1;
if (strncmp((char *)name, "http/1.1", 8) == 0)
return;
/* http2 */
/* adopt the header info */
@ -138,10 +138,10 @@ void lws_http2_configure_if_upgraded(struct lws *wsi)
lws_union_transition(wsi, LWS_CONNMODE_HTTP2_SERVING);
wsi->state = WSI_STATE_HTTP2_AWAIT_CLIENT_PREFACE;
/* http2 union member has http union struct at start */
wsi->u.http.ah = ah;
lws_http2_init(&wsi->u.http2.peer_settings);
lws_http2_init(&wsi->u.http2.my_settings);

View file

@ -99,7 +99,7 @@ lws_context_init_server_ssl(struct lws_context_creation_info *info,
#else
lwsl_notice(" Compiled with OpenSSL support\n");
#endif
if (info->ssl_cipher_list)
lwsl_notice(" SSL ciphers: '%s'\n", info->ssl_cipher_list);
@ -131,7 +131,7 @@ lws_context_init_server_ssl(struct lws_context_creation_info *info,
method = (SSL_METHOD *)SSLv23_server_method();
if (!method) {
error = ERR_get_error();
lwsl_err("problem creating ssl method %lu: %s\n",
lwsl_err("problem creating ssl method %lu: %s\n",
error, ERR_error_string(error,
(char *)context->service_buffer));
return 1;
@ -159,12 +159,12 @@ lws_context_init_server_ssl(struct lws_context_creation_info *info,
if (info->options &
LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT) {
int verify_options = SSL_VERIFY_PEER;
if (!(info->options & LWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED))
verify_options |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
SSL_CTX_set_session_id_context(context->ssl_ctx,
(unsigned char *)context, sizeof(void *));
@ -239,10 +239,10 @@ lws_context_init_server_ssl(struct lws_context_creation_info *info,
* SSL is happy and has a cert it's content with
* If we're supporting HTTP2, initialize that
*/
lws_context_init_http2_ssl(context);
}
return 0;
}
#endif
@ -377,7 +377,7 @@ int lws_context_init_client_ssl(struct lws_context_creation_info *info,
(char *)context->service_buffer));
return 1;
}
}
}
if (info->ssl_private_key_filepath) {
lws_ssl_bind_passphrase(context->ssl_client_ctx, info);
/* set the private key from KeyFile */
@ -397,12 +397,12 @@ int lws_context_init_client_ssl(struct lws_context_creation_info *info,
lwsl_err("Private SSL key doesn't match cert\n");
return 1;
}
}
}
context->protocols[0].callback(context, NULL,
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS,
context->ssl_client_ctx, NULL, 0);
return 0;
}
#endif
@ -448,10 +448,10 @@ lws_ssl_capable_read(struct lws_context *context,
return LWS_SSL_CAPABLE_ERROR;
if (n > 0) {
/*
/*
* if it was our buffer that limited what we read,
* check if SSL has additional data pending inside SSL buffers.
*
*
* Because these won't signal at the network layer with POLLIN
* and if we don't realize, this data will sit there forever
*/
@ -475,7 +475,7 @@ lws_ssl_capable_read(struct lws_context *context,
if (n == SSL_ERROR_WANT_READ || n == SSL_ERROR_WANT_WRITE)
return LWS_SSL_CAPABLE_MORE_SERVICE;
lwsl_err("%s: LWS_SSL_CAPABLE_ERROR\n", __func__);
return LWS_SSL_CAPABLE_ERROR;
return LWS_SSL_CAPABLE_ERROR;
}
LWS_VISIBLE int
@ -640,7 +640,7 @@ lws_server_socket_service_ssl(struct lws_context *context, struct lws **pwsi,
wsi->ssl = NULL;
goto accepted;
}
if (!n) /*
if (!n) /*
* connection is gone, or nothing to read
* if it's gone, we will timeout on
* PENDING_TIMEOUT_SSL_ACCEPT
@ -706,7 +706,7 @@ accepted:
}
return 0;
fail:
return 1;
}

View file

@ -64,9 +64,9 @@ enum demo_protocols {
};
/*
/*
* dumb_increment protocol
*
*
* since this also happens to be protocols[0], some callbacks that are not
* bound to a specific protocol also turn up here.
*/

View file

@ -133,7 +133,7 @@ do_rx:
}
break;
case LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS:
break;
#endif
default:
@ -253,7 +253,7 @@ int main(int argc, char **argv)
strncpy(uri, optarg, sizeof(uri));
uri[sizeof(uri) - 1] = '\0';
break;
#ifndef LWS_NO_DAEMONIZE
case 'D':
daemonize = 1;
@ -312,7 +312,7 @@ int main(int argc, char **argv)
}
}
#ifndef LWS_NO_DAEMONIZE
#ifndef LWS_NO_DAEMONIZE
/*
* normally lock path would be /var/lock/lwsts or similar, to
* simplify getting started without having to take care about
@ -399,10 +399,10 @@ int main(int argc, char **argv)
state = 1;
lwsl_notice("Client connecting to %s:%u....\n", address, port);
/* we are in client mode */
address[sizeof(address) - 1] = '\0';
sprintf(ads_port, "%s:%u", address, port & 65535);
wsi = lws_client_connect(context, address,
port, use_ssl, uri, ads_port,
ads_port, NULL, -1);

View file

@ -229,7 +229,6 @@ callback_fraggle(struct lws_context *context,
}
/* list of supported protocols and callbacks */
static struct lws_protocols protocols[] = {

View file

@ -120,9 +120,9 @@ callback_lws_mirror(struct lws_context * this,
fprintf(stderr, "LWS_CALLBACK_CLOSED on %p\n", (void *)wsi);
/* remove closed guy */
for (n = 0; n < clients; n++)
if (ping_wsi[n] == wsi) {
if (ping_wsi[n] == wsi) {
clients--;
while (n < clients) {
ping_wsi[n] = ping_wsi[n + 1];
@ -293,8 +293,8 @@ static struct lws_protocols protocols[] = {
callback_lws_mirror,
sizeof (struct per_session_data__ping),
},
{
NULL, NULL, 0/* end of list */
{
NULL, NULL, 0/* end of list */
}
};
@ -494,7 +494,7 @@ int main(int argc, char **argv)
} else
/* allow time for in-flight pongs to come */
if ((l - interrupted_time) > 250000) {
n = -1;
continue;

View file

@ -52,7 +52,7 @@ enum demo_protocols {
struct serveable {
const char *urlpath;
const char *mimetype;
};
};
/*
* this is just an example of parsing handshake headers, you don't need this
@ -105,7 +105,7 @@ const char * get_mimetype(const char *file)
}
/* this protocol server (always the first one) handles HTTP,
*
*
* Some misc callbacks that aren't associated with a protocol also turn up only
* here on the first protocol server.
*/
@ -176,7 +176,7 @@ int callback_http(struct lws_context *context, struct lws *wsi,
* we will send a big jpeg file, but it could be
* anything. Set the Content-Type: appropriately
* so the browser knows what to do with it.
*
*
* Notice we use the APIs to build the header, which
* will do the right thing for HTTP 1/1.1 and HTTP2
* depending on what connection it happens to be working
@ -206,7 +206,7 @@ int callback_http(struct lws_context *context, struct lws *wsi,
* this won't block since it's the first payload sent
* on the connection since it was established
* (too small for partial)
*
*
* Notice they are sent using LWS_WRITE_HTTP_HEADERS
* which also means you can't send body too in one step,
* this is mandated by changes in HTTP2
@ -260,8 +260,8 @@ int callback_http(struct lws_context *context, struct lws *wsi,
p = (unsigned char *)leaf_path;
if (lws_add_http_header_by_name(context, wsi,
(unsigned char *)"set-cookie:",
if (lws_add_http_header_by_name(context, wsi,
(unsigned char *)"set-cookie:",
(unsigned char *)b64, n, &p,
(unsigned char *)leaf_path + sizeof(leaf_path)))
return 1;
@ -310,7 +310,7 @@ int callback_http(struct lws_context *context, struct lws *wsi,
do {
/* we'd like the send this much */
n = sizeof(buffer) - LWS_SEND_BUFFER_PRE_PADDING;
/* but if the peer told us he wants less, we can adapt */
m = lws_get_peer_write_allowance(wsi);
@ -322,7 +322,7 @@ int callback_http(struct lws_context *context, struct lws *wsi,
if (m != -1 && m < n)
/* he couldn't handle that much */
n = m;
n = lws_plat_file_read(wsi, pss->fd,
&amount, buffer +
LWS_SEND_BUFFER_PRE_PADDING, n);
@ -335,7 +335,7 @@ int callback_http(struct lws_context *context, struct lws *wsi,
goto flush_bail;
/*
* To support HTTP2, must take care about preamble space
*
*
* identification of when we send the last payload frame
* is handled by the library itself if you sent a
* content-length header
@ -358,7 +358,7 @@ int callback_http(struct lws_context *context, struct lws *wsi,
if (m) /* while still active, extend timeout */
lws_set_timeout(wsi,
PENDING_TIMEOUT_HTTP_CONTENT, 5);
/* if we have indigestion, let him clear it
* before eating more */
if (lws_partial_buffered(wsi))

View file

@ -99,7 +99,7 @@ callback_lws_mirror(struct lws_context *context,
goto choke;
}
if (ringbuffer[ringbuffer_head].payload)
if (ringbuffer[ringbuffer_head].payload)
free(ringbuffer[ringbuffer_head].payload);
ringbuffer[ringbuffer_head].payload =

View file

@ -128,7 +128,7 @@ void *thread_dumb_increment(void *threadid)
pthread_mutex_unlock(&lock_established_conns);
usleep(100000);
}
pthread_exit(NULL);
}
@ -174,7 +174,7 @@ int main(int argc, char **argv)
int daemonize = 0;
#endif
/*
/*
* take care to zero down the info struct, he contains random garbaage
* from the stack otherwise
*/
@ -182,7 +182,7 @@ int main(int argc, char **argv)
info.port = 7681;
pthread_mutex_init(&lock_established_conns, NULL);
while (n >= 0) {
n = getopt_long(argc, argv, "eci:hsap:d:Dr:", options, NULL);
if (n < 0)
@ -236,7 +236,7 @@ int main(int argc, char **argv)
}
#if !defined(LWS_NO_DAEMONIZE) && !defined(WIN32)
/*
/*
* normally lock path would be /var/lock/lwsts or similar, to
* simplify getting started without having to take care about
* permissions or running as root, set to /tmp/.lwsts-lock
@ -278,7 +278,7 @@ int main(int argc, char **argv)
#ifndef LWS_NO_EXTENSIONS
info.extensions = lws_get_internal_extensions();
#endif
info.ssl_cert_filepath = NULL;
info.ssl_private_key_filepath = NULL;
@ -310,15 +310,15 @@ int main(int argc, char **argv)
}
/* start the dumb increment thread */
n = pthread_create(&pthread_dumb, NULL, thread_dumb_increment, 0);
if (n) {
lwsl_err("Unable to create dumb thread\n");
goto done;
}
/* this is our service thread */
n = 0;
while (n >= 0 && !force_exit) {
n = lws_service(context, 50);
@ -326,11 +326,11 @@ int main(int argc, char **argv)
/* wait for pthread_dumb to exit */
pthread_join(pthread_dumb, &retval);
done:
lws_context_destroy(context);
lws_context_destroy(context);
pthread_mutex_destroy(&lock_established_conns);
lwsl_notice("libwebsockets-test-server exited cleanly\n");

View file

@ -159,7 +159,7 @@ int main(int argc, char **argv)
int daemonize = 0;
#endif
/*
/*
* take care to zero down the info struct, he contains random garbaage
* from the stack otherwise
*/
@ -219,7 +219,7 @@ int main(int argc, char **argv)
}
#if !defined(LWS_NO_DAEMONIZE) && !defined(WIN32)
/*
/*
* normally lock path would be /var/lock/lwsts or similar, to
* simplify getting started without having to take care about
* permissions or running as root, set to /tmp/.lwsts-lock
@ -261,7 +261,7 @@ int main(int argc, char **argv)
#ifndef LWS_NO_EXTENSIONS
info.extensions = lws_get_internal_extensions();
#endif
info.ssl_cert_filepath = NULL;
info.ssl_private_key_filepath = NULL;