diff options
Diffstat (limited to 'thirdparty/libwebsockets/core')
-rw-r--r-- | thirdparty/libwebsockets/core/context.c | 25 | ||||
-rw-r--r-- | thirdparty/libwebsockets/core/libwebsockets.c | 55 | ||||
-rw-r--r-- | thirdparty/libwebsockets/core/output.c | 12 | ||||
-rw-r--r-- | thirdparty/libwebsockets/core/private.h | 33 |
4 files changed, 98 insertions, 27 deletions
diff --git a/thirdparty/libwebsockets/core/context.c b/thirdparty/libwebsockets/core/context.c index db9151b95f..7be004df33 100644 --- a/thirdparty/libwebsockets/core/context.c +++ b/thirdparty/libwebsockets/core/context.c @@ -134,7 +134,7 @@ lws_protocol_vh_priv_get(struct lws_vhost *vhost, { int n = 0; - if (!vhost || !vhost->protocol_vh_privs) + if (!vhost || !vhost->protocol_vh_privs || !prot) return NULL; while (n < vhost->count_protocols && &vhost->protocols[n] != prot) @@ -808,7 +808,7 @@ lws_create_vhost(struct lws_context *context, #ifdef LWS_WITH_ACCESS_LOG if (info->log_filepath) { - vh->log_fd = open(info->log_filepath, + vh->log_fd = lws_open(info->log_filepath, O_CREAT | O_APPEND | O_RDWR, 0600); if (vh->log_fd == (int)LWS_INVALID_FILE) { lwsl_err("unable to open log filepath %s\n", @@ -936,24 +936,29 @@ lws_create_event_pipes(struct lws_context *context) wsi->tsi = n; wsi->vhost = NULL; wsi->event_pipe = 1; + wsi->desc.sockfd = LWS_SOCK_INVALID; + context->pt[n].pipe_wsi = wsi; + context->count_wsi_allocated++; - if (lws_plat_pipe_create(wsi)) { - lws_free(wsi); + if (lws_plat_pipe_create(wsi)) + /* + * platform code returns 0 if it actually created pipes + * and initialized pt->dummy_pipe_fds[]. If it used + * some other mechanism outside of signaling in the + * normal event loop, we skip treating the pipe as + * related to dummy_pipe_fds[], adding it to the fds, + * etc. + */ continue; - } + wsi->desc.sockfd = context->pt[n].dummy_pipe_fds[0]; lwsl_debug("event pipe fd %d\n", wsi->desc.sockfd); - context->pt[n].pipe_wsi = wsi; - if (context->event_loop_ops->accept) context->event_loop_ops->accept(wsi); if (__insert_wsi_socket_into_fds(context, wsi)) return 1; - - //lws_change_pollfd(context->pt[n].pipe_wsi, 0, LWS_POLLIN); - context->count_wsi_allocated++; } return 0; diff --git a/thirdparty/libwebsockets/core/libwebsockets.c b/thirdparty/libwebsockets/core/libwebsockets.c index 0da02b17e4..58f00226f6 100644 --- a/thirdparty/libwebsockets/core/libwebsockets.c +++ b/thirdparty/libwebsockets/core/libwebsockets.c @@ -28,7 +28,7 @@ #ifdef LWS_WITH_IPV6 #if defined(WIN32) || defined(_WIN32) #include <wincrypt.h> -#include <Iphlpapi.h> +#include <iphlpapi.h> #else #include <net/if.h> #endif @@ -58,6 +58,28 @@ static const char * const log_level_names[] = { }; #endif +int lws_open(const char *__file, int __oflag, ...) +{ + va_list ap; + int n; + + va_start(ap, __oflag); + if (((__oflag & O_CREAT) == O_CREAT) +#if defined(O_TMPFILE) + || ((__oflag & O_TMPFILE) == O_TMPFILE) +#endif + ) + /* last arg is really a mode_t. But windows... */ + n = open(__file, __oflag, va_arg(ap, uint32_t)); + else + n = open(__file, __oflag); + va_end(ap); + + lws_plat_apply_FD_CLOEXEC(n); + + return n; +} + #if defined (_DEBUG) void lwsi_set_role(struct lws *wsi, lws_wsi_state_t role) { @@ -826,7 +848,15 @@ just_kill_connection: if (!wsi->protocol) pro = &wsi->vhost->protocols[0]; - pro->callback(wsi, + if (!wsi->upgraded_to_http2 || !lwsi_role_client(wsi)) + /* + * The network wsi for a client h2 connection shouldn't + * call back for its role: the child stream connections + * own the role. Otherwise h2 will call back closed + * one too many times as the children do it and then + * the closing network stream. + */ + pro->callback(wsi, wsi->role_ops->close_cb[lwsi_role_server(wsi)], wsi->user_space, NULL, 0); wsi->told_user_closed = 1; @@ -1453,7 +1483,7 @@ lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path, pf = fops->next; while (pf) { n = 0; - while (n < (int)ARRAY_SIZE(pf->fi) && pf->fi[n].sig) { + while (n < (int)LWS_ARRAY_SIZE(pf->fi) && pf->fi[n].sig) { if (p >= vfs_path + pf->fi[n].len) if (!strncmp(p - (pf->fi[n].len - 1), pf->fi[n].sig, @@ -1935,9 +1965,9 @@ static const char * const colours[] = { "[32;1m", /* LLL_INFO */ "[34;1m", /* LLL_DEBUG */ "[33;1m", /* LLL_PARSER */ - "[33;1m", /* LLL_HEADER */ - "[33;1m", /* LLL_EXT */ - "[33;1m", /* LLL_CLIENT */ + "[33m", /* LLL_HEADER */ + "[33m", /* LLL_EXT */ + "[33m", /* LLL_CLIENT */ "[33;1m", /* LLL_LATENCY */ "[30;1m", /* LLL_USER */ }; @@ -1946,14 +1976,14 @@ LWS_VISIBLE void lwsl_emit_stderr(int level, const char *line) { char buf[50]; static char tty = 3; - int n, m = ARRAY_SIZE(colours) - 1; + int n, m = LWS_ARRAY_SIZE(colours) - 1; if (!tty) tty = isatty(2) | 2; lwsl_timestamp(level, buf, sizeof(buf)); if (tty == 3) { - n = 1 << (ARRAY_SIZE(colours) - 1); + n = 1 << (LWS_ARRAY_SIZE(colours) - 1); while (n) { if (level & n) break; @@ -2060,7 +2090,9 @@ lwsl_hexdump_level(int hexdump_level, const void *vbuf, size_t len) LWS_VISIBLE void lwsl_hexdump(const void *vbuf, size_t len) { +#if defined(_DEBUG) lwsl_hexdump_level(LLL_DEBUG, vbuf, len); +#endif } LWS_VISIBLE int @@ -2091,6 +2123,8 @@ lws_partial_buffered(struct lws *wsi) LWS_VISIBLE lws_fileofs_t lws_get_peer_write_allowance(struct lws *wsi) { + if (!wsi->role_ops->tx_credit) + return -1; return wsi->role_ops->tx_credit(wsi); } @@ -3364,7 +3398,7 @@ lws_stats_log_dump(struct lws_context *context) wl = pt->http.ah_wait_list; while (wl) { m++; - wl = wl->ah_wait_list; + wl = wl->http.ah_wait_list; } lwsl_notice(" AH wait list count / actual: %d / %d\n", @@ -3401,7 +3435,8 @@ lws_stats_log_dump(struct lws_context *context) strcpy(buf, "unknown"); #if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) lwsl_notice(" peer %s: count wsi: %d, count ah: %d\n", - buf, df->count_wsi, df->count_ah); + buf, df->count_wsi, + df->http.count_ah); #else lwsl_notice(" peer %s: count wsi: %d\n", buf, df->count_wsi); diff --git a/thirdparty/libwebsockets/core/output.c b/thirdparty/libwebsockets/core/output.c index e2ff18ef27..11965a06b9 100644 --- a/thirdparty/libwebsockets/core/output.c +++ b/thirdparty/libwebsockets/core/output.c @@ -126,6 +126,18 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len) lwsl_info("** %p signalling to close now\n", wsi); return -1; /* retry closing now */ } + +#if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) +#if !defined(LWS_WITHOUT_SERVER) + if (wsi->http.deferred_transaction_completed) { + lwsl_notice("%s: partial completed, doing " + "deferred transaction completed\n", + __func__); + wsi->http.deferred_transaction_completed = 0; + return lws_http_transaction_completed(wsi); + } +#endif +#endif } /* always callback on writeable */ lws_callback_on_writable(wsi); diff --git a/thirdparty/libwebsockets/core/private.h b/thirdparty/libwebsockets/core/private.h index d6b494ac8c..73748b0498 100644 --- a/thirdparty/libwebsockets/core/private.h +++ b/thirdparty/libwebsockets/core/private.h @@ -232,7 +232,7 @@ #endif #else /* not windows */ - static inline int compatible_close(int fd) { return close(fd); } + static LWS_INLINE int compatible_close(int fd) { return close(fd); } #include <sys/stat.h> #include <sys/time.h> @@ -351,7 +351,15 @@ extern "C" { #define LWS_H2_RX_SCRATCH_SIZE 512 - +#if defined(WIN32) || defined(_WIN32) + // Visual studio older than 2015 and WIN_CE has only _stricmp + #if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE) + #define strcasecmp _stricmp + #elif !defined(__MINGW32__) + #define strcasecmp stricmp + #endif + #define getdtablesize() 30000 +#endif /* * All lws_tls...() functions must return this type, converting the @@ -863,6 +871,7 @@ struct lws_context { unsigned int timeout_secs; unsigned int pt_serv_buf_size; int max_http_header_data; + int max_http_header_pool; int simultaneous_ssl_restriction; int simultaneous_ssl; #if defined(LWS_WITH_PEER_LIMITS) @@ -889,7 +898,6 @@ struct lws_context { volatile int service_tid; int service_tid_detected; - short max_http_header_pool; short count_threads; short plugin_protocol_count; short plugin_extension_count; @@ -1216,7 +1224,7 @@ LWS_EXTERN int lws_rxflow_cache(struct lws *wsi, unsigned char *buf, int n, int len); #ifndef LWS_LATENCY -static inline void +static LWS_INLINE void lws_latency(struct lws_context *context, struct lws *wsi, const char *action, int ret, int completion) { do { @@ -1224,7 +1232,7 @@ lws_latency(struct lws_context *context, struct lws *wsi, const char *action, (void)completion; } while (0); } -static inline void +static LWS_INLINE void lws_latency_pre(struct lws_context *context, struct lws *wsi) { do { (void)context; (void)wsi; } while (0); } @@ -1597,6 +1605,9 @@ void lws_free(void *p); #define lws_free_set_NULL(P) do { lws_realloc(P, 0, "free"); (P) = NULL; } while(0) #endif +char * +lws_strdup(const char *s); + int lws_plat_pipe_create(struct lws *wsi); int @@ -1606,6 +1617,9 @@ lws_plat_pipe_close(struct lws *wsi); int lws_create_event_pipes(struct lws_context *context); +int lws_open(const char *__file, int __oflag, ...); +void lws_plat_apply_FD_CLOEXEC(int n); + const struct lws_plat_file_ops * lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path, const char **vpath); @@ -1673,10 +1687,10 @@ lws_broadcast(struct lws_context *context, int reason, void *in, size_t len); lws_stats_atomic_max(struct lws_context * context, struct lws_context_per_thread *pt, int index, uint64_t val); #else - static inline uint64_t lws_stats_atomic_bump(struct lws_context * context, + static LWS_INLINE uint64_t lws_stats_atomic_bump(struct lws_context * context, struct lws_context_per_thread *pt, int index, uint64_t bump) { (void)context; (void)pt; (void)index; (void)bump; return 0; } - static inline uint64_t lws_stats_atomic_max(struct lws_context * context, + static LWS_INLINE uint64_t lws_stats_atomic_max(struct lws_context * context, struct lws_context_per_thread *pt, int index, uint64_t val) { (void)context; (void)pt; (void)index; (void)val; return 0; } #endif @@ -1703,6 +1717,11 @@ void lws_peer_dump_from_wsi(struct lws *wsi); #endif +#ifdef LWS_WITH_HTTP_PROXY +hubbub_error +html_parser_cb(const hubbub_token *token, void *pw); +#endif + void __lws_remove_from_timeout_list(struct lws *wsi); |