[Libwebsockets] SSL http client stalls on the last chunk.

Zevv libws at zevv.nl
Wed Jan 22 15:51:57 CET 2020


Quoting Andy Green (2020-01-22 14:00:30)

> before having a nonzero poll wait, both pt lists get a chance in 
> lws_service_flag_pending() in lib/core-net/service.c to force POLLIN for 
> the related wsis that are on the lists.

What about:


diff --git a/src/lib/third_party/libwebsockets/lib/event-libs/libev/libev.c b/src/lib/third_party/libwebsockets/lib/event-libs/libev/libev.c
index e3ceccf..244be1e 100644
--- a/src/lib/third_party/libwebsockets/lib/event-libs/libev/libev.c
+++ b/src/lib/third_party/libwebsockets/lib/event-libs/libev/libev.c
@@ -46,6 +46,7 @@ lws_ev_idle_cb(struct ev_loop *loop, struct ev_idle *handle, int revents)
        struct lws_context_per_thread *pt = lws_container_of(handle,
                                        struct lws_context_per_thread, ev.idle);
        lws_usec_t us;
+       int reschedule = 0;
 
        lws_service_do_ripe_rxflow(pt);
 
@@ -54,7 +55,7 @@ lws_ev_idle_cb(struct ev_loop *loop, struct ev_idle *handle, int revents)
         */
        if (!lws_service_adjust_timeout(pt->context, 1, pt->tid))
                /* -1 timeout means just do forced service */
-               _lws_plat_service_forced_tsi(pt->context, pt->tid);
+               reschedule = _lws_plat_service_forced_tsi(pt->context, pt->tid);
 
        /* account for hrtimer */
 
@@ -67,7 +68,8 @@ lws_ev_idle_cb(struct ev_loop *loop, struct ev_idle *handle, int revents)
        lws_pt_unlock(pt);
 
        /* there is nobody who needs service forcing, shut down idle */
-       ev_idle_stop(loop, handle);
+       if(!reschedule)
+               ev_idle_stop(loop, handle);
 }
 
 static void
diff --git a/src/lib/third_party/libwebsockets/lib/plat/unix/unix-service.c b/src/lib/third_party/libwebsockets/lib/plat/unix/unix-service.c
index c1b9934..23f236a 100644
--- a/src/lib/third_party/libwebsockets/lib/plat/unix/unix-service.c
+++ b/src/lib/third_party/libwebsockets/lib/plat/unix/unix-service.c
@@ -37,9 +37,9 @@ int
 _lws_plat_service_forced_tsi(struct lws_context *context, int tsi)
 {
        struct lws_context_per_thread *pt = &context->pt[tsi];
-       int m, n;
+       int m, n, r;
 
-       lws_service_flag_pending(context, tsi);
+       r = lws_service_flag_pending(context, tsi);
 
        /* any socket with events to service? */
        for (n = 0; n < (int)pt->fds_count; n++) {
@@ -59,7 +59,7 @@ _lws_plat_service_forced_tsi(struct lws_context *context, int tsi)
 
        lws_service_do_ripe_rxflow(pt);
 
-       return 0;
+       return r;
 }
 
 #define LWS_POLL_WAIT_LIMIT 2000000000


--
:wq
^X^Cy^K^X^C^C^C^C


More information about the Libwebsockets mailing list