Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ugly hack to avoid loop starvation

  • Loading branch information...
commit 48f827ff7966b96b168c6c38e675ef64a126e06b 1 parent 39aac4a
@piscisaureus piscisaureus authored
Showing with 7 additions and 1 deletion.
  1. +4 −1 src/win/core.c
  2. +3 −0  src/win/req.c
View
5 src/win/core.c
@@ -156,6 +156,7 @@ static void uv_poll_ex(int block) {
#define UV_LOOP(poll) \
+ int mb; \
while (LOOP->refs > 0) { \
uv_update_time(); \
uv_process_timers(); \
@@ -168,9 +169,11 @@ static void uv_poll_ex(int block) {
/* Completely flush all pending reqs and endgames. */ \
/* We do even when we just called the idle callbacks because those may */ \
/* have closed handles or started requests that short-circuited. */ \
+ mb = 100; \
while (LOOP->pending_reqs_tail || LOOP->endgame_handles) { \
uv_process_endgames(); \
uv_process_reqs(); \
+ if (--mb <= 0) break; \
} \
\
if (LOOP->refs <= 0) { \
@@ -179,7 +182,7 @@ static void uv_poll_ex(int block) {
\
uv_prepare_invoke(); \
\
- poll(LOOP->idle_handles == NULL && LOOP->refs > 0); \
+ poll(LOOP->idle_handles == NULL && LOOP->pending_reqs_tail == NULL && LOOP->refs > 0); \
\
uv_check_invoke(); \
}
View
3  src/win/req.c
@@ -91,6 +91,7 @@ static uv_req_t* uv_remove_pending_req() {
void uv_process_reqs() {
uv_req_t* req;
+ int mb = 100;
while (req = uv_remove_pending_req()) {
switch (req->type) {
@@ -153,5 +154,7 @@ void uv_process_reqs() {
default:
assert(0);
}
+
+ if (mb-- <= 0) break;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.