im make a socket comet chat app in php, phread, and apc modules instalaled and working no problem. problem is pthreads and apc using together see sample code..

<?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);
}
?>

see top code return error Segmentation fault (on line : apcu_store('testkey123', "keyvalue", 2400);)

im make new script see bottom test apc working..

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

how to fix this first script ? please help me !

有帮助吗?

解决方案

im found a solution.. apcu or apc engine very fast alternative php Semaphore, Shared Memory and IPC ---> SHM works fast in all conditions

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

Consider the following page for more : http://us3.php.net/manual/en/book.sem.php

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top