Esempio n. 1
0
 function master_timer($tw)
 {
     if (!is_object($tw) && get_class($tw) !== 'EvTimer') {
         cy_log(CYE_ERROR, 'wrong type param called in master_timer');
         return;
     }
     //restart by luohaibin
     if (cy_i_get('bps_srv_status', CY_TYPE_SYS) == 1) {
         cy_i_set('bps_srv_status', CY_TYPE_SYS, 0);
         $this->flag = WKST_SPAWN;
         $this->worker_start();
         $this->worker_clean();
         $this->flag = WKST_RUNNING;
     }
     //force stop
     if (cy_i_get('bps_srv_status', CY_TYPE_SYS) == 2) {
         cy_i_set('bps_srv_status', CY_TYPE_SYS, 0);
         //master exit
         $this->flag = WKST_END;
         //worker force terminate
         $this->worker_clean();
         // TODO need wait.
         //$this->loop->stop();
     }
     /* Dead lock detect. */
     /*
     		$max = isset($_ENV['config']['max_lock_time']) ? $_ENV['config']['max_lock_time'] : 1;
     		$now = time();
     		foreach($this->workers as $pid => $worker)
     		{
     			if(cy_i_get('bps_srv_lock_'.$pid, CY_TYPE_SYS))
     			{
     				if($this->status['pid'] != $pid)
     				{
     					$this->status['pid']  = $pid;
     					$this->status['time'] = $now;
     					break;
     				}
     		if($now - $this->status['time'] > $max)
     				{
     					cy_log(CYE_ERROR, 'kill process '.$pid.' who had lock more than '.$max.'s');
     					cy_i_set('bps_srv_term_'.$pid, CY_TYPE_SYS, 1);
     				}
     		break;
     			}
     		}
     */
 }
Esempio n. 2
0
 function timer()
 {
     if (cy_i_get('bps_srv_term_' . $this->pid, CY_TYPE_SYS) === 1) {
         if ($this->srv) {
             fclose($this->srv);
             $this->srv = NULL;
         }
         if ($this->active_num <= 0) {
             $this->srv_shutdown();
         }
         return;
     }
     $now = $this->lp->now();
     if ($this->lock_time && $now - $this->lock_time > $this->max_lock_seconds) {
         cy_log(CYE_DEBUG, "%d waiting more than %d seconds, force next loop.", $this->pid, $this->max_lock_seconds);
         $this->next_loop_force();
         return;
     }
     /* 如果长连接一段时间没有请求,关闭一次 */
     if ($this->client && $this->last_request_time && $now - $this->last_request_time > $this->max_lock_seconds * 2) {
         cy_log(CYE_DEBUG, "%d closed, no request in a while.", $this->client);
         $this->next_loop_force();
         return;
     }
 }
Esempio n. 3
0
File: hb.php Progetto: xiaoyjy/retry
 function timer()
 {
     if (cy_i_get('bps_srv_term_' . $this->pid, CY_TYPE_SYS) === 1) {
         if ($this->srv) {
             fclose($this->srv);
             $this->srv = NULL;
         }
         if ($this->active_num <= 0) {
             $this->srv_shutdown();
         }
         return;
     }
 }