pthreads和apc一起使用时出错:分段错误

时间:2014-03-23 11:50:58

标签: php segmentation-fault pthreads apc

我在php,phread和apc模块instalaled做一个插座彗星聊天应用程序没有问题。问题是pthreads和apc一起使用看样例代码..

<?php
//use pthreads module
class Client extends Thread {
public function __construct($socket){
$this->socket = $socket;
$this->start();
}
public function run(){
$client = $this->socket;
if ($client) {
apcu_store('testkey123', "keyvalue", 2400);
$data=apcu_fetch('testkey123');
socket_write($client, $data);
socket_shutdown($client);       
socket_close($client);
}
}
}
$server = socket_create_listen(13000);
while(($client = socket_accept($server))){
$clients[]=new Client($client);
}
?>

请参阅顶部代码返回错误分段错误(在线:apcu_store(&#39; testkey123&#39;,&#34; keyvalue&#34;,2400);)

我使新脚本看到底部测试apc工作..

<?
apcu_store('testkey123', "keyvalue", 2400);
echo apcu_fetch('testkey123');
//work return keyvalue
?>

如何解决这个第一个脚本?请帮帮我!

1 个答案:

答案 0 :(得分:0)

我发现了一个解决方案.. apcu或apc引擎非常快的替代php信号量,共享内存和IPC ---&gt; SHM  在所有条件下都能快速运作

shm_attach — Creates or open a shared memory segment
shm_detach — Disconnects from shared memory segment
shm_get_var — Returns a variable from shared memory
shm_has_var — Check whether a specific entry exists
shm_put_var — Inserts or updates a variable in shared memory
shm_remove_var — Removes a variable from shared memory
shm_remove — Removes shared memory from Unix systems

请考虑以下页面了解更多信息:http://us3.php.net/manual/en/book.sem.php