<NME> iphp_MW_Worker.php
<BEF> <?php
class iphp_MW_Worker
{
	public $id = '';
	public $link = null;
	private $mw = null;
	private $name = '';
	
	function __construct($mw){
		global $argv;
		$this->name = basename($argv[0]);
		$this->mw = $mw;
	}

	function init($ip, $port){
		$this->link = new iphp_MW_Link();
		if(!$this->link->connect($ip, $port)){
			throw new Exception("could not connect to manager");
		}
		$this->link->send('role', 'worker');
		$resp = $this->link->recv();
		if(!$resp){
			throw new Exception("manager gone");
		}
		if($resp['type'] == 'ok'){
			//Logger::debug("[{$this->name}] worker[{$this->id}] started");
		}else{
			throw new Exception("bad response");
		}
	}

	function run($manager){
				break;
			}
			if($req['type'] == 'quit'){
				Logger::debug("receive quit message");
				break;
			}
			
			}
			if($req['type'] == 'quit'){
				#Logger::debug("[{$this->name}] receive quit");
				break;
			}
			
			$job = $req['data'];
			#Logger::debug("[{$this->name}] process job: " . json_encode($job));
			
			// process job...
			);
			$ret = $this->link->send('result', $result);
			if(!$ret){
				break;
			}
		}
	}
}
			$result = array(
				'id' => $job['id'],
				'time' => $job['time'],
				'error' => $error,
				'result' => $ret,
			);
			$ret = $this->link->send('result', $result);
			if(!$ret){
				Logger::debug("[{$this->name}] worker[{$this->id}] send result error.");
				break;
			}
		}
		//Logger::debug("[{$this->name}] worker[{$this->id}] quit");
	}
}

<MSG> update

<DFF> @@ -33,7 +33,6 @@ class iphp_MW_Worker
 				break;
 			}
 			if($req['type'] == 'quit'){
-				Logger::debug("receive quit message");
 				break;
 			}
 			
@@ -50,8 +49,10 @@ class iphp_MW_Worker
 			);
 			$ret = $this->link->send('result', $result);
 			if(!$ret){
+				Logger::debug("worker[{$this->id}] send result error.");
 				break;
 			}
 		}
+		Logger::debug("worker[{$this->id}] quit");
 	}
 }

update