예제 #1
0
파일: main.php 프로젝트: xiaoyjy/retry
 function worker_onexit($pw, $revents)
 {
     cy_log(CYE_DEBUG, "in worker_onexit");
     if (!is_object($pw) && get_class($pw) !== 'EvChild') {
         cy_log(CYE_ERROR, 'error type param, in worker_onexit');
         return;
     }
     $pw->stop();
     $pid = $pw->rpid;
     pcntl_waitpid($pid, $status, WNOHANG);
     $wiexit = pcntl_wifexited($status);
     $status = $pw->rstatus;
     $worker = $this->workers[$pid];
     $key = $worker['key'];
     unset($this->workers[$pid]);
     if ($this->flag === WKST_RUNNING || $this->flag === WKST_SPAWN) {
         $this->worker_fork($key);
     } elseif ($this->flag === WKST_END) {
         $now_num = cy_i_get('bps_srv_' . $key . '_num', CY_TYPE_SYS);
         if ($now_num === 0) {
             $this->loop->stop();
         }
     }
     cy_i_dec("bps_srv_" . $key . "_num", CY_TYPE_SYS, 1);
     cy_i_del("bps_srv_lock_" . $pid, CY_TYPE_SYS);
     if ($wiexit) {
         return;
     }
     /* 子进程没有正常退出, 加保护性代码,防止进程因为被kill而死锁 */
     if ($flag === WKST_QUITING) {
         cy_log(CYE_TRACE, $pid . ' exit, receive master cmd.');
     } else {
         cy_log(CYE_ERROR, $pid . ' is not normal exited.');
     }
     // TCP Server Only
     $stat_lock = cy_i_get($stat_name, CY_TYPE_SYS);
     if ($stat_lock) {
         cy_unlock('bps_' . $key . '_lock');
     }
     usleep(100000);
 }
예제 #2
0
파일: tcp.php 프로젝트: xiaoyjy/retry
 function srv_finish()
 {
     $error = error_get_last();
     if ($error['type'] === E_ERROR) {
         cy_log(CYE_ERROR, 'cy_srv_finish fatal errors found %s', json_encode($error));
         // 防止因为fatal error导致死锁
         /*
           if($this->unlock())
           {
           cy_log(CYE_ERROR, 'cy_srv_finish unlock the process, fatal error happen in process.');
           }
         */
     }
     cy_i_del('bps_srv_term_' . $this->pid, CY_TYPE_SYS);
     cy_i_del($this->stat_name, CY_TYPE_SYS);
 }
예제 #3
0
파일: hb.php 프로젝트: xiaoyjy/retry
 function srv_finish()
 {
     $error = error_get_last();
     if ($error['type'] === E_ERROR) {
         cy_log(CYE_ERROR, 'cy_srv_finish fatal errors found %s', json_encode($error));
     }
     cy_i_del('bps_srv_term_' . $this->pid, CY_TYPE_SYS);
 }