-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test and fix memcache session redundancy php8 (#87)
* Use zend_bool for ini bool settings I think that these might have uninitialized bytes when a data type larger than zend_bool is used for the ini setting, if the module globals are set from malloc? (Not 100% sure if the entire structure isn't set to 0 before being used) Related to #56 * add a redundancy test file add a redundancy test file checking multiple memcached restarts install pcntl in docker container so tests are running add also a Vagrantfile for easier dev env setup * fix the redundancy failover by having dataresult as null initially instead of empty string Co-authored-by: Tyson Andre <[email protected]> Co-authored-by: Tomas Srnka <[email protected]>
- Loading branch information
1 parent
e014963
commit c615b13
Showing
4 changed files
with
97 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
VAGRANTFILE_API_VERSION = '2' | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
config.vm.box = 'ubuntu/bionic64' | ||
|
||
config.vm.provider :virtualbox do |vb| | ||
vb.name = 'ext-memcache-dev' | ||
vb.memory = 1024 | ||
vb.cpus = 2 | ||
end | ||
|
||
config.vm.provision 'docker' | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--TEST-- | ||
redundancy test | ||
--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'; | ||
|
||
$sid = md5(rand()); | ||
|
||
ini_set('session.save_handler', 'memcache'); | ||
ini_set('memcache.session_save_path', "tcp://$host:$port,tcp://$host2:$port2"); | ||
ini_set('memcache.session_redundancy', 3); | ||
|
||
$memcache1 = test_connect1(); | ||
$memcache2 = test_connect2(); | ||
|
||
$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); | ||
} | ||
pcntl_waitpid($pid, $status); | ||
|
||
$memcache1->flush(); | ||
|
||
$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); | ||
} | ||
pcntl_waitpid($pid, $status); | ||
|
||
$memcache2->flush(); | ||
|
||
$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); | ||
} | ||
pcntl_waitpid($pid, $status); | ||
|
||
|
||
session_id($sid); | ||
session_start(); | ||
var_dump($_SESSION); | ||
|
||
?> | ||
--EXPECT-- | ||
array(1) { | ||
["counter"]=> | ||
int(3) | ||
} |