Skip to content

Commit 3e6e391

Browse files
committed
fixes
Various things that Sai identified needed fixing
1 parent 796db76 commit 3e6e391

File tree

28 files changed

+247
-117
lines changed

28 files changed

+247
-117
lines changed

.sai.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@
155155
"lws_system": {
156156
"cmake": "-DLWS_SUPPRESS_DEPRECATED_API_WARNINGS=1 -DLWS_WITH_ACME=1 -DLWS_WITH_MINIMAL_EXAMPLES=1 -DCMAKE_BUILD_TYPE=RELEASE -DLWS_WITH_GENCRYPTO=1 -DLWS_WITH_JOSE=1 -DLWS_WITH_SYS_ASYNC_DNS=1 -DLWS_WITH_SYS_NTPCLIENT=1"
157157
},
158+
"async_dnssec": {
159+
"cmake": "-DLWS_SUPPRESS_DEPRECATED_API_WARNINGS=1 -DCMAKE_BUILD_TYPE=DEBUG -DLWS_WITH_GENCRYPTO=1 -DLWS_WITH_JOSE=1 -DLWS_WITH_SYS_ASYNC_DNS=1 -DLWS_WITH_SYS_ASYNC_DNS_DNSSEC=1"
160+
},
161+
158162
"secure-streams": {
159163
"cmake": "-DLWS_WITH_SECURE_STREAMS=1 -DLWS_WITH_MINIMAL_EXAMPLES=1",
160164
"platforms": "w11/x86_64-amd/msvc,netbsd/aarch64BE-bcm2837-a53/gcc"
@@ -254,14 +258,14 @@
254258
# only applies to the coverity builder, and on pushes to "coverity" branch
255259

256260
"coverity": {
257-
"cmake": "-DLWS_WITHOUT_EXTENSIONS=0 -DLWS_WITH_CGI=1 -DLWS_IPV6=1 -DLWS_WITH_HTTP_PROXY=1 -DLWS_WITH_RANGES=1 -DLWS_WITH_THREADPOOL=1 -DLWS_WITH_CBOR=1 -DLWS_WITH_JOSE=1 -DLWS_WITH_COSE=1 -DLWS_WITH_SYS_DHCP_CLIENT=1 -DLWS_WITH_FTS=1 -DLWS_WITH_STRUCT_SQLITE3=1 -DLWS_ROLE_DBUS=1 -DLWS_WITH_SYS_ASYNC_DNS=1 -DLWS_WITH_SYS_FAULT_INJECTION=1 -DLWS_WITH_TLS_JIT_TRUST=1 -DLWS_ROLE_MQTT=1 -DLWS_ROLE_RAW_PROXY=1 -DLWS_WITH_EVENT_LIBS=1 -DLWS_WITH_LIBUV=1 -DLWS_WITH_STRUCT_JSON=1 -DLWS_WITH_LWS_DSH=1 -DLWS_WITH_SECURE_STREAMS_PROXY_API=1",
261+
"cmake": "-DLWS_WITHOUT_EXTENSIONS=0 -DLWS_WITH_CGI=1 -DLWS_IPV6=1 -DLWS_WITH_HTTP_PROXY=1 -DLWS_WITH_RANGES=1 -DLWS_WITH_THREADPOOL=1 -DLWS_WITH_CBOR=1 -DLWS_WITH_JOSE=1 -DLWS_WITH_COSE=1 -DLWS_WITH_SYS_DHCP_CLIENT=1 -DLWS_WITH_FTS=1 -DLWS_WITH_STRUCT_SQLITE3=1 -DLWS_ROLE_DBUS=1 -DLWS_WITH_SYS_ASYNC_DNS=1 -DLWS_WITH_SYS_ASYNC_DNS_DNSSEC=1 -DLWS_WITH_WEBRTC=1 -DLWS_WITH_DHT=1 -DLWS_WITH_ASYNC_QUEUE=1 -DLWS_WITH_SYS_FAULT_INJECTION=1 -DLWS_WITH_TLS_JIT_TRUST=1 -DLWS_ROLE_MQTT=1 -DLWS_ROLE_RAW_PROXY=1 -DLWS_WITH_EVENT_LIBS=1 -DLWS_WITH_LIBUV=1 -DLWS_WITH_STRUCT_JSON=1 -DLWS_WITH_LWS_DSH=1 -DLWS_WITH_SECURE_STREAMS_PROXY_API=1",
258262
"platforms": "none, coverity/x86_64/gcc",
259263
"cpack": "export STAMP=`git log -1 --pretty=format:%h` && rm -f libwebsockets.tgz && tar czvf libwebsockets.tgz cov-int && script -q -c \"cat /etc/coverity/secrets.sh | lws-minimal-http-client-post-form https://scan.coverity.com:443/builds?project=warmcat%2Flibwebsockets --form file=@libwebsockets.tgz --form version=${STAMP} --form 'description=lws qa'\" /dev/null",
260264
"branches": "coverity"
261265
},
262266
# awkward, we also want to test mbedtls, but coverity blocks on SSL build needing manual intervention
263267
"coverity-mbedtls": {
264-
"cmake": "-DLWS_WITH_MBEDTLS=1 -DLWS_WITHOUT_EXTENSIONS=0 -DLWS_WITH_CGI=1 -DLWS_IPV6=1 -DLWS_WITH_HTTP_PROXY=1 -DLWS_WITH_RANGES=1 -DLWS_WITH_THREADPOOL=1 -DLWS_WITH_CBOR=1 -DLWS_WITH_JOSE=1 -DLWS_WITH_COSE=1 -DLWS_WITH_SYS_DHCP_CLIENT=1 -DLWS_WITH_FTS=1 -DLWS_WITH_STRUCT_SQLITE3=1 -DLWS_ROLE_DBUS=1 -DLWS_WITH_SYS_ASYNC_DNS=1 -DLWS_WITH_SYS_FAULT_INJECTION=1 -DLWS_WITH_TLS_JIT_TRUST=1 -DLWS_ROLE_MQTT=1 -DLWS_ROLE_RAW_PROXY=1 -DLWS_WITH_EVENT_LIBS=1 -DLWS_WITH_LIBUV=1 -DLWS_WITH_STRUCT_JSON=1 -DLWS_WITH_LWS_DSH=1 -DLWS_WITH_SECURE_STREAMS_PROXY_API=1",
268+
"cmake": "-DLWS_WITH_MBEDTLS=1 -DLWS_WITHOUT_EXTENSIONS=0 -DLWS_WITH_CGI=1 -DLWS_IPV6=1 -DLWS_WITH_HTTP_PROXY=1 -DLWS_WITH_RANGES=1 -DLWS_WITH_THREADPOOL=1 -DLWS_WITH_CBOR=1 -DLWS_WITH_JOSE=1 -DLWS_WITH_COSE=1 -DLWS_WITH_SYS_DHCP_CLIENT=1 -DLWS_WITH_FTS=1 -DLWS_WITH_STRUCT_SQLITE3=1 -DLWS_ROLE_DBUS=1 -DLWS_WITH_SYS_ASYNC_DNS=1 -DLWS_WITH_SYS_ASYNC_DNS_DNSSEC=1 -DLWS_WITH_WEBRTC=1 -DLWS_WITH_DHT=1 -DLWS_WITH_ASYNC_QUEUE=1 -DLWS_WITH_SYS_FAULT_INJECTION=1 -DLWS_WITH_TLS_JIT_TRUST=1 -DLWS_ROLE_MQTT=1 -DLWS_ROLE_RAW_PROXY=1 -DLWS_WITH_EVENT_LIBS=1 -DLWS_WITH_LIBUV=1 -DLWS_WITH_STRUCT_JSON=1 -DLWS_WITH_LWS_DSH=1 -DLWS_WITH_SECURE_STREAMS_PROXY_API=1",
265269
"platforms": "none, coverity/x86_64/gcc",
266270
"cpack": "export STAMP=`git log -1 --pretty=format:%h` && rm -f libwebsockets.tgz && tar czvf libwebsockets.tgz cov-int && script -q -c \"cat /etc/coverity/secrets.sh | lws-minimal-http-client-post-form https://scan.coverity.com:443/builds?project=warmcat%2Flibwebsockets --form file=@libwebsockets.tgz --form version=${STAMP} --form 'description=lws qa'\" /dev/null",
267271
"branches": "coverity"

changelog

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
11
Changelog
22
---------
33

4+
Development
5+
===========
6+
7+
- Async DNS: support DNSSEC
8+
- Async DNS: support tcp fallback
9+
- Support authoritative DNS server, like nsd, using own-signed zone files
10+
- Support authoritative DNS signing (zone file -> DNSSEC ready signed zone
11+
file)
12+
- LWS_WITH_ASYNC_QUEUE: Makes slow tls negotiation and read / write happen
13+
via a queue + worker threads, instead of on the main event loop. This
14+
reduces the amount of blocking events delaying the event loop
15+
- LWS_WITH_LATENCY: support detailed event loop blocking measurements and a
16+
plugin to monitor event loop performace dynamically; lists worst blockers by
17+
protocol and actual delays
18+
- Support a headless camera participant to WebRTC conference
19+
- Support WebRTC conferencing serving / mixing over h.264 up to 1080p
20+
(and if supported in hw, AV1)
21+
- TLS: Support DTLS accross all the libraries
22+
- LWS_WITH_MNEMONIC support for mnemonic key backup
23+
- CRC32 is now provided
24+
- Generic HMAC now supports SHA-1
25+
- vhost: protocols from plugins are instantiated first, and protocols now
26+
have a priority field to control who gets instantiated before who
27+
additionally. This simplifies basing on plugin protocols.
28+
- lws_mutex is now public, platform-independent defines
29+
- Client: improve connect retries by iterating through DNS results
30+
- Contributors: AI isn't necessarily a problem, but we want to know which AI
31+
- ipv6: now built by default
32+
- TLS: LWS_WITH_GNUTLS: Support building against GnuTLS for tls + gencrypto
33+
- LWS_WITH_DHT: generic Kademlia DHT with pluggable additional verbs and lws
34+
UDP integratin
35+
- lws_captcha_ratelimit plugin can force generic captcha by introducing
36+
multiple mount order on same mounpoint, supports whitelisting netblocks
37+
- Context creation: Sumarize OpenSSL library version available if in use
38+
- JWS: support LWS_JOSE_ENCTYPE_NONE
39+
- TLS: LWS_WITH_SCHANNEL: Support building against Schannel, the windows
40+
native tls library for tls and gencrypto
41+
- SS: Support urlargs on server side
42+
- lhp: various improvements (still not very usable)
43+
444
v4.5.0
545
======
6-
46+
747
- fixes from coverity and Nozomi Networks
848
- fix for mountpoint headers being sticky for all following mounts too
949
- b64 apis: fixes and new api tests

include/libwebsockets.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ typedef int suseconds_t;
175175
#include <unistd.h>
176176

177177
#if defined (LWS_PLAT_FREERTOS)
178+
#if defined(LWS_AMAZON_RTOS)
179+
#include <FreeRTOS.h>
180+
#include <semphr.h>
181+
#include <task.h>
182+
#else
183+
#include <freertos/FreeRTOS.h>
184+
#include <freertos/semphr.h>
185+
#include <freertos/task.h>
186+
#endif
187+
178188
typedef SemaphoreHandle_t lws_mutex_t;
179189
#define lws_mutex_init(x) x = xSemaphoreCreateMutex()
180190
#define lws_mutex_destroy(x) vSemaphoreDelete(x)

include/libwebsockets/lws-dht.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <stddef.h>
2929
#include <stdint.h>
3030
#include <stdio.h>
31+
#include <libwebsockets/lws-genhash.h>
3132

3233
/*! \defgroup dht Distributed Hash Table
3334
* ## Distributed Hash Table (DHT) API

lib/core-net/close.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -654,15 +654,6 @@ __lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason,
654654
if (wsi->http.buflist_post_body)
655655
lws_buflist_destroy_all_segments(&wsi->http.buflist_post_body);
656656
#endif
657-
#if defined(LWS_WITH_UDP)
658-
if (wsi->udp) {
659-
/* confirm no sul left scheduled in wsi->udp itself */
660-
lws_sul_debug_zombies(wsi->a.context, wsi->udp,
661-
sizeof(*wsi->udp), "close udp wsi");
662-
663-
lws_free_set_NULL(wsi->udp);
664-
}
665-
#endif
666657

667658
if (lws_rops_fidx(wsi->role_ops, LWS_ROPS_close_kill_connection))
668659
lws_rops_func_fidx(wsi->role_ops,

lib/core-net/service.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,6 @@ _lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
867867
}
868868

869869
wsi->could_have_pending = 0; /* clear back-to-back write detection */
870-
pt->inside_lws_service = 1;
871870

872871
/* okay, what we came here to do... */
873872

@@ -884,7 +883,6 @@ _lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
884883
switch (lws_rops_func_fidx(wsi->role_ops, LWS_ROPS_handle_POLLIN).
885884
handle_POLLIN(pt, wsi, pollfd)) {
886885
case LWS_HPI_RET_WSI_ALREADY_DIED:
887-
pt->inside_lws_service = 0;
888886
#if defined (_WIN32)
889887
break;
890888
#else
@@ -915,7 +913,6 @@ _lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
915913
* we can't clear revents now because it'd be the wrong guy's
916914
* revents
917915
*/
918-
pt->inside_lws_service = 0;
919916
return 1;
920917
default:
921918
assert(0);
@@ -945,8 +942,6 @@ _lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
945942
lws_latency_note(pt, _role_out_start, 2000, "pollout:%dms", ms);
946943
}
947944
#endif
948-
pt->inside_lws_service = 0;
949-
950945
return 0;
951946
}
952947

