Skip to content

Commit

Permalink
fix: clear fd mapping on sub-co end
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jul 24, 2019
1 parent 553f650 commit de11ae5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/framework/src/Co.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ public static function create(callable $callable, bool $wait = true): int

// return coroutine ID for created.
return Coroutine::create(function () use ($callable, $tid, $wait) {
$cid = Coroutine::getCid();

try {
$id = Coroutine::getCid();
// Storage fd
self::$mapping[$id] = $tid;
self::$mapping[$cid] = $tid;

if ($wait) {
Context::getWaitGroup()->add();
Expand All @@ -134,6 +135,9 @@ public static function create(callable $callable, bool $wait = true): int

Context::getWaitGroup()->done();
}

// Clean fd mapping
unset(self::$mapping[$cid]);
});
}

Expand Down

0 comments on commit de11ae5

Please sign in to comment.