1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
--TEST--
session locking
--SKIPIF--
<?php include 'connect.inc'; if (!MEMCACHE_HAVE_SESSION) print 'skip not compiled with session support'; else if (!function_exists('pcntl_fork')) print 'skip not compiled with pcntl_fork() support'; ?>
--FILE--
<?php
include 'connect.inc';
$childcount = 50;
$sid = md5(rand());
ini_set('session.save_handler', 'memcache');
ini_set('session.save_path', "tcp://$host:$port?udp_port=$udpPort;tcp://$host2:$host2?udp_port=$udpPort2;tcp://$nonExistingHost:$nonExistingPort");
ini_set('memcache.session_redundancy', 10);
$pids = array();
for ($i = 0; $i < $childcount; $i++) {
$pid = pcntl_fork();
if (!$pid) {
// In child process
session_id($sid);
session_start();
if (!isset($_SESSION['counter']))
$_SESSION['counter'] = 0;
$_SESSION['counter'] += 1;
session_write_close();
exit(0);
}
else {
// In parent process
$pids[] = $pid;
}
}
// Wait for children to exit
foreach ($pids as $pid) {
$status = 0;
pcntl_waitpid($pid, $status);
if ($status != 0) {
//print "Child exited abnormally ($status)\n";
}
}
session_id($sid);
session_start();
var_dump($_SESSION);
?>
--EXPECT--
array(1) {
["counter"]=>
int(50)
}
|