diff -Nru libwebsockets-1.7.1/changelog libwebsockets-1.7.3/changelog --- libwebsockets-1.7.1/changelog 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/changelog 2016-02-29 03:30:07.000000000 +0000 @@ -1,6 +1,54 @@ Changelog --------- +v1.7.3 +====== + +NB: No API change since v1.7.0 + +Fixes +----- + +1) MAJOR connections on ah waiting list that closed did not get removed from +the waiting list... + +2) MAJOR since we added the ability to hold an ah across http keepalive +transactions where more headers had already arrived, we broke the ability +to tell if more headers had arrived. Result was if the browser didn't +close the keepalive, we retained ah for the lifetime of the keepalive, +using up the pool. + +3) MAJOR windows-only-POLLHUP was not coming + +4) Fix build on NetBSD + + +v1.7.2 +====== + +NB: No API change since v1.7.0 + +Fixes +----- + +1) libuv one-per-session valgrind leak fixed + +2) MINOR An error about hdr struct in _lws_ws_related is corrected, it's not +known to affect anything added until after it was fixed + +3) MINOR During the close shutdown wait state introduced at v1.7, if something +requests callback on writeable for the socket it will busywait until the +socket closes + +4) MINOR update URLs in test html for libwebsockets.org https STS changes + +Changes +------- + +1) test server html is updated with tabs and a new live server monitoring +feature. Input sanitization added to the js. + + v1.7.1 ====== @@ -15,6 +63,7 @@ get sent a content-length resulting in the link hanging until the peer closed it. attack.sh updated to add a test for this. + Changes ------- diff -Nru libwebsockets-1.7.1/CMakeLists.txt libwebsockets-1.7.3/CMakeLists.txt --- libwebsockets-1.7.1/CMakeLists.txt 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/CMakeLists.txt 2016-02-29 03:30:07.000000000 +0000 @@ -10,7 +10,7 @@ set(CPACK_PACKAGE_NAME "${PACKAGE}") set(CPACK_PACKAGE_VERSION_MAJOR "1") set(CPACK_PACKAGE_VERSION_MINOR "7") -set(CPACK_PACKAGE_VERSION_PATCH "1") +set(CPACK_PACKAGE_VERSION_PATCH "3") set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") set(CPACK_PACKAGE_VENDOR "andy@warmcat.com") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${PACKAGE_VERSION}") @@ -33,12 +33,23 @@ if(GIT_EXECUTABLE) execute_process( WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMAND "${GIT_EXECUTABLE}" log -n 1 --pretty=%h + COMMAND "${GIT_EXECUTABLE}" describe OUTPUT_VARIABLE GIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE ) - - set(LWS_BUILD_HASH ${GIT_HASH}) + execute_process( + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND "whoami" + OUTPUT_VARIABLE GIT_USER + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + execute_process( + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND "hostname" + OUTPUT_VARIABLE GIT_HOST + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + set(LWS_BUILD_HASH ${GIT_USER}@${GIT_HOST}-${GIT_HASH}) message("Git commit hash: ${LWS_BUILD_HASH}") endif() @@ -737,7 +748,7 @@ # # Helper function for adding a test app. # - macro(create_test_app TEST_NAME MAIN_SRC S2 S3 S4 S5) + macro(create_test_app TEST_NAME MAIN_SRC S2 S3 S4 S5 S6) set(TEST_SRCS ${MAIN_SRC}) set(TEST_HDR) @@ -757,6 +768,10 @@ else() list(APPEND TEST_SRCS ${S5}) endif() + if ("${S6}" STREQUAL "") + else() + list(APPEND TEST_SRCS ${S6}) + endif() if (WIN32) list(APPEND TEST_SRCS ${WIN32_HELPERS_PATH}/getopt.c @@ -818,12 +833,14 @@ "test-server/test-server-http.c" "test-server/test-server-dumb-increment.c" "test-server/test-server-mirror.c" + "test-server/test-server-status.c" "test-server/test-server-echogen.c") if (UNIX) create_test_app(test-fuzxy "test-server/fuzxy.c" "" "" "" + "" "") endif() if (UNIX AND NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))) @@ -832,6 +849,7 @@ "test-server/test-server-http.c" "test-server/test-server-dumb-increment.c" "test-server/test-server-mirror.c" + "test-server/test-server-status.c" "test-server/test-server-echogen.c") endif() if (UNIX AND NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) @@ -841,6 +859,7 @@ "test-server/test-server-http.c" "test-server/test-server-dumb-increment.c" "test-server/test-server-mirror.c" + "test-server/test-server-status.c" "test-server/test-server-echogen.c") endif() if (UNIX AND NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) @@ -850,6 +869,7 @@ "test-server/test-server-http.c" "test-server/test-server-dumb-increment.c" "test-server/test-server-mirror.c" + "test-server/test-server-status.c" "test-server/test-server-echogen.c") endif() endif() @@ -862,6 +882,7 @@ "test-server/test-server-http.c" "test-server/test-server-dumb-increment.c" "test-server/test-server-mirror.c" + "test-server/test-server-status.c" "test-server/test-server-echogen.c") # Set defines for this executable only. set_property( @@ -967,27 +988,27 @@ # test-client # if (NOT LWS_WITHOUT_TEST_CLIENT) - create_test_app(test-client "test-server/test-client.c" "" "" "" "") + create_test_app(test-client "test-server/test-client.c" "" "" "" "" "") endif() # # test-fraggle # if (NOT LWS_WITHOUT_TEST_FRAGGLE) - create_test_app(test-fraggle "test-server/test-fraggle.c" "" "" "" "") + create_test_app(test-fraggle "test-server/test-fraggle.c" "" "" "" "" "") endif() # # test-ping # if (NOT LWS_WITHOUT_TEST_PING) - create_test_app(test-ping "test-server/test-ping.c" "" "" "" "") + create_test_app(test-ping "test-server/test-ping.c" "" "" "" "" "") endif() # # test-echo # if (NOT LWS_WITHOUT_TEST_ECHO) - create_test_app(test-echo "test-server/test-echo.c" "" "" "" "") + create_test_app(test-echo "test-server/test-echo.c" "" "" "" "" "") endif() endif(NOT LWS_WITHOUT_CLIENT) diff -Nru libwebsockets-1.7.1/debian/changelog libwebsockets-1.7.3/debian/changelog --- libwebsockets-1.7.1/debian/changelog 2016-02-21 13:15:17.000000000 +0000 +++ libwebsockets-1.7.3/debian/changelog 2016-02-29 11:24:02.000000000 +0000 @@ -1,3 +1,9 @@ +libwebsockets (1.7.3-1) unstable; urgency=medium + + * New upstream release. + + -- Peter Pentchev Mon, 29 Feb 2016 13:24:01 +0200 + libwebsockets (1.7.1-1) unstable; urgency=medium * Fix the upstream website URLs after the author migrated to HTTPS diff -Nru libwebsockets-1.7.1/lib/client-handshake.c libwebsockets-1.7.3/lib/client-handshake.c --- libwebsockets-1.7.1/lib/client-handshake.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/client-handshake.c 2016-02-29 03:30:07.000000000 +0000 @@ -394,6 +394,7 @@ wsi->state = LWSS_CLIENT_UNCONNECTED; wsi->protocol = NULL; wsi->pending_timeout = NO_PENDING_TIMEOUT; + wsi->position_in_fds_table = -1; #ifdef LWS_OPENSSL_SUPPORT wsi->use_ssl = i->ssl_connection; diff -Nru libwebsockets-1.7.1/lib/context.c libwebsockets-1.7.3/lib/context.c --- libwebsockets-1.7.1/lib/context.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/context.c 2016-02-29 03:30:07.000000000 +0000 @@ -162,6 +162,8 @@ return NULL; } + context->pt[n].context = context; + context->pt[n].tid = n; context->pt[n].http_header_data = lws_malloc(context->max_http_header_data * context->max_http_header_pool); if (!context->pt[n].http_header_data) diff -Nru libwebsockets-1.7.1/lib/libev.c libwebsockets-1.7.3/lib/libev.c --- libwebsockets-1.7.1/lib/libev.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/libev.c 2016-02-29 03:30:07.000000000 +0000 @@ -138,6 +138,9 @@ if (!(context->options & LWS_SERVER_OPTION_LIBEV)) return; + if (!pt->io_loop_ev) + return; + ev_io_stop(pt->io_loop_ev, &pt->w_accept.ev_watcher); if (context->use_ev_sigint) ev_signal_stop(pt->io_loop_ev, diff -Nru libwebsockets-1.7.1/lib/libuv.c libwebsockets-1.7.3/lib/libuv.c --- libwebsockets-1.7.1/lib/libuv.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/libuv.c 2016-02-29 03:30:07.000000000 +0000 @@ -43,7 +43,7 @@ eventfd.fd = watcher->io_watcher.fd; eventfd.events = 0; - eventfd.revents = 0;//EV_NONE; + eventfd.revents = 0; if (revents & UV_READABLE) { eventfd.events |= LWS_POLLIN; eventfd.revents |= LWS_POLLIN; @@ -58,7 +58,7 @@ LWS_VISIBLE void lws_uv_sigint_cb(uv_loop_t *loop, uv_signal_t *watcher, int revents) { - //ev_break(loop, EVBREAK_ALL); + uv_stop(loop); } LWS_VISIBLE int @@ -74,6 +74,17 @@ return 0; } +static void +lws_uv_timeout_cb(uv_timer_t *timer) +{ + struct lws_context_per_thread *pt = container_of(timer, + struct lws_context_per_thread, uv_timeout_watcher); + + lwsl_info("%s\n", __func__); + /* do timeout check only */ + lws_service_fd_tsi(pt->context, NULL, pt->tid); +} + static const int sigs[] = { SIGINT, SIGTERM, SIGSEGV, SIGFPE }; LWS_VISIBLE int @@ -112,9 +123,22 @@ uv_poll_start(&wsi->w_read.uv_watcher, UV_READABLE, lws_accept_cb); } + uv_timer_init(pt->io_loop_uv, &pt->uv_timeout_watcher); + uv_timer_start(&pt->uv_timeout_watcher, lws_uv_timeout_cb, 1000, 1000); + return status; } +void lws_uv_close_cb(uv_handle_t *handle) +{ + +} + +void lws_uv_walk_cb(uv_handle_t *handle, void *arg) +{ + uv_close(handle, lws_uv_close_cb); +} + void lws_libuv_destroyloop(struct lws_context *context, int tsi) { @@ -124,13 +148,20 @@ if (!(context->options & LWS_SERVER_OPTION_LIBUV)) return; + if (!pt->io_loop_uv) + return; + if (context->use_ev_sigint) uv_signal_stop(&pt->w_sigint.uv_watcher); for (m = 0; m < ARRAY_SIZE(sigs); m++) uv_signal_stop(&pt->signals[m]); if (!pt->ev_loop_foreign) { + uv_stop(pt->io_loop_uv); + uv_walk(pt->io_loop_uv, lws_uv_walk_cb, NULL); + while (uv_run(pt->io_loop_uv, UV_RUN_NOWAIT)); m = uv_loop_close(pt->io_loop_uv); - lwsl_debug("%s: uv_loop_close: %d\n", __func__, m); + if (m == UV_EBUSY) + lwsl_debug("%s: uv_loop_close: UV_EBUSY\n", __func__); lws_free(pt->io_loop_uv); } } diff -Nru libwebsockets-1.7.1/lib/libwebsockets.c libwebsockets-1.7.3/lib/libwebsockets.c --- libwebsockets-1.7.1/lib/libwebsockets.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/libwebsockets.c 2016-02-29 03:30:07.000000000 +0000 @@ -53,11 +53,12 @@ lws_free_set_NULL(wsi->rxflow_buffer); lws_free_set_NULL(wsi->trunc_alloc); - if (wsi->u.hdr.ah) { + if (wsi->u.hdr.ah) /* we're closing, losing some rx is OK */ wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen; - lws_header_table_detach(wsi); - } + + /* we may not have an ah, but may be on the waiting list... */ + lws_header_table_detach(wsi); wsi->context->count_wsi_allocated--; lwsl_debug("%s: %p, remaining wsi %d\n", __func__, wsi, @@ -71,14 +72,17 @@ { struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi]; - if (!wsi->timeout_list_prev) + if (!wsi->timeout_list_prev) /* ie, not part of the list */ return; lws_pt_lock(pt); + /* if we have a next guy, set his prev to our prev */ if (wsi->timeout_list) wsi->timeout_list->timeout_list_prev = wsi->timeout_list_prev; + /* set our prev guy to our next guy instead of us */ *wsi->timeout_list_prev = wsi->timeout_list; + /* we're out of the list, we should not point anywhere any more */ wsi->timeout_list_prev = NULL; wsi->timeout_list = NULL; lws_pt_unlock(pt); @@ -104,11 +108,15 @@ time(&now); - if (!wsi->pending_timeout && reason) { + if (reason && !wsi->timeout_list_prev) { + /* our next guy is current first guy */ wsi->timeout_list = pt->timeout_list; + /* if there is a next guy, set his prev ptr to our next ptr */ if (wsi->timeout_list) wsi->timeout_list->timeout_list_prev = &wsi->timeout_list; + /* our prev ptr is first ptr */ wsi->timeout_list_prev = &pt->timeout_list; + /* set the first guy to be us */ *wsi->timeout_list_prev = wsi; } @@ -299,11 +307,16 @@ n = shutdown(wsi->sock, SHUT_WR); if (n) lwsl_debug("closing: shutdown ret %d\n", LWS_ERRNO); - wsi->state = LWSS_SHUTDOWN; - lws_change_pollfd(wsi, LWS_POLLOUT, LWS_POLLIN); - lws_set_timeout(wsi, PENDING_TIMEOUT_SHUTDOWN_FLUSH, - context->timeout_secs); - return; + + /* libuv: no event available to guarantee completion */ + if (!LWS_LIBUV_ENABLED(context)) { + + lws_change_pollfd(wsi, LWS_POLLOUT, LWS_POLLIN); + wsi->state = LWSS_SHUTDOWN; + lws_set_timeout(wsi, PENDING_TIMEOUT_SHUTDOWN_FLUSH, + context->timeout_secs); + return; + } } #endif @@ -372,7 +385,9 @@ ((wsi->state_pre_close == LWSS_ESTABLISHED) || (wsi->state_pre_close == LWSS_RETURNED_CLOSE_ALREADY) || (wsi->state_pre_close == LWSS_AWAITING_CLOSE_ACK) || - (wsi->state_pre_close == LWSS_FLUSHING_STORED_SEND_BEFORE_CLOSE))) { + (wsi->state_pre_close == LWSS_FLUSHING_STORED_SEND_BEFORE_CLOSE) || + (wsi->mode == LWSCM_WS_CLIENT && wsi->state_pre_close == LWSS_HTTP) || + (wsi->mode == LWSCM_WS_SERVING && wsi->state_pre_close == LWSS_HTTP))) { lwsl_debug("calling back CLOSED\n"); wsi->protocol->callback(wsi, LWS_CALLBACK_CLOSED, wsi->user_space, NULL, 0); @@ -922,18 +937,39 @@ LWS_VISIBLE void lwsl_emit_stderr(int level, const char *line) { + time_t o_now = time(NULL); unsigned long long now; + struct tm *ptm = NULL; char buf[300]; +#ifndef WIN32 + struct tm tm; +#endif int n; +#ifdef WIN32 + ptm = localtime(&o_now); +#else + if (localtime_r(&o_now, &tm)) + ptm = &tm; +#endif buf[0] = '\0'; for (n = 0; n < LLL_COUNT; n++) { if (level != (1 << n)) continue; now = time_in_microseconds() / 100; - sprintf(buf, "[%llu:%04d] %s: ", - (unsigned long long) now / 10000, - (int)(now % 10000), log_level_names[n]); + if (ptm) + sprintf(buf, "[%04d/%02d/%02d %02d:%02d:%02d:%04d] %s: ", + ptm->tm_year + 1900, + ptm->tm_mon, + ptm->tm_mday, + ptm->tm_hour, + ptm->tm_min, + ptm->tm_sec, + (int)(now % 10000), log_level_names[n]); + else + sprintf(buf, "[%llu:%04d] %s: ", + (unsigned long long) now / 10000, + (int)(now % 10000), log_level_names[n]); break; } diff -Nru libwebsockets-1.7.1/lib/libwebsockets.h libwebsockets-1.7.3/lib/libwebsockets.h --- libwebsockets-1.7.1/lib/libwebsockets.h 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/libwebsockets.h 2016-02-29 03:30:07.000000000 +0000 @@ -140,6 +140,10 @@ #else /* NOT WIN32 */ #include +#if defined(__NetBSD__) +#include +#endif + #define LWS_INLINE inline #define LWS_O_RDONLY O_RDONLY diff -Nru libwebsockets-1.7.1/lib/lws-plat-unix.c libwebsockets-1.7.3/lib/lws-plat-unix.c --- libwebsockets-1.7.1/lib/lws-plat-unix.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/lws-plat-unix.c 2016-02-29 03:30:07.000000000 +0000 @@ -158,15 +158,16 @@ return 0; } - if (n < 0) { - if (LWS_ERRNO != LWS_EINTR) - return -1; - return 0; - } - - c = n; - - lws_service_flag_pending(context, tsi); + m = lws_service_flag_pending(context, tsi); + if (m) + c = -1; /* unknown limit */ + else + if (n < 0) { + if (LWS_ERRNO != LWS_EINTR) + return -1; + return 0; + } else + c = n; /* any socket with events to service? */ for (n = 0; n < pt->fds_count && c; n++) { @@ -270,6 +271,10 @@ LWS_VISIBLE void lws_plat_drop_app_privileges(struct lws_context_creation_info *info) { + if (info->gid != -1) + if (setgid(info->gid)) + lwsl_warn("setgid: %s\n", strerror(LWS_ERRNO)); + if (info->uid != -1) { struct passwd *p = getpwuid(info->uid); @@ -282,10 +287,6 @@ } else lwsl_warn("getpwuid: unable to find uid %d", info->uid); } - if (info->gid != -1) - if (setgid(info->gid)) - lwsl_warn("setgid: %s\n", strerror(LWS_ERRNO)); - } static void diff -Nru libwebsockets-1.7.1/lib/lws-plat-win.c libwebsockets-1.7.3/lib/lws-plat-win.c --- libwebsockets-1.7.1/lib/lws-plat-win.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/lws-plat-win.c 2016-02-29 03:30:07.000000000 +0000 @@ -387,7 +387,8 @@ pt->fds[pt->fds_count++].revents = 0; pt->events[pt->fds_count] = WSACreateEvent(); - WSAEventSelect(wsi->sock, pt->events[pt->fds_count], LWS_POLLIN); + WSAEventSelect(wsi->sock, pt->events[pt->fds_count], + LWS_POLLIN | LWS_POLLHUP); } LWS_VISIBLE void diff -Nru libwebsockets-1.7.1/lib/parsers.c libwebsockets-1.7.3/lib/parsers.c --- libwebsockets-1.7.1/lib/parsers.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/parsers.c 2016-02-29 03:30:07.000000000 +0000 @@ -97,7 +97,7 @@ /* if we are already bound to one, just clear it down */ if (wsi->u.hdr.ah) { - lwsl_err("cleardown\n"); + lwsl_info("cleardown\n"); goto reset; } @@ -112,8 +112,8 @@ goto bail; } /* new ah.... remove ourselves from waiting list */ - *pwsi = wsi->u.hdr.ah_wait_list; - wsi->u.hdr.ah_wait_list = NULL; + *pwsi = wsi->u.hdr.ah_wait_list; /* set our prev to our next */ + wsi->u.hdr.ah_wait_list = NULL; /* no next any more */ pt->ah_wait_list_length--; break; } @@ -189,22 +189,22 @@ lws_pt_lock(pt); pwsi = &pt->ah_wait_list; - if (!ah) { /* remove from wait list if that's all */ -// if (wsi->socket_is_permanently_unusable) - while (*pwsi) { - if (*pwsi == wsi) { - lwsl_info("%s: wsi %p, remv wait\n", - __func__, wsi); - *pwsi = wsi->u.hdr.ah_wait_list; - wsi->u.hdr.ah_wait_list = NULL; - pt->ah_wait_list_length--; - goto bail; - } - pwsi = &(*pwsi)->u.hdr.ah_wait_list; + if (!ah) { /* remove from wait list if none attached */ + while (*pwsi) { + if (*pwsi == wsi) { + lwsl_info("%s: wsi %p, remv wait\n", + __func__, wsi); + *pwsi = wsi->u.hdr.ah_wait_list; + wsi->u.hdr.ah_wait_list = NULL; + pt->ah_wait_list_length--; + goto bail; } - + pwsi = &(*pwsi)->u.hdr.ah_wait_list; + } + /* no ah, not on list... no more business here */ goto bail; } + /* we did have an ah attached */ time(&now); if (now - wsi->u.hdr.ah->assigned > 3) { /* @@ -216,7 +216,7 @@ "wsi->more_rx_waiting %d\n", __func__, wsi, (int)(now - wsi->u.hdr.ah->assigned), ah->rxpos, ah->rxlen, wsi->mode, wsi->state, - wsi->u.hdr.more_rx_waiting); + wsi->more_rx_waiting); } /* if we think we're detaching one, there should be one in use */ @@ -226,6 +226,7 @@ wsi->u.hdr.ah = NULL; ah->wsi = NULL; /* no owner */ + /* oh there is nobody on the waiting list... leave it at that then */ if (!*pwsi) { ah->in_use = 0; pt->ah_count_in_use--; @@ -233,7 +234,7 @@ goto bail; } - /* somebody else on same tsi is waiting, give it to him */ + /* somebody else on same tsi is waiting, give it to oldest guy */ lwsl_info("pt wait list %p\n", *pwsi); while ((*pwsi)->u.hdr.ah_wait_list) @@ -258,6 +259,7 @@ /* point prev guy to next guy in list instead */ *pwsi = wsi->u.hdr.ah_wait_list; + /* the guy who got one is out of the list */ wsi->u.hdr.ah_wait_list = NULL; pt->ah_wait_list_length--; diff -Nru libwebsockets-1.7.1/lib/pollfd.c libwebsockets-1.7.3/lib/pollfd.c --- libwebsockets-1.7.1/lib/pollfd.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/pollfd.c 2016-02-29 03:30:07.000000000 +0000 @@ -277,7 +277,12 @@ #ifdef LWS_USE_HTTP2 struct lws *network_wsi, *wsi2; int already; +#endif + if (wsi->state == LWSS_SHUTDOWN) + return 0; + +#ifdef LWS_USE_HTTP2 lwsl_info("%s: %p\n", __func__, wsi); if (wsi->mode != LWSCM_HTTP2_SERVING) diff -Nru libwebsockets-1.7.1/lib/private-libwebsockets.h libwebsockets-1.7.3/lib/private-libwebsockets.h --- libwebsockets-1.7.1/lib/private-libwebsockets.h 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/private-libwebsockets.h 2016-02-29 03:30:07.000000000 +0000 @@ -530,6 +530,7 @@ struct lws *rx_draining_ext_list; struct lws *tx_draining_ext_list; struct lws *timeout_list; + struct lws_context *context; void *http_header_data; struct allocated_headers *ah_pool; struct lws *ah_wait_list; @@ -546,6 +547,7 @@ #if defined(LWS_USE_LIBUV) uv_loop_t *io_loop_uv; uv_signal_t signals[8]; + uv_timer_t uv_timeout_watcher; #endif #if defined(LWS_USE_LIBEV) struct lws_io_watcher w_accept; @@ -571,6 +573,7 @@ unsigned int fds_count; short ah_count_in_use; + unsigned char tid; }; /* @@ -948,12 +951,11 @@ char post_literal_equal; unsigned char parser_state; /* enum lws_token_indexes */ char redirects; - char more_rx_waiting; }; struct _lws_websocket_related { /* cheapest way to deal with ah overlap with ws union transition */ - struct _lws_header_related *hdr; + struct _lws_header_related hdr; char *rx_ubuf; unsigned int rx_ubuf_alloc; struct lws *rx_draining_ext_list; @@ -1056,6 +1058,7 @@ unsigned int user_space_externally_allocated:1; unsigned int socket_is_permanently_unusable:1; unsigned int rxflow_change_to:2; + unsigned int more_rx_waiting:1; /* has to live here since ah may stick to end */ #ifndef LWS_NO_EXTENSIONS unsigned int extension_data_pending:1; #endif diff -Nru libwebsockets-1.7.1/lib/server.c libwebsockets-1.7.3/lib/server.c --- libwebsockets-1.7.1/lib/server.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/server.c 2016-02-29 03:30:07.000000000 +0000 @@ -306,6 +306,11 @@ n = wsi->protocol->callback(wsi, LWS_CALLBACK_HTTP, wsi->user_space, uri_ptr, uri_len); + if (n) { + lwsl_info("LWS_CALLBACK_HTTP closing\n"); + + return 1; + } /* * If we're not issuing a file, check for content_length or @@ -347,7 +352,7 @@ assert(wsi->u.hdr.ah); while (len--) { - wsi->u.hdr.more_rx_waiting = !!len; + wsi->more_rx_waiting = !!len; assert(wsi->mode == LWSCM_HTTP_SERVING); @@ -359,7 +364,9 @@ if (wsi->u.hdr.parser_state != WSI_PARSING_COMPLETE) continue; - lwsl_parser("lws_parse sees parsing complete\n"); + lwsl_parser("%s: lws_parse sees parsing complete\n", __func__); + lwsl_debug("%s: wsi->more_rx_waiting=%d\n", __func__, + wsi->more_rx_waiting); wsi->mode = LWSCM_PRE_WS_SERVING_ACCEPT; lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0); @@ -739,7 +746,10 @@ * reset the existing header table and keep it. */ if (wsi->u.hdr.ah) { - if (!wsi->u.hdr.more_rx_waiting) { + lwsl_info("%s: wsi->more_rx_waiting=%d\n", __func__, + wsi->more_rx_waiting); + + if (!wsi->more_rx_waiting) { wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen; lws_header_table_detach(wsi); } else diff -Nru libwebsockets-1.7.1/lib/service.c libwebsockets-1.7.3/lib/service.c --- libwebsockets-1.7.1/lib/service.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/service.c 2016-02-29 03:30:07.000000000 +0000 @@ -292,7 +292,6 @@ lws_service_timeout_check(struct lws *wsi, unsigned int sec) { struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi]; - struct lws **pwsi; /* * if extensions want in on it (eg, we are a mux parent) @@ -316,21 +315,6 @@ pt->ah_wait_list_length, pt->fds[wsi->sock].events); #endif - lws_pt_lock(pt); - - pwsi = &pt->ah_wait_list; - if (!pwsi) - return 0; - while (*pwsi) { - if (*pwsi == wsi) - break; - pwsi = &(*pwsi)->u.hdr.ah_wait_list; - lwsl_err("%s: pwsi=%p\n", __func__, pwsi); - } - lws_pt_unlock(pt); - - if (!*pwsi) - lwsl_err("*** not on ah wait list ***\n"); /* * Since he failed a timeout, he already had a chance to do * something and was unable to... that includes situations like diff -Nru libwebsockets-1.7.1/lib/ssl.c libwebsockets-1.7.3/lib/ssl.c --- libwebsockets-1.7.1/lib/ssl.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/lib/ssl.c 2016-02-29 03:30:07.000000000 +0000 @@ -339,13 +339,6 @@ if (lws_context_ssl_init_ecdh(context)) return 1; -#if OPENSSL_VERSION_NUMBER >= 0x10200000L - n = SSL_CTX_build_cert_chain((SSL_CTX *)user, - SSL_BUILD_CHAIN_FLAG_CHECK | - SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR); - lwsl_notice("%s: build cert chain %d", __func__, n); -#endif - /* * SSL is happy and has a cert it's content with * If we're supporting HTTP2, initialize that diff -Nru libwebsockets-1.7.1/libwebsockets.spec libwebsockets-1.7.3/libwebsockets.spec --- libwebsockets-1.7.1/libwebsockets.spec 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/libwebsockets.spec 2016-02-29 03:30:07.000000000 +0000 @@ -1,11 +1,11 @@ Name: libwebsockets -Version: 1.7.1 +Version: 1.7.3 Release: 1%{?dist} Summary: Websocket Server and Client Library Group: System Environment/Libraries License: LGPLv2 with exceptions -URL: http://warmcat.com +URL: https://libwebsockets.org Source0: %{name}-%{version}.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) @@ -69,6 +69,12 @@ /%{_libdir}/pkgconfig/libwebsockets.pc %changelog +* Mon Feb 29 2016 Andy Green 1.7.3-1 +- MAJOR fixes Upstream 1.7.3 release (see changelog) + +* Thu Feb 25 2016 Andy Green 1.7.2-1 +- MINOR Upstream 1.7.2 release (see changelog) + * Sat Feb 20 2016 Andy Green 1.7.1-1 - MINOR Upstream 1.7.1 release (see changelog) diff -Nru libwebsockets-1.7.1/LICENSE libwebsockets-1.7.3/LICENSE --- libwebsockets-1.7.1/LICENSE 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/LICENSE 2016-02-29 03:30:07.000000000 +0000 @@ -20,7 +20,7 @@ satisfy this requirement: "[program] is based in part on the work of the libwebsockets project -(http://libwebsockets.org)" +(https://libwebsockets.org)" 3) Some sources included have their own, more liberal licenses, or options to get original sources with the liberal terms. diff -Nru libwebsockets-1.7.1/README.md libwebsockets-1.7.3/README.md --- libwebsockets-1.7.1/README.md 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/README.md 2016-02-29 03:30:07.000000000 +0000 @@ -8,16 +8,21 @@ This is the libwebsockets C library for lightweight websocket clients and servers. For support, visit - http://libwebsockets.org + https://libwebsockets.org + https://github.com/warmcat/libwebsockets and consider joining the project mailing list at - http://ml.libwebsockets.org/mailman/listinfo/libwebsockets + https://libwebsockets.org/mailman/listinfo/libwebsockets -You can get the latest version of the library from git +| News | +------ +| We have updated https://libwebsockets.org, if you would like your project using lws featured in the image carousel, send an image, project URL and brief summary to andy@warmcat.com | + +You can get the latest version of the library from git: -- http://git.libwebsockets.org - https://github.com/warmcat/libwebsockets +- https://libwebsockets.org/git for more information: diff -Nru libwebsockets-1.7.1/test-server/fuzxy.c libwebsockets-1.7.3/test-server/fuzxy.c --- libwebsockets-1.7.1/test-server/fuzxy.c 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/test-server/fuzxy.c 2016-02-29 03:30:07.000000000 +0000 @@ -62,6 +62,10 @@ #include #endif +#if defined(__NetBSD__) +#include +#endif + #define MAX_FUZZ_BUF (1024 * 1024) enum types { @@ -953,4 +957,3 @@ return 0; } - diff -Nru libwebsockets-1.7.1/test-server/test.html libwebsockets-1.7.3/test-server/test.html --- libwebsockets-1.7.1/test-server/test.html 2016-02-20 01:20:36.000000000 +0000 +++ libwebsockets-1.7.3/test-server/test.html 2016-02-29 03:30:07.000000000 +0000 @@ -4,12 +4,76 @@ Minimal Websocket test app @@ -19,33 +83,75 @@
-
-
Detected Browser:
...
+ + + + -
+ + +
Detected Browser: +
...
+
- -
-
libwebsockets "dumb-increment-protocol"
- + + + + + + + +
- - - - -
Not initialized
-
-The incrementing number is coming from the server and is individual for +
+Click Here to +have the test server send a big picture by http. +
+
+ +
+ + + +
+
+ + + + + + +
+ Websocket connection not initializeddumb increment-protocol
+The incrementing number is coming from the server at 20Hz and is individual for each connection to the server... try opening a second browser window.

-The button zeros just this connection's number. -

-Click Here to have the test server send a big picture by http. -
- -
-
-
libwebsockets "lws-mirror-protocol"
-
+The button sends a message over the websocket link to ask the server +to zero just this connection's number. +
+ +
+ + + + +
+ + + +
+
+ + + + + + +
+ Websocket connection not initialized + + lws-mirror-protocol +
+
Use the mouse to draw on the canvas below -- all other browser windows open on this page see your drawing in realtime and you can see any of theirs as well. @@ -56,57 +162,118 @@

libwebsockets-test-client joins in by spamming circles on to this shared canvas when run. -
- - - + + + + + + +
Drawing color: - + +
Drawing color: + +
+
+
+ + + + +
+ + + +
+
+ + + + - - - - - -
+ +
+ Websocket connection not initialized
Not initialized
-
-
- - -
-
libwebsockets "open and close testing"
-
- + + + + - - +
Open and close testing
+To help with open and close testing, you can open and close a connection by hand using + the buttons.
+ "Close" closes the connection from the browser with code 3000 + and reason 'Bye!".
+ "Request Server Close" sends a message asking the server to +initiate the close, which it does with code 1001 and reason "Seeya". +
Not initialized
-
-To help with open and close testing, you can open and close a connection by hand using - the buttons. "Request Server Close" sends a message asking the server to -initiate the close. -
-
-
-
-Looking for support? http://libwebsockets.org
-Join the mailing list: ​http://ml.libwebsockets.org/mailman/listinfo/libwebsockets + + + + +
+ + + +
+
+ + + + + + + + + + + + +
+
Websocket connection not initialized
+
+Server Info +
+This information is sent by the server over a ws[s] link and updated live +whenever the information changes server-side. +
+
+
+
+
+Looking for support? https://libwebsockets.org, https://github.com/warmcat/libwebsockets
+Join the mailing list: https://libwebsockets.org/mailman/listinfo/libwebsockets +