1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

ss: server mode fixes

This commit is contained in:
Andy Green 2021-01-11 08:29:02 +00:00
parent 06662a64fa
commit c6d172c2ed
4 changed files with 19 additions and 6 deletions

View file

@ -91,6 +91,9 @@ lws_get_or_create_peer(struct lws_vhost *vhost, lws_sockfd_type sockfd)
for (n = 0; n < (int)rlen; n++)
hash = (uint32_t)((((hash << 4) | (hash >> 28)) * (uint32_t)n) ^ q8[n]);
if (!context->pl_hash_elements)
return NULL;
hash = hash % context->pl_hash_elements;
lws_context_lock(context, "peer search"); /* <======================= */

View file

@ -180,7 +180,7 @@ lws_add_http_common_headers(struct lws *wsi, unsigned int code,
return 1;
#if defined(LWS_WITH_HTTP_STREAM_COMPRESSION)
if (!wsi->http.lcs &&
if (!wsi->http.lcs && content_type &&
(!strncmp(content_type, "text/", 5) ||
!strcmp(content_type, "application/javascript") ||
!strcmp(content_type, "image/svg+xml")))

View file

@ -466,10 +466,13 @@ secstream_h1(struct lws *wsi, enum lws_callback_reasons reason, void *user,
break;
} else
h->seqstate = SSSEQ_IDLE;
/* already disconnected, no action for DISCONNECT_ME */
r = lws_ss_event_helper(h, LWSSSCS_DISCONNECTED);
if (r != LWSSSSRET_OK)
return _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE(r, wsi, &h);
if (h->ss_dangling_connected) {
/* already disconnected, no action for DISCONNECT_ME */
r = lws_ss_event_helper(h, LWSSSCS_DISCONNECTED);
if (r != LWSSSSRET_OK)
return _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE(r, wsi, &h);
}
break;
@ -969,6 +972,12 @@ malformed:
}
}
if (!h->ss_dangling_connected) {
r = lws_ss_event_helper(h, LWSSSCS_CONNECTED);
if (r)
return _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE(r, wsi, &h);
}
r = lws_ss_event_helper(h, LWSSSCS_SERVER_TXN);
if (r)
return _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE(r, wsi, &h);

View file

@ -109,6 +109,7 @@ static const uint32_t ss_state_txn_validity[] = {
(1 << LWSSSCS_DESTROYING),
[LWSSSCS_CONNECTED] = (1 << LWSSSCS_SERVER_UPGRADE) |
(1 << LWSSSCS_SERVER_TXN) |
(1 << LWSSSCS_AUTH_FAILED) |
(1 << LWSSSCS_QOS_ACK_REMOTE) |
(1 << LWSSSCS_QOS_NACK_REMOTE) |
@ -886,7 +887,7 @@ lws_ss_create(struct lws_context *context, int tsi, const lws_ss_info_t *ssi,
i.vhost_name = h->policy->streamtype;
i.port = h->policy->port;
if (i.iface[0] == '+') {
if (i.iface && i.iface[0] == '+') {
i.iface++;
i.options |= LWS_SERVER_OPTION_UNIX_SOCK;
}