소스 검색

Update StreamSelectLoop.php

memory leak
2276225819 8 년 전
부모
커밋
76fb849dd7
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      Events/React/StreamSelectLoop.php

+ 4 - 2
Events/React/StreamSelectLoop.php

@@ -56,10 +56,12 @@ class StreamSelectLoop extends \React\EventLoop\StreamSelectLoop
                 $this->_timerIdMap[++$this->_timerIdIndex] = $timer_obj;
                 return $this->_timerIdIndex;
             case EventInterface::EV_TIMER_ONCE:
-                $timer_obj = $this->addTimer($fd, function() use ($func, $args) {
+                $index = ++$this->_timerIdIndex;
+                $timer_obj = $this->addTimer($fd, function() use ($func, $args, $index) {
+                    $this->del($index,EventInterface::EV_TIMER_ONCE);
                     call_user_func_array($func, $args);
                 });
-                $this->_timerIdMap[++$this->_timerIdIndex] = $timer_obj;
+                $this->_timerIdMap[$index] = $timer_obj;
                 return $this->_timerIdIndex;
         }
         return false;