@@ -976,7 +971,9 @@ lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
976971
lws_latency_cb_start(pt);
977972
#endif
978973

974+
pt->inside_lws_service = 1;
979975
ret = _lws_service_fd_tsi(context, pollfd, tsi);
976+
pt->inside_lws_service = 0;
980977

981978
#if defined(LWS_WITH_LATENCY)
982979
lws_latency_cb_end(pt, pn);

lib/core/adapt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ lws_adapt_report(struct lws_adapt *a, int success, lws_usec_t us)
146146
if (l->ewma_short < LWS_ADAPT_DOWNGRADE_THRESHOLD && a->active_level < a->num_levels - 1) {
147147
lwsl_notice("%s: Downgrading level %d -> %d (Score: %u/%u)\n",
148148
__func__, a->active_level, a->active_level + 1,
149-
l->ewma_short, LWS_ADAPT_MAX_SCORE);
149+
(unsigned int)l->ewma_short, (unsigned int)LWS_ADAPT_MAX_SCORE);
150150

151151
a->active_level++;
152152
a->last_downgrade_us = us;
@@ -167,7 +167,7 @@ lws_adapt_report(struct lws_adapt *a, int success, lws_usec_t us)
167167
if (a->backoff_multiplier < 1)
168168
a->backoff_multiplier = 1;
169169
a->last_downgrade_us = us; /* Reset the clock for the next forgiveness tier */
170-
lwsl_notice("%s: Sustained stability! Reducing backoff multiplier to %u\n", __func__, a->backoff_multiplier);
170+
lwsl_notice("%s: Sustained stability! Reducing backoff multiplier to %u\n", __func__, (unsigned int)a->backoff_multiplier);
171171
}
172172
}
173173
}
@@ -192,7 +192,7 @@ lws_adapt_get_level(struct lws_adapt *a)
192192
if (now > a->last_downgrade_us + backoff_required) {
193193
lwsl_notice("%s: Upgrading level %d -> %d (Stable for %u us)\n",
194194
__func__, a->active_level, a->active_level - 1,
195-
(uint32_t)(now - a->last_downgrade_us));
195+
(unsigned int)(now - a->last_downgrade_us));
196196

