/コンピュータ/blogn/ping送信の非同期化 コンピュータ/blogn/ping送信の非同期化 - A.K.I. Home

A.K.I. HomeATOM:A.K.I. Home


Top
コロンブスエッグ
SuperTagCenter
適当言語nolina
くろまじゅつしへの道
SiteDev2
MRTG
RTX1000
楽天ダウンロード


日刊放言なのか。
SuperTagCenter



Aubrey graham teen people article
article, Aubrey graham teen people article and Aubrey
Aubrey graham teen people article
2008年4月29日 16:18:59
Naked athelete
athelete
Naked athelete and Nak
2008年4月28日 09:05:51
Horny spanish flies karen
karen
Horny spanish flies karen and Horn
2008年4月27日 00:11:00
sexy
Pornstars nsked and sexy and Pornstars
Pornstars nsked and sexy
1970年1月1日 18:00:00
discount
Celebrity mercury pacific northwest cruise discount and Celebrity
Celebrity mercury pacific northwest cruise discount
1970年1月1日 18:00:00

コンピュータ / blogn / ping送信の非同期化

投稿後の待ち時間が長くなるのを防ぐために、pingを受信した後非同期でping送信を行うように修正してみます。

・まず、pingproxy.phpは受信したパラメータの1番目と2番目をbase64エンコードしてsystem関数で呼び出し、すぐに結果を返し終了する。
・pingproxy_cli.phpに実際のping送信部を移し、バックグラウンドで処理。
ということでこんなかんじ。
pingproxy.php

<?php
require_once("XML/RPC.php");
require_once("XML/RPC/Server.php");
$GLOBALS['XML_RPC_defencoding'] = "UTF-8";
function pingproxy ($params) {
	$p1 = base64_encode($params->getParam(0)->scalarval());
	$p2 = base64_encode($params->getParam(1)->scalarval());
	system("/usr/bin/php /***********/pingproxy_cli.php $p1 $p2 > /dev/null &");
	$value = new XML_RPC_Value(
	array(
		"flerror" => new XML_RPC_Value(0, "boolean"),
		"message" => new XML_RPC_Value("Thanks for the ping."),
	),"struct");
	return new XML_RPC_Response($value);
}

//RPCの実行
$s = new XML_RPC_Server(array("weblogUpdates.ping" => array("function" => "pingproxy")));
?>

pingproxy_cli.php

<?php
require_once("XML/RPC.php");
$GLOBALS['XML_RPC_defencoding'] = "UTF-8";
$logfile="/**********/pinglog.txt";
$pinglist="/**********/pinglist.txt";
function pingproxy ($params) {
	global $logfile;
	global $pinglist;
	global $XML_RPC_erruser; // import user errcode value
	$msg=new XML_RPC_Message('weblogUpdates.ping',$params);
	//ここループ
	$lines = file($pinglist);
	foreach ($lines as $line_num => $line) {
	preg_match ("/^[^\\/]+\\/\\/([^\\/]+)(\\/.*)$/", rtrim($line) ,$match);
	if($match[1]!=""){
	$client=new XML_RPC_Client($match[2],$match[1],80);
	$response=$client->send($msg,30);
	if($response!=0){
	if(!$response->faultCode()){
		file_put_contents($logfile,$match[1].":success\n",FILE_APPEND);
	}else{
		file_put_contents($logfile,$match[1].":fail\n",FILE_APPEND);
	}
	}else{
		file_put_contents($logfile,$match[1].":fail:".$client->errno.":".$client->errstring."\n",FILE_APPEND);
	}
	}
	//ここまでループ
	}
	$value = new XML_RPC_Value(
	array(
		"flerror" => new XML_RPC_Value(0, "boolean"),
		"message" => new XML_RPC_Value("Thanks for the ping."),
	),"struct");
	return new XML_RPC_Response($value);
}

file_put_contents($logfile,"---start---:".date("r")."\n",FILE_APPEND);
$value = array(
	 new XML_RPC_Value(base64_decode($argv[1]),'string'),
	 new XML_RPC_Value(base64_decode($argv[2]),'string'),
);
$r=pingproxy($value);
file_put_contents($logfile,"----end----:".date("r")."\n",FILE_APPEND);
?>

前回忘れたタイムアウトの設定を

	$response=$client->send($msg,30);

ここに入れています。30秒応答がないと次に進みます。
リストのサンプル

http://api.my.yahoo.com/RPC2
http://rpc.weblogs.com/RPC2
http://rpc.pingomatic.com/
http://rpc.reader.livedoor.com/ping
http://ping.weblogalot.com/rpc.php
http://ping.weblog.ne.jp/
http://ping.syndic8.com/xmlrpc.php
http://ping.speenee.com/xmlrpc
http://ping.maplog.jp/
http://ping.feedburner.com/

※ドメイン名だけで終るURLは必ず最後に/を付けてください。

 
TB:http://www.tetsuneko.net/aki/sitedev2/tb/27c284fc344a2c9738b9836db12d5916
(c)A.K.I. 2007