port forced service checking from libuv
authorAndy Green <andy@warmcat.com>
Tue, 4 Oct 2016 00:39:14 +0000 (08:39 +0800)
committerAndy Green <andy@warmcat.com>
Tue, 4 Oct 2016 00:39:14 +0000 (08:39 +0800)
Related to second part of

https://github.com/warmcat/libwebsockets/issues/638

lib/libuv.c
lib/lws-plat-unix.c

index c12353b..78c2374 100644 (file)
@@ -52,7 +52,7 @@ lws_uv_idle(uv_idle_t *handle
                if (!lws_service_adjust_timeout(pt->context, 1, pt->tid))
                        /* yes... come back again later */
                        lwsl_debug("%s: done again\n", __func__);
-                       return;
+               return;
        }
 
        /* there is nobody who needs service forcing, shut down idle */
index 1dd901e..23ff642 100644 (file)
@@ -131,6 +131,19 @@ lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
        context->service_tid = context->service_tid_detected;
 
        timeout_ms = lws_service_adjust_timeout(context, timeout_ms, tsi);
+       /*
+        * is there anybody with pending stuff that needs service forcing?
+        */
+       if (!timeout_ms) {
+               /* -1 timeout means just do forced service */
+               lws_plat_service_tsi(context, -1, pt->tid);
+               /* still somebody left who wants forced service? */
+               if (!lws_service_adjust_timeout(context, 1, pt->tid)) {
+                       /* yes... come back again later */
+                       lwsl_debug("%s: done again\n", __func__);
+               }
+               return 0;
+       }
 
        n = poll(pt->fds, pt->fds_count, timeout_ms);