示例#1
0
 /**
  * Initializes the current thread process.
  *
  * @ignore
  */
 public static function run($port, $id)
 {
     if (strlen($port) != 5 || !ctype_digit($port)) {
         die;
     }
     $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
     if (FALSE === @socket_connect($sock, '127.0.0.1', $port)) {
         die;
     }
     $handle = new ThreadHandle($sock, $port, $id);
     if (!$handle->send($id) || $handle->recv(self::$init_timeout) != 'ack' || ($entrypoint = $handle->recv(self::$init_timeout)) === NULL || (self::$threadfilename = $handle->recv(self::$init_timeout)) === NULL || !$handle->send('ack')) {
         $handle->close();
         die;
     }
     call_user_func($entrypoint, $handle);
     $handle->stop();
     exit;
     // just in case all else fails
 }