197197
a->active_level--;
198198
a->last_downgrade_us = now; /* So we measure forgiveness from the moment of success */

lib/misc/dht.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
#include "../core/private-lib-core.h"
2828
#include "../core-net/private-lib-core-net.h"
29+
#ifndef _WIN32
2930
#include <arpa/inet.h>
31+
#endif
3032
#include <errno.h>
3133

3234
// #define DHT_VERBOSE

lib/roles/http/client/client-http.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,8 +1211,24 @@ lws_client_interpret_server_handshake(struct lws *wsi)
12111211
wsi->http.ah->frags[wsi->http.ah->frag_index[_WSI_TOKEN_CLIENT_URI]].offset = wsi->http.ah->pos;
12121212
wsi->http.ah->frags[wsi->http.ah->frag_index[_WSI_TOKEN_CLIENT_URI]].len = (uint16_t)(pl + 1u);
12131213

1214-
if (wsi->stash)
1215-
wsi->stash->cis[CIS_PATH] = wsi->http.ah->data + wsi->http.ah->pos;
1214+
if (wsi->stash) {
1215+
struct client_info_stash *ostash = wsi->stash;
1216+
const char *cisin[CIS_COUNT];
1217+
int m;
1218+
1219+
wsi->stash = NULL;
1220+
for (m = 0; m < CIS_COUNT; m++)
1221+
cisin[m] = ostash->cis[m];
1222+
cisin[CIS_PATH] = wsi->http.ah->data + wsi->http.ah->pos;
1223+
1224+
if (lws_client_stash_create(wsi, cisin)) {
1225+
lwsl_err("%s: failed to realloc stash for redirect\n", __func__);
1226+
lws_free(ostash);
1227+
cce = "HS: stash realloc failed";
1228+
goto bail3;
1229+
}
1230+
lws_free(ostash);
1231+
}
12161232

