mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
protocol_init: make errors fatal
This commit is contained in:
parent
6f1e67cf91
commit
de21a5b5b9
4 changed files with 14 additions and 6 deletions
|
@ -185,7 +185,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)
|
||||
|
@ -316,6 +316,8 @@ lws_protocol_init(struct lws_context *context)
|
|||
vh->protocol_vh_privs[n] = NULL;
|
||||
lwsl_err("%s: protocol %s failed init\n", __func__,
|
||||
vh->protocols[n].name);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -553,8 +553,10 @@ lws_service_periodic_checks(struct lws_context *context,
|
|||
#endif
|
||||
|
||||
if (!context->protocol_init_done)
|
||||
if (lws_protocol_init(context))
|
||||
if (lws_protocol_init(context)) {
|
||||
lwsl_err("%s: lws_protocol_init failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
time(&now);
|
||||
|
||||
|
@ -805,7 +807,7 @@ lws_service_periodic_checks(struct lws_context *context,
|
|||
context->tls_ops->periodic_housekeeping)
|
||||
context->tls_ops->periodic_housekeeping(context, now);
|
||||
|
||||
return timed_out;
|
||||
return 0;
|
||||
}
|
||||
|
||||
LWS_VISIBLE int
|
||||
|
@ -820,7 +822,7 @@ lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
|
|||
|
||||
/* the socket we came to service timed out, nothing to do */
|
||||
if (lws_service_periodic_checks(context, pollfd, tsi) || !pollfd)
|
||||
return 0;
|
||||
return -2;
|
||||
|
||||
/* no, here to service a socket descriptor */
|
||||
wsi = wsi_from_fd(context, pollfd->fd);
|
||||
|
|
|
@ -166,8 +166,11 @@ faked_service:
|
|||
c--;
|
||||
|
||||
m = lws_service_fd_tsi(context, &pt->fds[n], tsi);
|
||||
if (m < 0)
|
||||
if (m < 0) {
|
||||
lwsl_err("%s: lws_service_fd_tsi returned %d\n",
|
||||
__func__, m);
|
||||
return -1;
|
||||
}
|
||||
/* if something closed, retry this slot */
|
||||
if (m)
|
||||
n--;
|
||||
|
|
|
@ -572,7 +572,7 @@ send_hs:
|
|||
return wsi;
|
||||
|
||||
oom4:
|
||||
if (lwsi_role_client(wsi) && lwsi_state_est(wsi)) {
|
||||
if (lwsi_role_client(wsi) /* && lwsi_state_est(wsi) */) {
|
||||
wsi->protocol->callback(wsi,
|
||||
LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
|
||||
wsi->user_space, (void *)cce, strlen(cce));
|
||||
|
@ -591,6 +591,7 @@ oom4:
|
|||
*/
|
||||
lws_vhost_lock(wsi->vhost);
|
||||
lws_dll_lws_remove(&wsi->dll_active_client_conns);
|
||||
wsi->vhost->context->count_wsi_allocated--;
|
||||
lws_vhost_unlock(wsi->vhost);
|
||||
#if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2)
|
||||
lws_header_table_detach(wsi, 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue