From 1b2c9a23e13dd250b193e4302a8d48c5be97d16b Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 29 Jan 2016 21:18:54 +0800 Subject: clean pre 1.7 Signed-off-by: Andy Green --- lib/client-handshake.c | 10 ++++------ lib/client-parser.c | 22 +++++++--------------- lib/client.c | 34 +++++++--------------------------- lib/context.c | 5 +---- lib/extension-permessage-deflate.c | 15 ++++++++------- lib/extension.c | 16 +++++----------- lib/libwebsockets.c | 8 +++++--- lib/libwebsockets.h | 9 +++++---- lib/lws-plat-unix.c | 6 ++++-- lib/output.c | 2 -- lib/parsers.c | 6 +++--- lib/pollfd.c | 19 +++++++------------ lib/server-handshake.c | 11 ++++------- lib/server.c | 12 ++++++------ lib/service.c | 2 +- 15 files changed, 67 insertions(+), 110 deletions(-) (limited to 'lib') diff --git a/lib/client-handshake.c b/lib/client-handshake.c index 6e035017..474ee2c8 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -33,9 +33,7 @@ lws_client_connect_2(struct lws *wsi) "Proxy-authorization: basic %s\x0d\x0a", context->proxy_basic_auth_token); - plen += sprintf((char *)pt->serv_buf + plen, - "\x0d\x0a"); - + plen += sprintf((char *)pt->serv_buf + plen, "\x0d\x0a"); ads = context->http_proxy_address; #ifdef LWS_USE_IPV6 @@ -547,8 +545,8 @@ lws_client_connect(struct lws_context *context, const char *address, const char *host, const char *origin, const char *protocol, int ietf_version_or_minus_one) { - return lws_client_connect_extended(context, address, port, ssl_connection, path, - host, origin, protocol, - ietf_version_or_minus_one, NULL); + return lws_client_connect_extended(context, address, port, ssl_connection, + path, host, origin, protocol, + ietf_version_or_minus_one, NULL); } diff --git a/lib/client-parser.c b/lib/client-parser.c index 65a40a59..704a424c 100644 --- a/lib/client-parser.c +++ b/lib/client-parser.c @@ -25,11 +25,10 @@ int lws_client_rx_sm(struct lws *wsi, unsigned char c) { struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi]; int callback_action = LWS_CALLBACK_CLIENT_RECEIVE; + int handled, n, m, rx_draining_ext = 0; unsigned short close_code; - unsigned char *pp; struct lws_tokens eff_buf; - int handled, n, m, rx_draining_ext = 0; - + unsigned char *pp; if (wsi->u.ws.rx_draining_ext) { struct lws **w = &pt->rx_draining_ext_list; @@ -191,10 +190,8 @@ int lws_client_rx_sm(struct lws *wsi, unsigned char c) case LWS_RXPS_04_FRAME_HDR_LEN16_1: wsi->u.ws.rx_packet_length |= c; - //lwsl_err("&&&&& packet length %d\n", wsi->u.ws.rx_packet_length); if (wsi->u.ws.this_frame_masked) - wsi->lws_rx_parse_state = - LWS_RXPS_07_COLLECT_FRAME_KEY_1; + wsi->lws_rx_parse_state = LWS_RXPS_07_COLLECT_FRAME_KEY_1; else { if (wsi->u.ws.rx_packet_length) wsi->lws_rx_parse_state = @@ -346,8 +343,7 @@ spill: switch (wsi->u.ws.opcode) { case LWSWSOPC_CLOSE: - pp = (unsigned char *)&wsi->u.ws.rx_ubuf[ - LWS_PRE]; + pp = (unsigned char *)&wsi->u.ws.rx_ubuf[LWS_PRE]; if (wsi->context->options & LWS_SERVER_OPTION_VALIDATE_UTF8 && wsi->u.ws.rx_ubuf_head > 2 && lws_check_utf8(&wsi->u.ws.utf8, pp + 2, @@ -389,8 +385,7 @@ spill: * we do not care about how it went, we are closing * immediately afterwards */ - lws_write(wsi, - (unsigned char *)&wsi->u.ws.rx_ubuf[LWS_PRE], + lws_write(wsi, (unsigned char *)&wsi->u.ws.rx_ubuf[LWS_PRE], wsi->u.ws.rx_ubuf_head, LWS_WRITE_CLOSE); wsi->state = LWSS_RETURNED_CLOSE_ALREADY; /* close the connection */ @@ -458,16 +453,14 @@ ping_drop: * state machine. */ - eff_buf.token = &wsi->u.ws.rx_ubuf[ - LWS_PRE]; + eff_buf.token = &wsi->u.ws.rx_ubuf[LWS_PRE]; eff_buf.token_len = wsi->u.ws.rx_ubuf_head; if (lws_ext_cb_active(wsi, LWS_EXT_CB_EXTENDED_PAYLOAD_RX, &eff_buf, 0) <= 0) { /* not handle or fail */ - lwsl_ext("Unhandled ext opc 0x%x\n", - wsi->u.ws.opcode); + lwsl_ext("Unhandled ext opc 0x%x\n", wsi->u.ws.opcode); wsi->u.ws.rx_ubuf_head = 0; return 0; @@ -563,7 +556,6 @@ already_done: return 0; illegal_ctl_length: - lwsl_warn("Control frame asking for extended length is illegal\n"); /* kill the connection */ return -1; diff --git a/lib/client.c b/lib/client.c index a308487c..844d4763 100644 --- a/lib/client.c +++ b/lib/client.c @@ -107,7 +107,6 @@ int lws_client_socket_service(struct lws_context *context, n = recv(wsi->sock, sb, LWS_MAX_SOCKET_IO_BUF, 0); if (n < 0) { - if (LWS_ERRNO == LWS_EAGAIN) { lwsl_debug("Proxy read returned EAGAIN... retrying\n"); return 0; @@ -120,8 +119,7 @@ int lws_client_socket_service(struct lws_context *context, pt->serv_buf[13] = '\0'; if (strcmp(sb, "HTTP/1.0 200 ") && - strcmp(sb, "HTTP/1.1 200 ") - ) { + strcmp(sb, "HTTP/1.1 200 ")) { lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS); lwsl_err("ERROR proxy: %s\n", sb); return 0; @@ -138,9 +136,7 @@ int lws_client_socket_service(struct lws_context *context, /* * we are under PENDING_TIMEOUT_SENT_CLIENT_HANDSHAKE * timeout protection set in client-handshake.c - */ - - /* + * * take care of our lws_callback_on_writable * happening at a time when there's no real connection yet */ @@ -227,8 +223,7 @@ int lws_client_socket_service(struct lws_context *context, lws_latency_pre(context, wsi); n = SSL_connect(wsi->ssl); lws_latency(context, wsi, - "SSL_connect LWSCM_WSCL_ISSUE_HANDSHAKE", - n, n > 0); + "SSL_connect LWSCM_WSCL_ISSUE_HANDSHAKE", n, n > 0); if (n < 0) { n = SSL_get_error(wsi->ssl, n); @@ -249,9 +244,7 @@ int lws_client_socket_service(struct lws_context *context, * are getting serviced inbetweentimes) * us to get called back when writable. */ - - lwsl_info( - "SSL_connect WANT_WRITE... retrying\n"); + lwsl_info("%s: WANT_WRITE... retrying\n", __func__); lws_callback_on_writable(wsi); some_wait: wsi->mode = LWSCM_WSCL_WAITING_SSL; @@ -266,7 +259,6 @@ 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", @@ -282,7 +274,6 @@ some_wait: case LWSCM_WSCL_WAITING_SSL: if (wsi->use_ssl) { - if (wsi->mode == LWSCM_WSCL_WAITING_SSL) { lws_latency_pre(context, wsi); n = SSL_connect(wsi->ssl); @@ -309,7 +300,6 @@ 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(wsi); @@ -488,7 +478,6 @@ bail3: return 0; } - /* * In-place str to lower case */ @@ -526,7 +515,6 @@ lws_client_interpret_server_handshake(struct lws *wsi) * well, what the server sent looked reasonable for syntax. * Now let's confirm it sent all the necessary headers */ - p = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP); if (!p) { lwsl_info("no URI\n"); @@ -598,7 +586,6 @@ lws_client_interpret_server_handshake(struct lws *wsi) len = lws_hdr_total_length(wsi, WSI_TOKEN_PROTOCOL); if (!len) { - lwsl_info("lws_client_int_s_hs: WSI_TOKEN_PROTOCOL is null\n"); /* * no protocol name to work from, @@ -802,8 +789,7 @@ check_accept: * we seem to be good to go, give client last chance to check * headers and OK it */ - if (wsi->protocol->callback(wsi, - LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH, + if (wsi->protocol->callback(wsi, LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH, wsi->user_space, NULL, 0)) goto bail2; @@ -823,7 +809,6 @@ check_accept: * size mentioned in the protocol definition. If 0 there, then * use a big default for compatibility */ - n = wsi->protocol->rx_buffer_size; if (!n) n = LWS_MAX_SOCKET_IO_BUF; @@ -854,7 +839,6 @@ check_accept: * inform all extensions, not just active ones since they * already know */ - ext = context->extensions; while (ext && ext->callback) { @@ -975,7 +959,6 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt) #ifndef LWS_NO_EXTENSIONS ext = context->extensions; while (ext && ext->callback) { - n = lws_ext_cb_all_exts(context, wsi, LWS_EXT_CB_CHECK_OK_TO_PROPOSE_EXTENSION, (char *)ext->name, 0); @@ -984,7 +967,6 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt) ext++; continue; } - n = context->protocols[0].callback(wsi, LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED, wsi->user_space, (char *)ext->name, 0); @@ -1019,10 +1001,8 @@ lws_generate_client_handshake(struct lws *wsi, char *pkt) /* give userland a chance to append, eg, cookies */ - context->protocols[0].callback(wsi, - LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER, - NULL, &p, - (pkt + LWS_MAX_SOCKET_IO_BUF) - p - 12); + context->protocols[0].callback(wsi, LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER, + NULL, &p, (pkt + LWS_MAX_SOCKET_IO_BUF) - p - 12); p += sprintf(p, "\x0d\x0a"); diff --git a/lib/context.c b/lib/context.c index 3e5fc024..e4cbe783 100644 --- a/lib/context.c +++ b/lib/context.c @@ -34,7 +34,6 @@ static const char *library_version = LWS_LIBRARY_VERSION " " LWS_BUILD_HASH; * representing the library version followed by the git head hash it * was built from */ - LWS_VISIBLE const char * lws_get_library_version(void) { @@ -70,7 +69,6 @@ lws_get_library_version(void) * images or whatever over http and dynamic data over websockets all in * one place; they're all handled in the user callback. */ - LWS_VISIBLE struct lws_context * lws_create_context(struct lws_context_creation_info *info) { @@ -83,7 +81,6 @@ lws_create_context(struct lws_context_creation_info *info) int n, m; lwsl_notice("Initial logging level %d\n", log_level); - lwsl_notice("Libwebsockets version: %s\n", library_version); #if LWS_POSIX #ifdef LWS_USE_IPV6 @@ -382,7 +379,7 @@ lws_context_destroy(struct lws_context *context) } #ifdef LWS_USE_LIBEV ev_io_stop(context->io_loop, &context->w_accept.watcher); - if(context->use_ev_sigint) + if (context->use_ev_sigint) ev_signal_stop(context->io_loop, &context->w_sigint.watcher); #endif /* LWS_USE_LIBEV */ diff --git a/lib/extension-permessage-deflate.c b/lib/extension-permessage-deflate.c index 996f6402..e23f4ed7 100644 --- a/lib/extension-permessage-deflate.c +++ b/lib/extension-permessage-deflate.c @@ -58,7 +58,8 @@ lws_extension_callback_pm_deflate(struct lws_context *context, switch (reason) { case LWS_EXT_CB_OPTION_SET: oa = in; - lwsl_info("%s: option set: idx %d, %s, len %d\n", __func__, oa->option_index, oa->start, oa->len); + lwsl_info("%s: option set: idx %d, %s, len %d\n", __func__, + oa->option_index, oa->start, oa->len); if (oa->start) priv->args[oa->option_index] = atoi(oa->start); else @@ -297,12 +298,12 @@ lws_extension_callback_pm_deflate(struct lws_context *context, } #if 0 - for (n = 0; n < eff_buf->token_len; n++) { - printf("%02X ", (unsigned char)eff_buf->token[n]); - if ((n & 15) == 15) - printf("\n"); - } - printf("\n"); + for (n = 0; n < eff_buf->token_len; n++) { + printf("%02X ", (unsigned char)eff_buf->token[n]); + if ((n & 15) == 15) + printf("\n"); + } + printf("\n"); #endif priv->tx.next_out = priv->buf_tx_deflated + LWS_PRE + 5; diff --git a/lib/extension.c b/lib/extension.c index f4d1c59f..990f586a 100644 --- a/lib/extension.c +++ b/lib/extension.c @@ -4,13 +4,12 @@ LWS_VISIBLE void lws_context_init_extensions(struct lws_context_creation_info *info, - struct lws_context *context) + struct lws_context *context) { context->extensions = info->extensions; lwsl_info(" LWS_MAX_EXTENSIONS_ACTIVE: %u\n", LWS_MAX_EXTENSIONS_ACTIVE); } - enum lws_ext_option_parser_states { LEAPS_SEEK_NAME, LEAPS_EAT_NAME, @@ -149,7 +148,6 @@ set_arg: } return -1; } - len--; in++; } @@ -170,7 +168,7 @@ int lws_ext_cb_active(struct lws *wsi, int reason, void *arg, int len) wsi->act_ext_user[n], arg, len); if (m < 0) { lwsl_ext("Ext '%s' failed to handle callback %d!\n", - wsi->active_extensions[n]->name, reason); + wsi->active_extensions[n]->name, reason); return -1; } if (m > handled) @@ -207,10 +205,8 @@ int lws_ext_cb_all_exts(struct lws_context *context, struct lws *wsi, int lws_issue_raw_ext_access(struct lws *wsi, unsigned char *buf, size_t len) { - int ret; struct lws_tokens eff_buf; - int m; - int n = 0; + int ret, m, n = 0; eff_buf.token = (char *)buf; eff_buf.token_len = len; @@ -293,13 +289,11 @@ lws_issue_raw_ext_access(struct lws *wsi, unsigned char *buf, size_t len) } int -lws_any_extension_handled(struct lws *wsi, - enum lws_extension_callback_reasons r, +lws_any_extension_handled(struct lws *wsi, enum lws_extension_callback_reasons r, void *v, size_t len) { - int n; - int handled = 0; struct lws_context *context = wsi->context; + int n, handled = 0; /* maybe an extension will take care of it for us */ diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 26979e98..8ef3bad4 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -613,8 +613,8 @@ lws_callback_all_protocol(struct lws_context *context, const struct lws_protocols *protocol, int reason) { struct lws_context_per_thread *pt = &context->pt[0]; - struct lws *wsi; unsigned int n, m = context->count_threads; + struct lws *wsi; while (m--) { for (n = 0; n < pt->fds_count; n++) { @@ -622,7 +622,8 @@ lws_callback_all_protocol(struct lws_context *context, if (!wsi) continue; if (wsi->protocol == protocol) - protocol->callback(wsi, reason, wsi->user_space, NULL, 0); + protocol->callback(wsi, reason, wsi->user_space, + NULL, 0); } pt++; } @@ -869,7 +870,8 @@ LWS_VISIBLE int lws_is_final_fragment(struct lws *wsi) { lwsl_info("%s: final %d, rx pk length %d, draining %d", __func__, - wsi->u.ws.final, wsi->u.ws.rx_packet_length, wsi->u.ws.rx_draining_ext); + wsi->u.ws.final, wsi->u.ws.rx_packet_length, + wsi->u.ws.rx_draining_ext); return wsi->u.ws.final && !wsi->u.ws.rx_packet_length && !wsi->u.ws.rx_draining_ext; } diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index 92405bc8..9b663527 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -430,7 +430,7 @@ enum lws_extension_callback_reasons { LWS_EXT_CB_CONSTRUCT = 4, LWS_EXT_CB_CLIENT_CONSTRUCT = 5, LWS_EXT_CB_CHECK_OK_TO_REALLY_CLOSE = 6, - LWS_EXT_CB_CHECK_OK_TO_PROPOSE_EXTENSION = 7, + LWS_EXT_CB_CHECK_OK_TO_PROPOSE_EXTENSION = 7, LWS_EXT_CB_DESTROY = 8, LWS_EXT_CB_DESTROY_ANY_WSI_CLOSING = 9, LWS_EXT_CB_ANY_WSI_ESTABLISHED = 10, @@ -606,7 +606,7 @@ enum lws_token_indexes { /* always last real token index*/ WSI_TOKEN_COUNT, - /* parser state additions */ + /* parser state additions, no storage associated */ WSI_TOKEN_NAME_PART, WSI_TOKEN_SKIPPING, WSI_TOKEN_SKIPPING_SAW_CR, @@ -1236,7 +1236,7 @@ struct lws_extension { /* * The internal exts are part of the public abi - * If we add more extensions, publish the callback here + * If we add more extensions, publish the callback here ------v */ extern int lws_extension_callback_pm_deflate( @@ -1836,7 +1836,8 @@ lws_read(struct lws *wsi, unsigned char *buf, size_t len); #define lws_get_internal_extensions() NULL LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi, - void *ext_user, const struct lws_ext_options *opts, const char *o, int len); + void *ext_user, const struct lws_ext_options *opts, + const char *o, int len); #endif /* diff --git a/lib/lws-plat-unix.c b/lib/lws-plat-unix.c index 9953ac7a..0963debe 100644 --- a/lib/lws-plat-unix.c +++ b/lib/lws-plat-unix.c @@ -54,7 +54,8 @@ lws_poll_listen_fd(struct lws_pollfd *fd) * This is just used to interrupt poll waiting * we don't have to do anything with it. */ -static void lws_sigusr2(int sig) +static void +lws_sigusr2(int sig) { } @@ -335,7 +336,8 @@ lws_plat_drop_app_privileges(struct lws_context_creation_info *info) } -static void sigpipe_handler(int x) +static void +sigpipe_handler(int x) { } diff --git a/lib/output.c b/lib/output.c index cfb7c958..b389ace4 100644 --- a/lib/output.c +++ b/lib/output.c @@ -131,8 +131,6 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len) switch (n) { case LWS_SSL_CAPABLE_ERROR: -// lwsl_err("%s: wsi %p: LWS_SSL_CAPABLE_ERROR\n", __func__, -// (void *)wsi); /* we're going to close, let close know sends aren't possible */ wsi->socket_is_permanently_unusable = 1; return -1; diff --git a/lib/parsers.c b/lib/parsers.c index bc9bf4c0..bd251c14 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -860,9 +860,10 @@ int lws_rx_sm(struct lws *wsi, unsigned char c) { struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi]; - struct lws_tokens eff_buf; - int ret = 0, n, rx_draining_ext = 0; int callback_action = LWS_CALLBACK_RECEIVE; + int ret = 0, n, rx_draining_ext = 0; + struct lws_tokens eff_buf; + if (wsi->socket_is_permanently_unusable) return -1; @@ -1136,7 +1137,6 @@ handle_first: case LWS_RXPS_PAYLOAD_UNTIL_LENGTH_EXHAUSTED: - assert(wsi->u.ws.rx_ubuf); if (wsi->u.ws.rx_ubuf_head + LWS_PRE >= diff --git a/lib/pollfd.c b/lib/pollfd.c index c4609328..96406fa7 100644 --- a/lib/pollfd.c +++ b/lib/pollfd.c @@ -24,8 +24,8 @@ int _lws_change_pollfd(struct lws *wsi, int _and, int _or, struct lws_pollargs *pa) { - struct lws_context *context; struct lws_context_per_thread *pt; + struct lws_context *context; int ret = 0, pa_events = 1; struct lws_pollfd *pfd; int sampled_tid, tid; @@ -93,7 +93,7 @@ insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi) struct lws_pollargs pa1; #endif - lwsl_info("%s: %p: tsi=%d, sock=%d, pos-in-fds=%d\n", + lwsl_debug("%s: %p: tsi=%d, sock=%d, pos-in-fds=%d\n", __func__, wsi, wsi->tsi, wsi->sock, pt->fds_count); if ((unsigned int)pt->fds_count >= context->fd_limit_per_thread) { @@ -122,11 +122,6 @@ insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi) wsi->position_in_fds_table = pt->fds_count; pt->fds[pt->fds_count].fd = wsi->sock; pt->fds[pt->fds_count].events = LWS_POLLIN; - - /* don't apply this logic to the listening socket... */ -// if (wsi->mode != LWSCM_SERVER_LISTENER && !wsi->u.hdr.ah) -// pt->fds[pt->fds_count].events = 0; - pa.events = pt->fds[pt->fds_count].events; lws_plat_insert_socket_into_fds(context, wsi); @@ -152,14 +147,14 @@ insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi) int remove_wsi_socket_from_fds(struct lws *wsi) { - int m, ret = 0; - struct lws *end_wsi; struct lws_pollargs pa = { wsi->sock, 0, 0 }; #ifndef LWS_NO_SERVER struct lws_pollargs pa1; #endif struct lws_context *context = wsi->context; struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi]; + struct lws *end_wsi; + int m, ret = 0; #if !defined(_WIN32) && !defined(MBED_OPERATORS) if (wsi->sock > context->max_fds) { @@ -220,10 +215,10 @@ remove_wsi_socket_from_fds(struct lws *wsi) int lws_change_pollfd(struct lws *wsi, int _and, int _or) { - struct lws_context *context; struct lws_context_per_thread *pt; - int ret = 0; + struct lws_context *context; struct lws_pollargs pa; + int ret = 0; if (!wsi || !wsi->protocol || wsi->position_in_fds_table < 0) return 1; @@ -339,8 +334,8 @@ lws_callback_on_writable_all_protocol(const struct lws_context *context, const struct lws_protocols *protocol) { const struct lws_context_per_thread *pt = &context->pt[0]; - struct lws *wsi; unsigned int n, m = context->count_threads; + struct lws *wsi; while (m--) { for (n = 0; n < pt->fds_count; n++) { diff --git a/lib/server-handshake.c b/lib/server-handshake.c index bbbcfcc0..5f525852 100644 --- a/lib/server-handshake.c +++ b/lib/server-handshake.c @@ -31,10 +31,10 @@ lws_extension_server_handshake(struct lws *wsi, char **p) const struct lws_extension *ext; char ext_name[128]; int ext_count = 0; - char *c;//, *start; int more = 1; char ignore; int n, m; + char *c; /* * Figure out which extensions the client has that we want to @@ -57,7 +57,6 @@ lws_extension_server_handshake(struct lws *wsi, char **p) wsi->count_act_ext = 0; n = 0; ignore = 0; -// start = c; while (more) { if (*c && (*c != ',' && *c != '\t')) { @@ -148,7 +147,6 @@ lws_extension_server_handshake(struct lws *wsi, char **p) ext++; } - //start = c; n = 0; } @@ -160,10 +158,9 @@ handshake_0405(struct lws_context *context, struct lws *wsi) { struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi]; unsigned char hash[20]; - int n; + int n, accept_len; char *response; char *p; - int accept_len; if (!lws_hdr_total_length(wsi, WSI_TOKEN_HOST) || !lws_hdr_total_length(wsi, WSI_TOKEN_KEY)) { @@ -187,8 +184,8 @@ handshake_0405(struct lws_context *context, struct lws *wsi) lws_SHA1(pt->serv_buf, n, hash); - accept_len = lws_b64_encode_string((char *)hash, 20, - (char *)pt->serv_buf, LWS_MAX_SOCKET_IO_BUF); + accept_len = lws_b64_encode_string((char *)hash, 20, (char *)pt->serv_buf, + LWS_MAX_SOCKET_IO_BUF); if (accept_len < 0) { lwsl_warn("Base64 encoded hash too long\n"); goto bail; diff --git a/lib/server.c b/lib/server.c index ef56cb02..689d477f 100644 --- a/lib/server.c +++ b/lib/server.c @@ -31,13 +31,13 @@ int lws_context_init_server(struct lws_context_creation_info *info, #if LWS_POSIX struct sockaddr_in serv_addr4; socklen_t len = sizeof(struct sockaddr); + int n, opt = 1, limit = 1; struct sockaddr_in sin; struct sockaddr *v; - int n, opt = 1, limit = 1; #endif - int m = 0; lws_sockfd_type sockfd; struct lws *wsi; + int m = 0; /* set up our external listening socket we serve on */ @@ -722,6 +722,7 @@ LWS_VISIBLE struct lws * lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd) { struct lws *new_wsi = lws_create_new_server_wsi(context); + if (!new_wsi) { compatible_close(accept_fd); return NULL; @@ -773,8 +774,8 @@ LWS_VISIBLE int lws_server_socket_service(struct lws_context *context, struct lws *wsi, struct lws_pollfd *pollfd) { - lws_sockfd_type accept_fd = LWS_SOCK_INVALID; struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi]; + lws_sockfd_type accept_fd = LWS_SOCK_INVALID; #if LWS_POSIX struct sockaddr_in cli_addr; socklen_t clilen; @@ -861,8 +862,7 @@ try_pollout: lws_libev_io(wsi, LWS_EV_STOP | LWS_EV_WRITE); if (wsi->state != LWSS_HTTP_ISSUING_FILE) { - n = user_callback_handle_rxflow( - wsi->protocol->callback, + n = user_callback_handle_rxflow(wsi->protocol->callback, wsi, LWS_CALLBACK_HTTP_WRITEABLE, wsi->user_space, NULL, 0); if (n < 0) { @@ -1082,7 +1082,7 @@ lws_server_get_canonical_hostname(struct lws_context *context, #if LWS_POSIX /* find canonical hostname */ gethostname((char *)context->canonical_hostname, - sizeof(context->canonical_hostname) - 1); + sizeof(context->canonical_hostname) - 1); lwsl_notice(" canonical_hostname = %s\n", context->canonical_hostname); #else diff --git a/lib/service.c b/lib/service.c index 89fe32c0..5893a69c 100644 --- a/lib/service.c +++ b/lib/service.c @@ -629,8 +629,8 @@ read: */ eff_buf.token = (char *)pt->serv_buf; -drain: +drain: do { more = 0; -- cgit v1.2.3