12171233
wsi->http.ah->pos += pl + 1u;
12181234
}

lib/roles/listen/ops-listen.c

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424

2525
#include <private-lib-core.h>
2626

27+
static void
28+
lws_accept_pause_cb(lws_sorted_usec_list_t *sul)
29+
{
30+
struct lws *wsi = lws_container_of(sul, struct lws, sul_validity);
31+
32+
if (lws_change_pollfd(wsi, 0, LWS_POLLIN))
33+
lwsl_wsi_info(wsi, "fail");
34+
}
35+
2736
static lws_handling_result_t
2837
rops_handle_POLLIN_listen(struct lws_context_per_thread *pt, struct lws *wsi,
2938
struct lws_pollfd *pollfd)
@@ -101,11 +110,33 @@ rops_handle_POLLIN_listen(struct lws_context_per_thread *pt, struct lws *wsi,
101110
}
102111
#endif
103112
if (filt.accept_fd == LWS_SOCK_INVALID) {
104-
if (LWS_ERRNO == LWS_EAGAIN ||
105-
LWS_ERRNO == LWS_EWOULDBLOCK) {
113+
int m = LWS_ERRNO;
114+
115+
if (m == LWS_EAGAIN ||
116+
m == LWS_EWOULDBLOCK) {
117+
break;
118+
}
119+
lwsl_err("accept: errno %d\n", m);
120+
121+
if (
122+
#if defined(WSAEMFILE)
123+
m == WSAEMFILE ||
124+
#endif
125+
#if defined(EMFILE)
126+
m == EMFILE ||
127+
#endif
128+
#if defined(ENFILE)
129+
m == ENFILE ||
130+
#endif
131+
0) {
132+
if (lws_change_pollfd(wsi, LWS_POLLIN, 0))
133+
lwsl_wsi_info(wsi, "failed disable POLLIN");
134+
135+
lws_sul_schedule(context, 0, &wsi->sul_validity,
136+
lws_accept_pause_cb,
137+
100 * LWS_US_PER_MS);
106138
break;
107139
}
108-
lwsl_err("accept: errno %d\n", LWS_ERRNO);
109140

110141
return LWS_HPI_RET_HANDLED;
111142
}

0 commit comments

Comments
 (0)