diff --git a/lib/core/context.c b/lib/core/context.c index 5557b814fe02f37cd43ade047f2988b9edd2f5c7..f5dd745c8a82f21ef1ca83c3bc8246b83216d52e 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -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; } } diff --git a/lib/core/service.c b/lib/core/service.c index 2f6656bcf6d1aa12d265f31567b7e33fb8de01a2..cc7faa1cda57d082abf02b010fceb8bd14aa9f16 100644 --- a/lib/core/service.c +++ b/lib/core/service.c @@ -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); diff --git a/lib/plat/unix/unix-service.c b/lib/plat/unix/unix-service.c index 00c1fc926edda5b57b9bcbc6e9ae75d89895335d..e61ef59959cb25ff0e8ce2b4fcaa7d48abe74f86 100644 --- a/lib/plat/unix/unix-service.c +++ b/lib/plat/unix/unix-service.c @@ -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--; diff --git a/lib/roles/http/client/client-handshake.c b/lib/roles/http/client/client-handshake.c index bda434ff6eaff2b61bb492bc4572c1662f7d2f25..f64188bb7703cee063454dccf933323132b81d09 100644 --- a/lib/roles/http/client/client-handshake.c +++ b/lib/roles/http/client/client-handshake.c @@ -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);