Skip to content

Commit

Permalink
Made the fiber base function robust against spurious resume calls cau…
Browse files Browse the repository at this point in the history
…sed by dangling libevent events.
  • Loading branch information
s-ludwig committed May 22, 2012
1 parent dbfef75 commit 081d673
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/vibe/core/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,13 @@ shared static this()

private void defaultFiberFunc()
{
auto fthis = Fiber.getThis();
while(true){
auto task = s_taskFuncs[Fiber.getThis()];
while( fthis !in s_taskFuncs )
s_core.yieldForEvent();

auto task = s_taskFuncs[fthis];
s_taskFuncs.remove(fthis);
try {
logTrace("entering task.");
task();
Expand All @@ -295,8 +300,7 @@ private void defaultFiberFunc()
// make the fiber available for the next task
if( s_availableFibers.length <= s_availableFibersCount )
s_availableFibers.length = 2*s_availableFibers.length;
s_availableFibers[s_availableFibersCount++] = Fiber.getThis();
s_core.yieldForEvent();
s_availableFibers[s_availableFibersCount++] = fthis;
}
}

Expand Down

0 comments on commit 081d673

Please sign in to comment.