Skip to content

Commit 375ea50

Browse files
committed
fixes
1 parent 1e6379b commit 375ea50

3 files changed

Lines changed: 52 additions & 14 deletions

File tree

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/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)