public function finish($status = 0, $zombie = false)
    {
        if ($this->state === Generic::STATE_FINISHED) {
            return;
        }

        if (!$zombie) {
            $this->state = Generic::STATE_FINISHED;
        }

        if (!($r = $this->running)) {
            $this->onWakeup();
        }

        while (($cb = array_shift($this->shutdownFuncs)) !== null) {
            try {
                $cb($this);
            } catch (\Exception $e) {
                Daemon::uncaughtExceptionHandler($e);
                // @TODO: break?
            }
        }

        if (!$r) {
            $this->onSleep();
        }

        $this->event('finish');
        $this->onFinish();
        $this->cleanupEventHandlers();

        if (Daemon::$compatMode) {
            return;
        }

        ++Daemon::$process->counterGC;

        if (Daemon::$compatMode) {
            return;
        }

        if (!Daemon::$obInStack) { // preventing recursion
            ob_flush();
        }

        if ($status !== -1) {
            $appStatus = 0;
            $this->postFinishHandler(function () use ($appStatus, $status) {
                $this->upstream->endRequest($this, $appStatus, $status);
                $this->free();
            });
        } else {
            $this->free();
        }
    }
public function finish($status = 0, $zombie = false)
    {
        if ($this->state === Generic::STATE_FINISHED) {
            return;
        }

        if (!$zombie) {
            $this->state = Generic::STATE_FINISHED;
        }

        if (!($r = $this->running)) {
            $this->onWakeup();
        }

        while (($cb = array_shift($this->shutdownFuncs)) !== null) {
            try {
                $cb($this);
            } catch (\Exception $e) {
                Daemon::uncaughtExceptionHandler($e);
                // @TODO: break?
            }
        }

        if (!$r) {
            $this->onSleep();
        }

        $this->event('finish');
        $this->onFinish();
        $this->cleanupEventHandlers();

        if (Daemon::$compatMode) {
            return;
        }

        ++Daemon::$process->counterGC;

        if (Daemon::$compatMode) {
            return;
        }

        if (!Daemon::$obInStack) { // preventing recursion
            ob_flush();
        }

        if ($status !== -1) {
            $appStatus = 0;
            $this->postFinishHandler(function () use ($appStatus, $status) {
                $this->upstream->endRequest($this, $appStatus, $status);
                $this->free();
            });
        } else {
            $this->free();
        }
    }
public function finish ( $ status = 0 , $ zombie = false ) { if ( $ this -> state === Generic :: STATE_FINISHED ) { return ; } if ( ! $ zombie ) { $ this -> state = Generic :: STATE_FINISHED ; } if ( ! ( $ r = $ this -> running ) ) { $ this -> onWakeup ( ) ; } while ( ( $ cb = array_shift ( $ this -> shutdownFuncs ) ) !== null ) { try { $ cb ( $ this ) ; } catch ( \ Exception $ e ) { Daemon :: uncaughtExceptionHandler ( $ e ) ; // @TODO: break? } } if ( ! $ r ) { $ this -> onSleep ( ) ; } $ this -> event ( 'finish' ) ; $ this -> onFinish ( ) ; $ this -> cleanupEventHandlers ( ) ; if ( Daemon :: $ compatMode ) { return ; } ++ Daemon :: $ process -> counterGC ; if ( Daemon :: $ compatMode ) { return ; } if ( ! Daemon :: $ obInStack ) { // preventing recursion ob_flush ( ) ; } if ( $ status !== - 1 ) { $ appStatus = 0 ; $ this -> postFinishHandler ( function ( ) use ( $ appStatus , $ status ) { $ this -> upstream -> endRequest ( $ this , $ appStatus , $ status ) ; $ this -> free ( ) ; } ) ; } else { $ this -> free ( ) ; } }
Finish the request
@param integer Optional. Status. 0 - normal, -1 - abort, -2 - termination
@param boolean Optional. Zombie. Default is false
@return void
Finish the request