├── tests ├── data │ └── abc.data ├── get_included_files_inc1.inc ├── apc_bin_002-2.inc ├── get_included_files_inc2.inc ├── get_included_files_inc3.inc ├── skipif.inc ├── 023-2.inc ├── php_5_3_ns.inc ├── apc_011.phpt ├── apc53_005.phpt ├── apc53_003.phpt ├── apc_bin_001.phpt ├── apc_002.phpt ├── apc_001.phpt ├── apc53_001.phpt ├── apc53_004.phpt ├── iterator_007.phpt ├── iterator_002.phpt ├── iterator_004.phpt ├── apc53_002.phpt ├── apc_004.phpt ├── bug62802.phpt ├── apc_005.phpt ├── apc54_003.phpt ├── bug62765.phpt ├── apc_008.phpt ├── apc54_012.phpt ├── bug38779.phpt ├── bug62825.phpt ├── apc54_007.phpt ├── apc54_010.phpt ├── apc_007.phpt ├── bug62757.phpt ├── apc54_001.phpt ├── apc_006.phpt ├── apc54_error_010_2.phpt ├── apc_bin_002.phpt ├── apc54_011.phpt ├── apc_bin_002-1.inc ├── apc_010.phpt ├── get_included_files.phpt ├── apc54_009.phpt ├── apc54_014.phpt ├── bug52144_classes.phpt ├── apc_003.phpt ├── iterator_001.phpt ├── apc_003b.phpt ├── apc54_021.phpt ├── iterator_003.phpt ├── iterator_005.phpt ├── apc_012.phpt ├── apc54_016.phpt ├── apc_009.phpt ├── bug52144_functions.phpt ├── apc54_013.phpt ├── apc54_002.phpt ├── apc54_bug62699.phpt ├── bug61398_2.phpt ├── apc54_019.phpt ├── apc54_017.phpt ├── apc54_004.phpt ├── server_test.inc ├── bug61398.phpt ├── apc54_015.phpt └── apc54_018.phpt ├── NOTICE ├── README.md ├── Makefile.frag ├── TODO ├── apc_debug.h ├── apc_spin.h ├── apc_pthreadmutex.h ├── config.w32 ├── apc_pthreadrwlock.h ├── apc_signal.h ├── apc_string.h ├── apc_mmap.h ├── apc_spin.c ├── apc_fcntl.h ├── php_apc.h ├── apc_shm.h ├── apc_sem.h ├── apc_bin.h ├── apc_stack.h ├── apc_debug.c ├── apc_windows_srwlock_kernel.h ├── apc_php.h ├── LICENSE ├── apc_main.h ├── apc_serializer.h ├── apc_stack.c ├── apc_php_pcre.h ├── apc_sma.h ├── apc_pool.h ├── apc_shm.c ├── apc_fcntl.c ├── apc_fcntl_win32.c ├── apc_pthreadmutex.c ├── apc_pthreadrwlock.c ├── apc_iterator.h ├── apc.h └── apc_windows_srwlock_kernel.c /tests/data/abc.data: -------------------------------------------------------------------------------- 1 | s:3:"123" 2 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/laruence/php-apc/HEAD/NOTICE -------------------------------------------------------------------------------- /tests/get_included_files_inc1.inc: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /tests/apc_bin_002-2.inc: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /tests/get_included_files_inc2.inc: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /tests/get_included_files_inc3.inc: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /tests/skipif.inc: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /tests/023-2.inc: -------------------------------------------------------------------------------- 1 | 2 | This is Finish.phtml. This file is supposed to be included 3 | from regression_test.phtml. This is normal HTML. 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | php-apc 2 | ======= 3 | 4 | Alternative PHP Cache 5 | 6 | APC is a free, open, and robust framework for caching and optimizing PHP intermediate code. 7 | 8 | This is not the offical repository of APC, this is just the dev repository of myself. 9 | -------------------------------------------------------------------------------- /Makefile.frag: -------------------------------------------------------------------------------- 1 | clean-coverage: 2 | @rm -fr .coverage coverage 3 | 4 | coverage: test clean-coverage 5 | @echo "Generating $@" 6 | @$(LCOV) --directory . --capture --base-directory=. --output-file .coverage 7 | @$(GENHTML) --legend --output-directory coverage/ --title "pecl/apc code coverage" .coverage 8 | 9 | -------------------------------------------------------------------------------- /tests/php_5_3_ns.inc: -------------------------------------------------------------------------------- 1 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | 21 | ===DONE=== 22 | 23 | --EXPECTF-- 24 | string(3) "bar" 25 | string(3) "bar" 26 | ===DONE=== 27 | -------------------------------------------------------------------------------- /tests/apc53_005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: goto (php 5.3) 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | apc.enabled=1 12 | apc.enable_cli=1 13 | apc.file_update_protection=0 14 | --FILE-- 15 | 25 | ===DONE=== 26 | 27 | --EXPECTF-- 28 | 1 29 | 2 30 | 4 31 | 5 32 | 7 33 | 8 34 | 10 35 | ===DONE=== 36 | -------------------------------------------------------------------------------- /tests/apc53_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: anonymous functions (php 5.3) 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | apc.enabled=1 12 | apc.enable_cli=1 13 | apc.file_update_protection=0 14 | --FILE-- 15 | 26 | ===DONE=== 27 | 28 | --EXPECTF-- 29 | Hello World 30 | Hello PHP 31 | ===DONE=== 32 | -------------------------------------------------------------------------------- /tests/apc_bin_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: bindump user cache 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | --FILE-- 9 | 19 | ===DONE=== 20 | 21 | --EXPECTF-- 22 | bool(false) 23 | string(9) "testvalue" 24 | ===DONE=== 25 | -------------------------------------------------------------------------------- /tests/apc_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_store/fetch with objects 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | a = true; 20 | var_dump($bar); 21 | 22 | ?> 23 | ===DONE=== 24 | 25 | --EXPECTF-- 26 | object(foo)#%d (0) { 27 | } 28 | object(foo)#%d (0) { 29 | } 30 | object(foo)#%d (1) { 31 | ["a"]=> 32 | bool(true) 33 | } 34 | ===DONE=== 35 | -------------------------------------------------------------------------------- /tests/apc_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_store/fetch with strings 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | 25 | ===DONE=== 26 | 27 | --EXPECTF-- 28 | string(11) "hello world" 29 | string(11) "hello world" 30 | string(4) "nice" 31 | string(11) "hello world" 32 | ===DONE=== 33 | -------------------------------------------------------------------------------- /tests/apc53_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: classes with namespaces (php 5.3) 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | apc.enabled=1 12 | apc.enable_cli=1 13 | apc.file_update_protection=0 14 | --FILE-- 15 | 22 | ===DONE=== 23 | 24 | --EXPECTF-- 25 | object(Foo\Bar\Baz)#1 (3) { 26 | ["i"]=> 27 | int(1) 28 | ["f":protected]=> 29 | float(3.14) 30 | ["s":"Foo\Bar\Baz":private]=> 31 | string(11) "hello world" 32 | } 33 | ===DONE=== 34 | -------------------------------------------------------------------------------- /tests/apc53_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: closures (php 5.3) 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | apc.enabled=1 12 | apc.enable_cli=1 13 | apc.file_update_protection=0 14 | --FILE-- 15 | 28 | ===DONE=== 29 | 30 | --EXPECTF-- 31 | double of 9 is 18 32 | triple of 4 is 12 33 | ===DONE=== 34 | -------------------------------------------------------------------------------- /tests/iterator_007.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: APCIterator Overwriting the ctor 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | --FILE-- 9 | rewind(), 16 | $obj->current(), 17 | $obj->key(), 18 | $obj->next(), 19 | $obj->valid(), 20 | $obj->getTotalHits(), 21 | $obj->getTotalSize(), 22 | $obj->getTotalCount(), 23 | apc_delete($obj) 24 | ); 25 | ?> 26 | --EXPECTF-- 27 | bool(false) 28 | bool(false) 29 | bool(false) 30 | bool(false) 31 | bool(false) 32 | bool(false) 33 | bool(false) 34 | bool(false) 35 | bool(false) 36 | 37 | -------------------------------------------------------------------------------- /tests/iterator_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: APCIterator regex 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | $value) { 17 | $vals[$key] = $value['key']; 18 | } 19 | ksort($vals); 20 | var_dump($vals); 21 | 22 | ?> 23 | ===DONE=== 24 | 25 | --EXPECT-- 26 | array(4) { 27 | ["key10"]=> 28 | string(5) "key10" 29 | ["key20"]=> 30 | string(5) "key20" 31 | ["key30"]=> 32 | string(5) "key30" 33 | ["key40"]=> 34 | string(5) "key40" 35 | } 36 | ===DONE=== 37 | -------------------------------------------------------------------------------- /tests/iterator_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: APCIterator regex & chunk size & list 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | $value) { 17 | $vals[$key] = $value['key']; 18 | } 19 | ksort($vals); 20 | var_dump($vals); 21 | 22 | ?> 23 | ===DONE=== 24 | 25 | --EXPECT-- 26 | array(4) { 27 | ["key10"]=> 28 | string(5) "key10" 29 | ["key20"]=> 30 | string(5) "key20" 31 | ["key30"]=> 32 | string(5) "key30" 33 | ["key40"]=> 34 | string(5) "key40" 35 | } 36 | ===DONE=== 37 | -------------------------------------------------------------------------------- /tests/apc53_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: global spaces (php 5.3) 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | apc.enabled=1 12 | apc.enable_cli=1 13 | apc.file_update_protection=0 14 | --FILE-- 15 | foo(); 21 | var_dump(Foo\Bar\sort()); 22 | ?> 23 | ===DONE=== 24 | 25 | --EXPECTF-- 26 | array(4) { 27 | [0]=> 28 | int(1) 29 | [1]=> 30 | int(2) 31 | [2]=> 32 | int(3) 33 | [3]=> 34 | int(4) 35 | } 36 | array(4) { 37 | [0]=> 38 | int(1) 39 | [1]=> 40 | int(2) 41 | [2]=> 42 | int(3) 43 | [3]=> 44 | int(4) 45 | } 46 | string(8) "IT WORKS" 47 | ===DONE=== 48 | -------------------------------------------------------------------------------- /tests/apc_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_store/fetch with bools 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | 28 | ===DONE=== 29 | 30 | --EXPECTF-- 31 | bool(false) 32 | bool(false) 33 | bool(false) 34 | bool(true) 35 | bool(false) 36 | bool(false) 37 | bool(false) 38 | ===DONE=== 39 | -------------------------------------------------------------------------------- /tests/bug62802.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #62802 (Crash when use apc_bin_dump/load) 3 | --SKIPIF-- 4 | 30 | --CLEAN-- 31 | 34 | --EXPECT-- 35 | string(3) "uuu" 36 | -------------------------------------------------------------------------------- /tests/apc_005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_store/fetch with arrays of objects 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | 23 | ===DONE=== 24 | 25 | --EXPECTF-- 26 | array(2) { 27 | [0]=> 28 | object(stdClass)#1 (0) { 29 | } 30 | [1]=> 31 | object(stdClass)#2 (0) { 32 | } 33 | } 34 | array(2) { 35 | [0]=> 36 | object(stdClass)#1 (0) { 37 | } 38 | [1]=> 39 | object(stdClass)#2 (0) { 40 | } 41 | } 42 | array(2) { 43 | [0]=> 44 | object(stdClass)#3 (0) { 45 | } 46 | [1]=> 47 | object(stdClass)#4 (0) { 48 | } 49 | } 50 | ===DONE=== 51 | -------------------------------------------------------------------------------- /tests/apc54_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #62190 Couldn't fetch DOMProcessingInstruction with APC and native obj (php 5.4 nts) 3 | --SKIPIF-- 4 | loadHTML(''); 16 | echo "{\$node->firstChild->nextSibling->nodeType}\n"; 17 | FL; 18 | 19 | $args = array( 20 | 'apc.enabled=1', 21 | 'apc.enable_cli=1', 22 | 'apc.stat=0', 23 | ); 24 | 25 | server_start($file, $args); 26 | 27 | for ($i = 0; $i < 10; $i++) { 28 | run_test_simple(); 29 | } 30 | echo 'done'; 31 | 32 | 33 | --EXPECT-- 34 | 7 35 | 7 36 | 7 37 | 7 38 | 7 39 | 7 40 | 7 41 | 7 42 | 7 43 | 7 44 | 7 45 | 7 46 | 7 47 | 7 48 | 7 49 | 7 50 | 7 51 | 7 52 | 7 53 | 7 54 | 7 55 | 7 56 | 7 57 | 7 58 | 7 59 | 7 60 | 7 61 | 7 62 | 7 63 | 7 64 | done 65 | -------------------------------------------------------------------------------- /tests/bug62765.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #62765 (apc_bin_dumpfile report Fatal error when there is "goto" in function) 3 | --INI-- 4 | apc.enabled=1 5 | apc.enable_cli=1 6 | apc.stat=0 7 | apc.cache_by_default=1 8 | apc.filters= 9 | report_memleaks=0 10 | --FILE-- 11 | 35 | --CLEAN-- 36 | 40 | --EXPECT-- 41 | 22 42 | okey 43 | -------------------------------------------------------------------------------- /tests/apc_008.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_cas test 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | 24 | ===DONE=== 25 | 26 | --EXPECTF-- 27 | $foobar = 2 28 | $foobar == 1 ? 2 : 1 = fail 29 | $foobar == 2 ? 1 : 2 = ok 30 | $foobar = 1 31 | $f__bar == 1 ? 2 : 1 = fail 32 | $perfection == 2 ? 1 : 2 = epic fail 33 | $foobar = 1 34 | ===DONE=== 35 | -------------------------------------------------------------------------------- /tests/apc54_012.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #61164 Crash with $_SERVER and ?: operator (php 5.4) 3 | --SKIPIF-- 4 | 34 | --EXPECT-- 35 | hello 36 | hello 37 | hello 38 | hello 39 | hello 40 | hello 41 | hello 42 | hello 43 | hello 44 | hello 45 | hello 46 | hello 47 | hello 48 | hello 49 | hello 50 | hello 51 | hello 52 | hello 53 | hello 54 | hello 55 | hello 56 | hello 57 | hello 58 | hello 59 | hello 60 | hello 61 | hello 62 | hello 63 | hello 64 | hello 65 | done 66 | -------------------------------------------------------------------------------- /tests/bug62825.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #62825 (php carshed OR return PHP Fatal error when used apc_bin_dump after apc_store) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | report_memleaks=0 9 | --FILE-- 10 | array())); 13 | apc_store('k3', array('foo' => new StdClass())); 14 | $obj = new StdClass(); 15 | $obj->name = array('foo'); 16 | apc_store('k4', $obj); 17 | apc_store('k5', NULL); 18 | apc_store('k6', 0.5); 19 | apc_store('k7', 123456); 20 | $dump = apc_bin_dump(array(), NULL); 21 | apc_clear_cache(); 22 | var_dump(apc_fetch('testkey')); 23 | apc_bin_load($dump, APC_BIN_VERIFY_MD5 | APC_BIN_VERIFY_CRC32); 24 | foreach(range(1, 7) as $i) { 25 | var_dump(apc_fetch("k" . $i)); 26 | } 27 | ?> 28 | --EXPECTF-- 29 | bool(false) 30 | string(9) "testvalue" 31 | array(1) { 32 | ["foo"]=> 33 | array(0) { 34 | } 35 | } 36 | array(1) { 37 | ["foo"]=> 38 | object(stdClass)#%d (0) { 39 | } 40 | } 41 | object(stdClass)#%d (1) { 42 | ["name"]=> 43 | array(1) { 44 | [0]=> 45 | string(3) "foo" 46 | } 47 | } 48 | NULL 49 | float(0.5) 50 | int(123456) 51 | -------------------------------------------------------------------------------- /tests/apc54_007.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: bug #62302 apc.include_once_override=1 made everything crash 3 | --SKIPIF-- 4 | bark(); 26 | FL; 27 | 28 | $args = array( 29 | 'apc.enabled=1', 30 | 'apc.enable_cli=1', 31 | ); 32 | 33 | server_start($file, $args); 34 | 35 | for ($i = 0; $i < 10; $i++) { 36 | run_test_simple(); 37 | } 38 | echo 'done'; 39 | 40 | --EXPECT-- 41 | woof! 42 | woof! 43 | woof! 44 | woof! 45 | woof! 46 | woof! 47 | woof! 48 | woof! 49 | woof! 50 | woof! 51 | woof! 52 | woof! 53 | woof! 54 | woof! 55 | woof! 56 | woof! 57 | woof! 58 | woof! 59 | woof! 60 | woof! 61 | woof! 62 | woof! 63 | woof! 64 | woof! 65 | woof! 66 | woof! 67 | woof! 68 | woof! 69 | woof! 70 | woof! 71 | done 72 | -------------------------------------------------------------------------------- /tests/apc_007.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_inc/apc_dec test 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | 32 | ===DONE=== 33 | 34 | --EXPECTF-- 35 | $foobar = 2 36 | $foobar += 1 = 3 37 | $foobar += 10 = 13 38 | $foobar -= 1 = 12 39 | $foobar -= 10 = 2 40 | $f__bar += 1 = fail 41 | $perfection -= 1 = epic fail 42 | $foobar += 1 = 3 43 | pass by ref success 1 44 | $foobar -= 1 = 2 45 | pass by ref success 1 46 | ===DONE=== 47 | -------------------------------------------------------------------------------- /tests/bug62757.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #62757 (php-fpm carshed when used apc_bin_dumpfile with apc.serializer) 3 | --INI-- 4 | apc.enabled=1 5 | apc.enable_cli=1 6 | apc.stat=0 7 | apc.cache_by_default=1 8 | apc.serializer=php 9 | report_memleaks=0 10 | --FILE-- 11 | array() ); 21 | protected $str = "constant string"; 22 | public function test() { 23 | var_dump($this->str); 24 | return $this->arr; 25 | } 26 | } 27 | '; 28 | file_put_contents($filename, $file_contents); 29 | apc_compile_file($filename); 30 | apc_bin_dumpfile(array($filename), null, $bin_filename); 31 | apc_clear_cache(); 32 | apc_bin_loadfile($bin_filename); 33 | include $filename; 34 | 35 | var_dump(test()); 36 | $lib = new ApiLib(); 37 | var_dump($lib->test()); 38 | echo "okey\n"; 39 | ?> 40 | --CLEAN-- 41 | 45 | --EXPECT-- 46 | array(0) { 47 | } 48 | string(15) "constant string" 49 | array(1) { 50 | ["abcd"]=> 51 | array(0) { 52 | } 53 | } 54 | okey 55 | -------------------------------------------------------------------------------- /tests/apc54_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: bug #62398 (php 5.4) 3 | --SKIPIF-- 4 | = 5.4'); 8 | } 9 | --FILE-- 10 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | apc.serializer=default 10 | report_memleaks=0 11 | --FILE-- 12 | 34 | ===DONE=== 35 | 36 | --EXPECTF-- 37 | array(9) refcount(2){ 38 | [0]=> 39 | string(1) "a" refcount(1) 40 | [1]=> 41 | &array(1) refcount(2){ 42 | [0]=> 43 | string(1) "c" refcount(1) 44 | } 45 | [2]=> 46 | &array(1) refcount(2){ 47 | [0]=> 48 | string(1) "c" refcount(1) 49 | } 50 | [3]=> 51 | &string(1) "d" refcount(3) 52 | [4]=> 53 | &string(1) "d" refcount(3) 54 | [5]=> 55 | &string(1) "d" refcount(3) 56 | [6]=> 57 | string(1) "e" refcount(2) 58 | [7]=> 59 | string(1) "e" refcount(2) 60 | [8]=> 61 | &array(2) refcount(2){ 62 | [0]=> 63 | string(1) "f" refcount(1) 64 | [1]=> 65 | &array(2) refcount(2){ 66 | [0]=> 67 | string(1) "f" refcount(1) 68 | [1]=> 69 | *RECURSION* 70 | } 71 | } 72 | } 73 | ===DONE=== 74 | -------------------------------------------------------------------------------- /tests/apc54_error_010_2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Exclude trait method 3 | --SKIPIF-- 4 | test()); 31 | FL; 32 | 33 | $args = array( 34 | 'apc.enabled=1', 35 | 'apc.cache_by_default=1', 36 | 'apc.enable_cli=1', 37 | 'apc.shm_segments=1', 38 | 'apc.optimization=0', 39 | 'apc.ttl=0', 40 | 'apc.user_ttl=0', 41 | 'apc.num_files_hint=4096', 42 | 'apc.canonicalize=0', 43 | 'apc.write_lock=1', 44 | ); 45 | 46 | server_start($file, $args); 47 | 48 | for ($i = 0; $i < 10; $i++) { 49 | run_test_simple(); 50 | } 51 | echo 'done'; 52 | --EXPECTF-- 53 | int(2) 54 | int(2) 55 | int(2) 56 | int(2) 57 | int(2) 58 | int(2) 59 | int(2) 60 | int(2) 61 | int(2) 62 | int(2) 63 | int(2) 64 | int(2) 65 | int(2) 66 | int(2) 67 | int(2) 68 | int(2) 69 | int(2) 70 | int(2) 71 | int(2) 72 | int(2) 73 | int(2) 74 | int(2) 75 | int(2) 76 | int(2) 77 | int(2) 78 | int(2) 79 | int(2) 80 | int(2) 81 | int(2) 82 | int(2) 83 | done 84 | -------------------------------------------------------------------------------- /tests/apc_bin_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: bindump file cache part 1 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.stat=0 9 | apc.cache_by_default=1 10 | apc.filters= 11 | report_memleaks = Off 12 | --FILE-- 13 | 32 | ===DONE=== 33 | 34 | --EXPECTF-- 35 | apc bindump 002 test 36 | 37 | global scope execution: Success 38 | 39 | function execution: Success 40 | 41 | class static method: Success 42 | class dynamic method: Success 43 | class static property: Success 44 | class dynamic property: Success 45 | class constant: Success 46 | 47 | inherited class static method: Success 48 | inherited class dynamic method: Success 49 | inherited class static property: Success 50 | inherited class dynamic property: Success 51 | inherited class constant: Success 52 | 53 | ===DONE=== 54 | -------------------------------------------------------------------------------- /tests/apc54_011.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #61219 method not found on 2nd request (php 5.4) 3 | --SKIPIF-- 4 | testme(\$p); 21 | } 22 | 23 | function testme(\$p) 24 | { 25 | echo "testme \$p\n"; 26 | } 27 | } 28 | 29 | \$h = new hello(\$there); 30 | FL; 31 | 32 | $args = array( 33 | 'apc.enabled=1', 34 | 'apc.cache_by_default=1', 35 | 'apc.enable_cli=1', 36 | 'apc.slam_defense=0', 37 | 'apc.write_lock=1', 38 | ); 39 | 40 | server_start($file, $args); 41 | 42 | for ($i = 0; $i < 10; $i++) { 43 | run_test_simple(); 44 | } 45 | echo 'done'; 46 | --EXPECT-- 47 | testme world 48 | testme world 49 | testme world 50 | testme world 51 | testme world 52 | testme world 53 | testme world 54 | testme world 55 | testme world 56 | testme world 57 | testme world 58 | testme world 59 | testme world 60 | testme world 61 | testme world 62 | testme world 63 | testme world 64 | testme world 65 | testme world 66 | testme world 67 | testme world 68 | testme world 69 | testme world 70 | testme world 71 | testme world 72 | testme world 73 | testme world 74 | testme world 75 | testme world 76 | testme world 77 | done 78 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Known Bugs 2 | 3 | 1. Gallery2 doesn't work with PHP5+APC. There is something wrong 4 | with the way methods are restored in some edge case I haven't 5 | been able to figure out yet. 6 | To reproduce install gallery2 and click down to an individual photo. 7 | 8 | 2. apc_store() probably needs some checks to skip trying to store 9 | internal classes. Something along the lines of: 10 | 11 | if(Z_TYPE_P(val) == IS_OBJECT) { 12 | zend_class_entry *ce = Z_OBJCE_P(val); 13 | if(ce->type == ZEND_INTERNAL_CLASS) { 14 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot cache internal objects"); 15 | RETURN_FALSE; 16 | } 17 | } 18 | 19 | in the apc_store() function in php_apc.c but I am wondering if it needs to do more 20 | than that. 21 | 22 | Windows 23 | 24 | 1. The following configurations (build arguments) have not been implemented yet 25 | 26 | (*) --enable-apc-mmap Memory mapping support 27 | (*) --enable-apc-sem Semaphore locking support (FCNTL replacement) 28 | (*) --enable-apc-phreadmutex Thread mutexes, while implemented we should probably rename the internals to thread 29 | (*) --enable-apc-pthreadrwlocks Thread mutexes, read/write locking 30 | 31 | 2. Non-blocking locks is not supported either 32 | 33 | 3. Update fileinfo to support stat info in a more portable way (see PECL #17903) 34 | 35 | 4. Check whether the signal handling needs to be enabled, and if it makes sense on Windows -------------------------------------------------------------------------------- /tests/apc_bin_002-1.inc: -------------------------------------------------------------------------------- 1 | my_method()."\n"; 15 | echo "class static property: ".my_class::$my_static_property."\n"; 16 | echo "class dynamic property: ".$my_class->my_property."\n"; 17 | echo "class constant: ".my_class::my_constant."\n"; 18 | echo "\n"; 19 | echo "inherited class static method: ".my_i_class::my_static_method()."\n"; 20 | echo "inherited class dynamic method: ".$my_i_class->my_method()."\n"; 21 | echo "inherited class static property: ".my_i_class::$my_static_property."\n"; 22 | echo "inherited class dynamic property: ".$my_i_class->my_property."\n"; 23 | echo "inherited class constant: ".my_i_class::my_constant."\n"; 24 | echo "\n"; 25 | 26 | 27 | 28 | function my_function() { return "Success"; } 29 | 30 | 31 | class my_class { 32 | static $my_static_property = "Success"; 33 | var $my_property = "Success"; 34 | const my_constant = "Success"; 35 | static function my_static_method() { return "Success"; } 36 | function my_method() { return "Success"; } 37 | } 38 | 39 | class my_i_class extends my_class { 40 | function dummy() { return 1; } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /tests/apc_010.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_store/fetch/add with array of key/value pairs. 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | 31 | ===DONE=== 32 | 33 | --EXPECTF-- 34 | array(0) { 35 | } 36 | array(4) { 37 | ["key1"]=> 38 | string(6) "value1" 39 | ["key2"]=> 40 | string(6) "value2" 41 | ["key3"]=> 42 | array(2) { 43 | [0]=> 44 | string(7) "value3a" 45 | [1]=> 46 | string(7) "value3b" 47 | } 48 | ["key4"]=> 49 | int(4) 50 | } 51 | array(2) { 52 | ["key1"]=> 53 | string(6) "value1" 54 | ["key3"]=> 55 | array(2) { 56 | [0]=> 57 | string(7) "value3a" 58 | [1]=> 59 | string(7) "value3b" 60 | } 61 | } 62 | array(2) { 63 | ["key1"]=> 64 | int(-1) 65 | ["key3"]=> 66 | int(-1) 67 | } 68 | array(4) { 69 | ["key1"]=> 70 | string(6) "value1" 71 | ["key2"]=> 72 | string(6) "value2" 73 | ["key3"]=> 74 | array(2) { 75 | [0]=> 76 | string(7) "value3a" 77 | [1]=> 78 | string(7) "value3b" 79 | } 80 | ["key4"]=> 81 | int(4) 82 | } 83 | ===DONE=== 84 | -------------------------------------------------------------------------------- /apc_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | | Arun C. Murthy | 17 | | Gopal Vijayaraghavan | 18 | +----------------------------------------------------------------------+ 19 | 20 | This software was contributed to PHP by Community Connect Inc. in 2002 21 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 22 | Future revisions and derivatives of this source code must acknowledge 23 | Community Connect Inc. as the original contributor of this module by 24 | leaving this note intact in the source code. 25 | 26 | All other licensing and usage conditions are those of the PHP Group. 27 | */ 28 | 29 | void dump(zend_op_array * TSRMLS_DC); 30 | -------------------------------------------------------------------------------- /apc_spin.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Brian Shire | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: apc_spin.h 307048 2011-01-03 23:53:17Z kalle $ */ 21 | 22 | #ifndef APC_SPIN_H 23 | #define APC_SPIN_H 24 | 25 | #include "apc.h" 26 | 27 | #ifdef APC_SPIN_LOCKS 28 | 29 | #include "pgsql_s_lock.h" 30 | 31 | slock_t *apc_slock_create(slock_t *lock); 32 | void apc_slock_destroy(slock_t *lock); 33 | void apc_slock_lock(slock_t *lock TSRMLS_DC); 34 | zend_bool apc_slock_nonblocking_lock(slock_t *lock); 35 | void apc_slock_unlock(slock_t *lock); 36 | 37 | #endif 38 | 39 | #endif 40 | 41 | /* 42 | * Local variables: 43 | * tab-width: 4 44 | * c-basic-offset: 4 45 | * End: 46 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 47 | * vim<600: expandtab sw=4 ts=4 sts=4 48 | */ 49 | -------------------------------------------------------------------------------- /tests/get_included_files.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test get_include_files() function (from ext/standard/tests/general_functions/get_included_files.phpt) 3 | --INI-- 4 | include_path=. 5 | apc.enabled=1 6 | apc.cache_by_default=1 7 | apc.enable_cli=1 8 | --FILE-- 9 | 32 | ===DONE=== 33 | --EXPECTF-- 34 | *** Testing get_included_files() 35 | 36 | -- List included files at start -- 37 | array(1) { 38 | [0]=> 39 | string(%d) "%sget_included_files.php" 40 | } 41 | 42 | -- List included files atfter including inc1 - 43 | array(2) { 44 | [0]=> 45 | string(%d) "%sget_included_files.php" 46 | [1]=> 47 | string(%d) "%sget_included_files_inc1.inc" 48 | } 49 | 50 | -- List included files atfter including inc2 which will include inc3 which includes inc1 -- 51 | array(4) { 52 | [0]=> 53 | string(%d) "%sget_included_files.php" 54 | [1]=> 55 | string(%d) "%sget_included_files_inc1.inc" 56 | [2]=> 57 | string(%d) "%sget_included_files_inc2.inc" 58 | [3]=> 59 | string(%d) "%sget_included_files_inc3.inc" 60 | } 61 | 62 | -- Error cases -- 63 | 64 | Warning: get_included_files() expects exactly 0 parameters, 1 given in %s on line %d 65 | NULL 66 | ===DONE=== 67 | -------------------------------------------------------------------------------- /apc_pthreadmutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Brian Shire | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: apc_pthreadmutex.h 307048 2011-01-03 23:53:17Z kalle $ */ 21 | 22 | #ifndef APC_PTHREADMUTEX_H 23 | #define APC_PTHREADMUTEX_H 24 | 25 | #include "apc.h" 26 | 27 | #ifdef APC_PTHREADMUTEX_LOCKS 28 | 29 | #include 30 | 31 | pthread_mutex_t *apc_pthreadmutex_create(pthread_mutex_t *lock TSRMLS_DC); 32 | void apc_pthreadmutex_destroy(pthread_mutex_t *lock); 33 | void apc_pthreadmutex_lock(pthread_mutex_t *lock TSRMLS_DC); 34 | void apc_pthreadmutex_unlock(pthread_mutex_t *lock TSRMLS_DC); 35 | zend_bool apc_pthreadmutex_nonblocking_lock(pthread_mutex_t *lock TSRMLS_DC); 36 | 37 | #endif 38 | 39 | #endif 40 | 41 | /* 42 | * Local variables: 43 | * tab-width: 4 44 | * c-basic-offset: 4 45 | * End: 46 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 47 | * vim<600: expandtab sw=4 ts=4 sts=4 48 | */ 49 | -------------------------------------------------------------------------------- /config.w32: -------------------------------------------------------------------------------- 1 | // $Id: config.w32 309203 2011-03-14 06:47:16Z pajoye $ 2 | // vim:ft=javascript 3 | 4 | ARG_ENABLE('apc', 'Whether to enable APC support', 'no'); 5 | ARG_ENABLE('apc-debug', 'Whether to enable APC debugging', 'no'); 6 | ARG_ENABLE('apc-filehits', 'Whether to enable cache request file info', 'no'); 7 | ARG_ENABLE('apc-spinlocks', 'Whether to use spin locks (experimental)', 'no'); 8 | ARG_ENABLE('apc-memprotect', 'Whether to enable memory protection (experimental)', 'no'); 9 | ARG_ENABLE('apc-srwlock-native', 'Whether to use SRWLOCK locks native (win7/2008 only)', 'no'); 10 | ARG_ENABLE('apc-srwlock-kernel', 'Whether to use SRWLOCK locks (loaded at runtime)', 'no'); 11 | 12 | if(PHP_APC != 'no') 13 | { 14 | var apc_sources = 'apc.c php_apc.c apc_cache.c apc_compile.c apc_debug.c ' + 15 | 'apc_fcntl_win32.c apc_iterator.c apc_main.c apc_shm.c ' + 16 | 'apc_sma.c apc_stack.c apc_rfc1867.c apc_zend.c apc_pool.c ' + 17 | 'apc_bin.c apc_string.c'; 18 | 19 | if(PHP_APC_DEBUG != 'no') 20 | { 21 | ADD_FLAG('CFLAGS_APC', '/D __DEBUG_APC__=1'); 22 | } 23 | 24 | if(PHP_APC_FILEHITS != 'no') 25 | { 26 | AC_DEFINE('APC_FILEHITS', 1); 27 | } 28 | 29 | if(PHP_APC_MEMPROTECT != 'no') 30 | { 31 | AC_DEFINE('APC_MEMPROTECT', 1); 32 | } 33 | 34 | if(PHP_APC_SRWLOCK_NATIVE != 'no') { 35 | AC_DEFINE('APC_SRWLOCK_NATIVE', 1); 36 | } else { 37 | if(PHP_APC_SRWLOCK_KERNEL != 'no') { 38 | AC_DEFINE('APC_SRWLOCK_KERNEL', 1); 39 | ADD_FLAG('CFLAGS_APC', '/D WIN32_ONLY_COMPILER=1'); 40 | 41 | apc_sources += ' apc_windows_srwlock_kernel.c'; 42 | } else { 43 | if(PHP_APC_SPINLOCKS != 'no') { 44 | AC_DEFINE('APC_SPIN_LOCKS', 1); 45 | ADD_FLAG('CFLAGS_APC', '/D WIN32_ONLY_COMPILER=1'); 46 | 47 | apc_sources += ' apc_spin.c pgsql_s_lock.c'; 48 | } else { 49 | AC_DEFINE('APC_FCNTL_LOCKS', 1); 50 | } 51 | } 52 | } 53 | 54 | AC_DEFINE('HAVE_APC', 1); 55 | AC_DEFINE('HAVE_ATOMIC_OPERATIONS', 1); 56 | 57 | PHP_INSTALL_HEADERS("ext/apc", "apc_serializer.h"); 58 | 59 | EXTENSION('apc', apc_sources); 60 | } 61 | -------------------------------------------------------------------------------- /tests/apc54_009.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #61824 apc produces strange notice (php 5.4) 3 | --SKIPIF-- 4 | document); 18 | echo "\n"; 19 | FL; 20 | 21 | $args = array( 22 | 'apc.enabled=1', 23 | 'apc.enable_cli=1', 24 | ); 25 | 26 | server_start($file, $args); 27 | 28 | for ($i = 0; $i < 10; $i++) { 29 | run_test_simple(); 30 | } 31 | echo 'done'; 32 | 33 | --EXPECT-- 34 | DOMDocument::__set_state(array( 35 | )) 36 | DOMDocument::__set_state(array( 37 | )) 38 | DOMDocument::__set_state(array( 39 | )) 40 | DOMDocument::__set_state(array( 41 | )) 42 | DOMDocument::__set_state(array( 43 | )) 44 | DOMDocument::__set_state(array( 45 | )) 46 | DOMDocument::__set_state(array( 47 | )) 48 | DOMDocument::__set_state(array( 49 | )) 50 | DOMDocument::__set_state(array( 51 | )) 52 | DOMDocument::__set_state(array( 53 | )) 54 | DOMDocument::__set_state(array( 55 | )) 56 | DOMDocument::__set_state(array( 57 | )) 58 | DOMDocument::__set_state(array( 59 | )) 60 | DOMDocument::__set_state(array( 61 | )) 62 | DOMDocument::__set_state(array( 63 | )) 64 | DOMDocument::__set_state(array( 65 | )) 66 | DOMDocument::__set_state(array( 67 | )) 68 | DOMDocument::__set_state(array( 69 | )) 70 | DOMDocument::__set_state(array( 71 | )) 72 | DOMDocument::__set_state(array( 73 | )) 74 | DOMDocument::__set_state(array( 75 | )) 76 | DOMDocument::__set_state(array( 77 | )) 78 | DOMDocument::__set_state(array( 79 | )) 80 | DOMDocument::__set_state(array( 81 | )) 82 | DOMDocument::__set_state(array( 83 | )) 84 | DOMDocument::__set_state(array( 85 | )) 86 | DOMDocument::__set_state(array( 87 | )) 88 | DOMDocument::__set_state(array( 89 | )) 90 | DOMDocument::__set_state(array( 91 | )) 92 | DOMDocument::__set_state(array( 93 | )) 94 | done 95 | -------------------------------------------------------------------------------- /apc_pthreadrwlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Gopal V | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: apc_pthreadrwlock.h 302175 2010-08-13 06:20:28Z kalle $ */ 21 | 22 | #ifndef APC_PTHREADRWLOCK_H 23 | #define APC_PTHREADRWLOCK_H 24 | 25 | #include "apc.h" 26 | 27 | #ifdef APC_PTHREADRW_LOCKS 28 | 29 | #include 30 | 31 | pthread_rwlock_t *apc_pthreadrwlock_create(pthread_rwlock_t *lock TSRMLS_DC); 32 | void apc_pthreadrwlock_destroy(pthread_rwlock_t *lock); 33 | void apc_pthreadrwlock_lock(pthread_rwlock_t *lock TSRMLS_DC); 34 | void apc_pthreadrwlock_rdlock(pthread_rwlock_t *lock TSRMLS_DC); 35 | void apc_pthreadrwlock_unlock(pthread_rwlock_t *lock TSRMLS_DC); 36 | zend_bool apc_pthreadrwlock_nonblocking_lock(pthread_rwlock_t *lock TSRMLS_DC); 37 | 38 | #endif 39 | 40 | #endif 41 | 42 | /* 43 | * Local variables: 44 | * tab-width: 4 45 | * c-basic-offset: 4 46 | * End: 47 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 48 | * vim<600: expandtab sw=4 ts=4 sts=4 49 | */ 50 | -------------------------------------------------------------------------------- /tests/apc54_014.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #61742 preload_path does not work due to incorrect string length (variant 1) (php 5.4) 3 | --SKIPIF-- 4 | | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: apc_signal.h 307048 2011-01-03 23:53:17Z kalle $ */ 21 | 22 | #ifndef APC_SIGNAL_H 23 | #define APC_SIGNAL_H 24 | 25 | #include "apc.h" 26 | #include "apc_php.h" 27 | 28 | typedef struct apc_signal_entry_t { 29 | int signo; /* signal number */ 30 | int siginfo; /* siginfo style handler calling */ 31 | void* handler; /* signal handler */ 32 | } apc_signal_entry_t; 33 | 34 | typedef struct apc_signal_info_t { 35 | int installed; /* How many signals we've installed handles for */ 36 | apc_signal_entry_t **prev; /* Previous signal handlers */ 37 | } apc_signal_info_t; 38 | 39 | void apc_set_signals(TSRMLS_D); 40 | void apc_shutdown_signals(TSRMLS_D); 41 | 42 | #endif 43 | 44 | /* 45 | * Local variables: 46 | * tab-width: 4 47 | * c-basic-offset: 4 48 | * End: 49 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 50 | * vim<600: expandtab sw=4 ts=4 sts=4 51 | */ 52 | -------------------------------------------------------------------------------- /apc_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Dmitry Stogov | 16 | +----------------------------------------------------------------------+ 17 | 18 | This software was contributed to PHP by Community Connect Inc. in 2002 19 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 20 | Future revisions and derivatives of this source code must acknowledge 21 | Community Connect Inc. as the original contributor of this module by 22 | leaving this note intact in the source code. 23 | 24 | All other licensing and usage conditions are those of the PHP Group. 25 | 26 | */ 27 | 28 | /* $Id: apc_string.h 324145 2012-03-12 11:38:28Z pajoye $ */ 29 | 30 | #ifndef APC_STRING 31 | #define APC_STRING 32 | 33 | #include "apc.h" 34 | 35 | #ifndef ZTS 36 | void apc_interned_strings_init(TSRMLS_D); 37 | void apc_interned_strings_shutdown(TSRMLS_D); 38 | #endif 39 | 40 | const char *apc_new_interned_string(const char *arKey, int nKeyLength TSRMLS_DC); 41 | 42 | #endif 43 | 44 | /* 45 | * Local variables: 46 | * tab-width: 4 47 | * c-basic-offset: 4 48 | * End: 49 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 50 | * vim<600: expandtab sw=4 ts=4 sts=4 51 | */ 52 | -------------------------------------------------------------------------------- /apc_mmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Gopal V | 16 | +----------------------------------------------------------------------+ 17 | 18 | This software was contributed to PHP by Community Connect Inc. in 2002 19 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 20 | Future revisions and derivatives of this source code must acknowledge 21 | Community Connect Inc. as the original contributor of this module by 22 | leaving this note intact in the source code. 23 | 24 | All other licensing and usage conditions are those of the PHP Group. 25 | 26 | */ 27 | 28 | /* $Id: apc_mmap.h 307048 2011-01-03 23:53:17Z kalle $ */ 29 | 30 | #ifndef APC_MMAP_H 31 | #define APC_MMAP_H 32 | 33 | #include 34 | 35 | #include "apc.h" 36 | #include "apc_sma.h" 37 | 38 | /* Wrapper functions for shared memory mapped files */ 39 | 40 | #if APC_MMAP 41 | apc_segment_t apc_mmap(char *file_mask, size_t size TSRMLS_DC); 42 | void apc_unmap(apc_segment_t* segment TSRMLS_DC); 43 | #endif 44 | 45 | #endif 46 | 47 | /* 48 | * Local variables: 49 | * tab-width: 4 50 | * c-basic-offset: 4 51 | * End: 52 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 53 | * vim<600: expandtab sw=4 ts=4 sts=4 54 | */ 55 | -------------------------------------------------------------------------------- /apc_spin.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Brian Shire | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: apc_spin.c 307048 2011-01-03 23:53:17Z kalle $ */ 21 | 22 | #include "apc_spin.h" 23 | 24 | #ifdef APC_SPIN_LOCKS 25 | 26 | slock_t *apc_slock_create(slock_t *lock) 27 | { 28 | S_INIT_LOCK(lock); 29 | return lock; 30 | } 31 | 32 | void apc_slock_destroy(slock_t *lock) 33 | { 34 | return; 35 | } 36 | 37 | void apc_slock_lock(slock_t *lock TSRMLS_DC) 38 | { 39 | S_LOCK(lock); 40 | } 41 | 42 | void apc_slock_unlock(slock_t *lock) 43 | { 44 | S_UNLOCK(lock); 45 | } 46 | 47 | zend_bool apc_slock_nonblocking_lock(slock_t *lock) 48 | { 49 | /* Technically we aren't supposed to call this directly, but the original 50 | * code provides no method for absolute non-blocking locks, so we'll call into 51 | * the TAS (test and set) functionality directly 52 | */ 53 | return !(TAS(lock)); /* if TAS returns 0 we obtained the lock, otherwise we failed */ 54 | } 55 | 56 | 57 | #endif 58 | 59 | /* 60 | * Local variables: 61 | * tab-width: 4 62 | * c-basic-offset: 4 63 | * End: 64 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 65 | * vim<600: expandtab sw=4 ts=4 sts=4 66 | */ 67 | -------------------------------------------------------------------------------- /apc_fcntl.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt. | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: George Schlossnagle | 16 | | Rasmus Lerdorf | 17 | +----------------------------------------------------------------------+ 18 | 19 | This software was contributed to PHP by Community Connect Inc. in 2002 20 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 21 | Future revisions and derivatives of this source code must acknowledge 22 | Community Connect Inc. as the original contributor of this module by 23 | leaving this note intact in the source code. 24 | 25 | All other licensing and usage conditions are those of the PHP Group. 26 | 27 | */ 28 | 29 | /* $Id: apc_fcntl.h 307048 2011-01-03 23:53:17Z kalle $ */ 30 | 31 | #ifndef APC_FCNTL_H 32 | #define APC_FCNTL_H 33 | 34 | 35 | extern int apc_fcntl_create(const char* pathname TSRMLS_DC); 36 | extern void apc_fcntl_destroy(int fd); 37 | extern void apc_fcntl_lock(int fd TSRMLS_DC); 38 | extern void apc_fcntl_rdlock(int fd TSRMLS_DC); 39 | extern void apc_fcntl_unlock(int fd TSRMLS_DC); 40 | extern unsigned char apc_fcntl_nonblocking_lock(int fd TSRMLS_DC); 41 | #endif 42 | 43 | /* 44 | * Local variables: 45 | * tab-width: 4 46 | * c-basic-offset: 4 47 | * End: 48 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 49 | * vim<600: expandtab sw=4 ts=4 sts=4 50 | */ 51 | -------------------------------------------------------------------------------- /php_apc.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | | George Schlossnagle | 17 | | Rasmus Lerdorf | 18 | +----------------------------------------------------------------------+ 19 | 20 | This software was contributed to PHP by Community Connect Inc. in 2002 21 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 22 | Future revisions and derivatives of this source code must acknowledge 23 | Community Connect Inc. as the original contributor of this module by 24 | leaving this note intact in the source code. 25 | 26 | All other licensing and usage conditions are those of the PHP Group. 27 | 28 | */ 29 | 30 | /* $Id: php_apc.h 328953 2013-01-03 02:19:19Z rasmus $ */ 31 | 32 | #ifndef PHP_APC_H 33 | #define PHP_APC_H 34 | 35 | #include "apc_php.h" 36 | #include "apc_globals.h" 37 | 38 | #define PHP_APC_VERSION "3.1.15-dev" 39 | 40 | extern zend_module_entry apc_module_entry; 41 | #define apc_module_ptr &apc_module_entry 42 | 43 | #define phpext_apc_ptr apc_module_ptr 44 | 45 | #endif /* PHP_APC_H */ 46 | 47 | /* 48 | * Local variables: 49 | * tab-width: 4 50 | * c-basic-offset: 4 51 | * End: 52 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 53 | * vim<600: expandtab sw=4 ts=4 sts=4 54 | */ 55 | -------------------------------------------------------------------------------- /apc_shm.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | +----------------------------------------------------------------------+ 17 | 18 | This software was contributed to PHP by Community Connect Inc. in 2002 19 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 20 | Future revisions and derivatives of this source code must acknowledge 21 | Community Connect Inc. as the original contributor of this module by 22 | leaving this note intact in the source code. 23 | 24 | All other licensing and usage conditions are those of the PHP Group. 25 | 26 | */ 27 | 28 | /* $Id: apc_shm.h 307259 2011-01-08 12:05:24Z gopalv $ */ 29 | 30 | #ifndef APC_SHM_H 31 | #define APC_SHM_H 32 | 33 | #include 34 | #ifdef PHP_WIN32 35 | #include 36 | #endif 37 | 38 | #include "apc_sma.h" 39 | 40 | /* Wrapper functions for unix shared memory */ 41 | 42 | extern int apc_shm_create(int proj, size_t size TSRMLS_DC); 43 | extern void apc_shm_destroy(int shmid); 44 | extern apc_segment_t apc_shm_attach(int shmid, size_t size TSRMLS_DC); 45 | extern void apc_shm_detach(apc_segment_t* segment TSRMLS_DC); 46 | 47 | #endif 48 | 49 | /* 50 | * Local variables: 51 | * tab-width: 4 52 | * c-basic-offset: 4 53 | * End: 54 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 55 | * vim<600: expandtab sw=4 ts=4 sts=4 56 | */ 57 | -------------------------------------------------------------------------------- /tests/bug52144_classes.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #52144 (Error: Base lambda function for closure not found) 3 | --SKIPIF-- 4 | dummy(); 51 | } 52 | PHP; 53 | 54 | $args = array( 55 | 'apc.enabled=1', 56 | 'apc.enable_cli=1', 57 | 'apc.file_update_protection=0', 58 | ); 59 | 60 | server_start($file, $args); 61 | 62 | for ($i = 0; $i < 10; $i++) { 63 | echo "-----------------------------\n"; 64 | run_test_simple("?tested=true"); 65 | } 66 | --CLEAN-- 67 | 70 | --EXPECT-- 71 | ----------------------------- 72 | string(6) "cached" 73 | ----------------------------- 74 | string(1) "C" 75 | ----------------------------- 76 | string(6) "cached" 77 | ----------------------------- 78 | string(1) "C" 79 | ----------------------------- 80 | string(6) "cached" 81 | ----------------------------- 82 | string(1) "C" 83 | ----------------------------- 84 | string(6) "cached" 85 | ----------------------------- 86 | string(1) "C" 87 | ----------------------------- 88 | string(6) "cached" 89 | ----------------------------- 90 | string(1) "C" 91 | -------------------------------------------------------------------------------- /apc_sem.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | +----------------------------------------------------------------------+ 17 | 18 | This software was contributed to PHP by Community Connect Inc. in 2002 19 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 20 | Future revisions and derivatives of this source code must acknowledge 21 | Community Connect Inc. as the original contributor of this module by 22 | leaving this note intact in the source code. 23 | 24 | All other licensing and usage conditions are those of the PHP Group. 25 | 26 | */ 27 | 28 | /* $Id: apc_sem.h 307048 2011-01-03 23:53:17Z kalle $ */ 29 | 30 | #ifndef APC_SEM_H 31 | #define APC_SEM_H 32 | 33 | /* Wrapper functions for SysV sempahores */ 34 | 35 | extern int apc_sem_create(int proj, int initval TSRMLS_DC); 36 | extern void apc_sem_destroy(int semid); 37 | extern void apc_sem_lock(int semid TSRMLS_DC); 38 | extern int apc_sem_nonblocking_lock(int semid TSRMLS_DC); 39 | extern void apc_sem_unlock(int semid TSRMLS_DC); 40 | extern void apc_sem_wait_for_zero(int semid TSRMLS_DC); 41 | extern int apc_sem_get_value(int semid TSRMLS_DC); 42 | 43 | #endif 44 | 45 | /* 46 | * Local variables: 47 | * tab-width: 4 48 | * c-basic-offset: 4 49 | * End: 50 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 51 | * vim<600: expandtab sw=4 ts=4 sts=4 52 | */ 53 | -------------------------------------------------------------------------------- /tests/apc_003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_store/fetch with objects (php pre-5.3) 3 | --SKIPIF-- 4 | = 0) { 7 | echo "skip\n"; 8 | } 9 | ?> 10 | --INI-- 11 | apc.enabled=1 12 | apc.enable_cli=1 13 | apc.file_update_protection=0 14 | --FILE-- 15 | a = true; 25 | var_dump($bar); 26 | 27 | class bar extends foo 28 | { 29 | public $pub = 'bar'; 30 | protected $pro = 'bar'; 31 | private $pri = 'bar'; // we don't see this, we'd need php 5.1 new serialization 32 | 33 | function __construct() 34 | { 35 | $this->bar = true; 36 | } 37 | 38 | function change() 39 | { 40 | $this->pri = 'mod'; 41 | } 42 | } 43 | 44 | class baz extends bar 45 | { 46 | private $pri = 'baz'; 47 | 48 | function __construct() 49 | { 50 | parent::__construct(); 51 | $this->baz = true; 52 | } 53 | } 54 | 55 | $baz = new baz; 56 | var_dump($baz); 57 | $baz->change(); 58 | var_dump($baz); 59 | apc_store('baz', $baz); 60 | unset($baz); 61 | var_dump(apc_fetch('baz')); 62 | 63 | ?> 64 | ===DONE=== 65 | 66 | --EXPECTF-- 67 | object(foo)#%d (0) { 68 | } 69 | object(foo)#%d (0) { 70 | } 71 | object(foo)#%d (1) { 72 | ["a"]=> 73 | bool(true) 74 | } 75 | object(baz)#%d (6) { 76 | ["pri:private"]=> 77 | string(3) "baz" 78 | ["pub"]=> 79 | string(3) "bar" 80 | ["pro:protected"]=> 81 | string(3) "bar" 82 | ["pri:private"]=> 83 | string(3) "bar" 84 | ["bar"]=> 85 | bool(true) 86 | ["baz"]=> 87 | bool(true) 88 | } 89 | object(baz)#%d (6) { 90 | ["pri:private"]=> 91 | string(3) "baz" 92 | ["pub"]=> 93 | string(3) "bar" 94 | ["pro:protected"]=> 95 | string(3) "bar" 96 | ["pri:private"]=> 97 | string(3) "mod" 98 | ["bar"]=> 99 | bool(true) 100 | ["baz"]=> 101 | bool(true) 102 | } 103 | object(baz)#%d (6) { 104 | ["pri:private"]=> 105 | string(3) "baz" 106 | ["pub"]=> 107 | string(3) "bar" 108 | ["pro:protected"]=> 109 | string(3) "bar" 110 | ["pri:private"]=> 111 | string(3) "mod" 112 | ["bar"]=> 113 | bool(true) 114 | ["baz"]=> 115 | bool(true) 116 | } 117 | ===DONE=== 118 | -------------------------------------------------------------------------------- /apc_bin.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Brian Shire | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: apc_bin.h 328743 2012-12-12 07:58:32Z ab $ */ 21 | 22 | #ifndef APC_BINDUMP_H 23 | #define APC_BINDUMP_H 24 | 25 | #include "apc.h" 26 | #include "apc_php.h" 27 | #include "ext/standard/basic_functions.h" 28 | 29 | /* APC binload flags */ 30 | #define APC_BIN_VERIFY_MD5 1 << 0 31 | #define APC_BIN_VERIFY_CRC32 1 << 1 32 | 33 | typedef struct _apc_bd_entry_t { 34 | unsigned char type; 35 | uint num_functions; 36 | uint num_classes; 37 | apc_cache_entry_value_t val; 38 | unsigned char file_md5[16]; /* only sensible for file entries */ 39 | } apc_bd_entry_t; 40 | 41 | typedef struct _apc_bd_t { 42 | unsigned int size; 43 | int swizzled; 44 | unsigned char md5[16]; 45 | php_uint32 crc; 46 | unsigned int num_entries; 47 | apc_bd_entry_t *entries; 48 | int num_swizzled_ptrs; 49 | void ***swizzled_ptrs; 50 | } apc_bd_t; 51 | 52 | apc_bd_t* apc_bin_dump(HashTable *files, HashTable *user_vars TSRMLS_DC); 53 | int apc_bin_load(apc_bd_t *bd, int flags TSRMLS_DC); 54 | 55 | #endif 56 | 57 | /* 58 | * Local variables: 59 | * tab-width: 4 60 | * c-basic-offset: 4 61 | * End: 62 | * vim600: expandtab sw=4 ts=4 sts=4 fdm=marker 63 | * vim<600: expandtab sw=4 ts=4 sts=4 64 | */ 65 | -------------------------------------------------------------------------------- /tests/iterator_001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: APCIterator general 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | $value) { 17 | $vals[$key] = $value['key']; 18 | } 19 | ksort($vals); 20 | var_dump($vals); 21 | 22 | ?> 23 | ===DONE=== 24 | 25 | --EXPECT-- 26 | array(41) { 27 | ["key0"]=> 28 | string(4) "key0" 29 | ["key1"]=> 30 | string(4) "key1" 31 | ["key10"]=> 32 | string(5) "key10" 33 | ["key11"]=> 34 | string(5) "key11" 35 | ["key12"]=> 36 | string(5) "key12" 37 | ["key13"]=> 38 | string(5) "key13" 39 | ["key14"]=> 40 | string(5) "key14" 41 | ["key15"]=> 42 | string(5) "key15" 43 | ["key16"]=> 44 | string(5) "key16" 45 | ["key17"]=> 46 | string(5) "key17" 47 | ["key18"]=> 48 | string(5) "key18" 49 | ["key19"]=> 50 | string(5) "key19" 51 | ["key2"]=> 52 | string(4) "key2" 53 | ["key20"]=> 54 | string(5) "key20" 55 | ["key21"]=> 56 | string(5) "key21" 57 | ["key22"]=> 58 | string(5) "key22" 59 | ["key23"]=> 60 | string(5) "key23" 61 | ["key24"]=> 62 | string(5) "key24" 63 | ["key25"]=> 64 | string(5) "key25" 65 | ["key26"]=> 66 | string(5) "key26" 67 | ["key27"]=> 68 | string(5) "key27" 69 | ["key28"]=> 70 | string(5) "key28" 71 | ["key29"]=> 72 | string(5) "key29" 73 | ["key3"]=> 74 | string(4) "key3" 75 | ["key30"]=> 76 | string(5) "key30" 77 | ["key31"]=> 78 | string(5) "key31" 79 | ["key32"]=> 80 | string(5) "key32" 81 | ["key33"]=> 82 | string(5) "key33" 83 | ["key34"]=> 84 | string(5) "key34" 85 | ["key35"]=> 86 | string(5) "key35" 87 | ["key36"]=> 88 | string(5) "key36" 89 | ["key37"]=> 90 | string(5) "key37" 91 | ["key38"]=> 92 | string(5) "key38" 93 | ["key39"]=> 94 | string(5) "key39" 95 | ["key4"]=> 96 | string(4) "key4" 97 | ["key40"]=> 98 | string(5) "key40" 99 | ["key5"]=> 100 | string(4) "key5" 101 | ["key6"]=> 102 | string(4) "key6" 103 | ["key7"]=> 104 | string(4) "key7" 105 | ["key8"]=> 106 | string(4) "key8" 107 | ["key9"]=> 108 | string(4) "key9" 109 | } 110 | ===DONE=== 111 | -------------------------------------------------------------------------------- /tests/apc_003b.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_store/fetch with objects (php 5.3) 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | apc.enabled=1 12 | apc.enable_cli=1 13 | apc.file_update_protection=0 14 | --FILE-- 15 | a = true; 25 | var_dump($bar); 26 | 27 | class bar extends foo 28 | { 29 | public $pub = 'bar'; 30 | protected $pro = 'bar'; 31 | private $pri = 'bar'; // we don't see this, we'd need php 5.1 new serialization 32 | 33 | function __construct() 34 | { 35 | $this->bar = true; 36 | } 37 | 38 | function change() 39 | { 40 | $this->pri = 'mod'; 41 | } 42 | } 43 | 44 | class baz extends bar 45 | { 46 | private $pri = 'baz'; 47 | 48 | function __construct() 49 | { 50 | parent::__construct(); 51 | $this->baz = true; 52 | } 53 | } 54 | 55 | $baz = new baz; 56 | var_dump($baz); 57 | $baz->change(); 58 | var_dump($baz); 59 | apc_store('baz', $baz); 60 | unset($baz); 61 | var_dump(apc_fetch('baz')); 62 | 63 | ?> 64 | ===DONE=== 65 | 66 | --EXPECTF-- 67 | object(foo)#%d (0) { 68 | } 69 | object(foo)#%d (0) { 70 | } 71 | object(foo)#%d (1) { 72 | ["a"]=> 73 | bool(true) 74 | } 75 | object(baz)#%d (6) { 76 | ["pri":"baz":private]=> 77 | string(3) "baz" 78 | ["pub"]=> 79 | string(3) "bar" 80 | ["pro":protected]=> 81 | string(3) "bar" 82 | ["pri":"bar":private]=> 83 | string(3) "bar" 84 | ["bar"]=> 85 | bool(true) 86 | ["baz"]=> 87 | bool(true) 88 | } 89 | object(baz)#%d (6) { 90 | ["pri":"baz":private]=> 91 | string(3) "baz" 92 | ["pub"]=> 93 | string(3) "bar" 94 | ["pro":protected]=> 95 | string(3) "bar" 96 | ["pri":"bar":private]=> 97 | string(3) "mod" 98 | ["bar"]=> 99 | bool(true) 100 | ["baz"]=> 101 | bool(true) 102 | } 103 | object(baz)#%d (6) { 104 | ["pri":"baz":private]=> 105 | string(3) "baz" 106 | ["pub"]=> 107 | string(3) "bar" 108 | ["pro":protected]=> 109 | string(3) "bar" 110 | ["pri":"bar":private]=> 111 | string(3) "mod" 112 | ["bar"]=> 113 | bool(true) 114 | ["baz"]=> 115 | bool(true) 116 | } 117 | ===DONE=== 118 | -------------------------------------------------------------------------------- /tests/apc54_021.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: APCIterator file + apc_delete_file() (php 5.4) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | $value) { 17 | $vals[$key] = $value['key']; 18 | } 19 | ksort($vals); 20 | var_dump($vals); 21 | 22 | ?> 23 | ===DONE=== 24 | 25 | --EXPECT-- 26 | array(41) { 27 | ["key0"]=> 28 | string(4) "key0" 29 | ["key1"]=> 30 | string(4) "key1" 31 | ["key10"]=> 32 | string(5) "key10" 33 | ["key11"]=> 34 | string(5) "key11" 35 | ["key12"]=> 36 | string(5) "key12" 37 | ["key13"]=> 38 | string(5) "key13" 39 | ["key14"]=> 40 | string(5) "key14" 41 | ["key15"]=> 42 | string(5) "key15" 43 | ["key16"]=> 44 | string(5) "key16" 45 | ["key17"]=> 46 | string(5) "key17" 47 | ["key18"]=> 48 | string(5) "key18" 49 | ["key19"]=> 50 | string(5) "key19" 51 | ["key2"]=> 52 | string(4) "key2" 53 | ["key20"]=> 54 | string(5) "key20" 55 | ["key21"]=> 56 | string(5) "key21" 57 | ["key22"]=> 58 | string(5) "key22" 59 | ["key23"]=> 60 | string(5) "key23" 61 | ["key24"]=> 62 | string(5) "key24" 63 | ["key25"]=> 64 | string(5) "key25" 65 | ["key26"]=> 66 | string(5) "key26" 67 | ["key27"]=> 68 | string(5) "key27" 69 | ["key28"]=> 70 | string(5) "key28" 71 | ["key29"]=> 72 | string(5) "key29" 73 | ["key3"]=> 74 | string(4) "key3" 75 | ["key30"]=> 76 | string(5) "key30" 77 | ["key31"]=> 78 | string(5) "key31" 79 | ["key32"]=> 80 | string(5) "key32" 81 | ["key33"]=> 82 | string(5) "key33" 83 | ["key34"]=> 84 | string(5) "key34" 85 | ["key35"]=> 86 | string(5) "key35" 87 | ["key36"]=> 88 | string(5) "key36" 89 | ["key37"]=> 90 | string(5) "key37" 91 | ["key38"]=> 92 | string(5) "key38" 93 | ["key39"]=> 94 | string(5) "key39" 95 | ["key4"]=> 96 | string(4) "key4" 97 | ["key40"]=> 98 | string(5) "key40" 99 | ["key5"]=> 100 | string(4) "key5" 101 | ["key6"]=> 102 | string(4) "key6" 103 | ["key7"]=> 104 | string(4) "key7" 105 | ["key8"]=> 106 | string(4) "key8" 107 | ["key9"]=> 108 | string(4) "key9" 109 | } 110 | ===DONE=== 111 | -------------------------------------------------------------------------------- /tests/iterator_005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: APCIterator delete 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | --FILE-- 10 | $value) { 21 | $vals[$key] = $value['key']; 22 | } 23 | foreach($it2 as $key=>$value) { 24 | $vals2[$key] = $value['key']; 25 | } 26 | ksort($vals2); 27 | var_dump($vals); 28 | var_dump($vals2); 29 | 30 | ?> 31 | ===DONE=== 32 | 33 | --EXPECT-- 34 | array(0) { 35 | } 36 | array(37) { 37 | ["key0"]=> 38 | string(4) "key0" 39 | ["key1"]=> 40 | string(4) "key1" 41 | ["key11"]=> 42 | string(5) "key11" 43 | ["key12"]=> 44 | string(5) "key12" 45 | ["key13"]=> 46 | string(5) "key13" 47 | ["key14"]=> 48 | string(5) "key14" 49 | ["key15"]=> 50 | string(5) "key15" 51 | ["key16"]=> 52 | string(5) "key16" 53 | ["key17"]=> 54 | string(5) "key17" 55 | ["key18"]=> 56 | string(5) "key18" 57 | ["key19"]=> 58 | string(5) "key19" 59 | ["key2"]=> 60 | string(4) "key2" 61 | ["key21"]=> 62 | string(5) "key21" 63 | ["key22"]=> 64 | string(5) "key22" 65 | ["key23"]=> 66 | string(5) "key23" 67 | ["key24"]=> 68 | string(5) "key24" 69 | ["key25"]=> 70 | string(5) "key25" 71 | ["key26"]=> 72 | string(5) "key26" 73 | ["key27"]=> 74 | string(5) "key27" 75 | ["key28"]=> 76 | string(5) "key28" 77 | ["key29"]=> 78 | string(5) "key29" 79 | ["key3"]=> 80 | string(4) "key3" 81 | ["key31"]=> 82 | string(5) "key31" 83 | ["key32"]=> 84 | string(5) "key32" 85 | ["key33"]=> 86 | string(5) "key33" 87 | ["key34"]=> 88 | string(5) "key34" 89 | ["key35"]=> 90 | string(5) "key35" 91 | ["key36"]=> 92 | string(5) "key36" 93 | ["key37"]=> 94 | string(5) "key37" 95 | ["key38"]=> 96 | string(5) "key38" 97 | ["key39"]=> 98 | string(5) "key39" 99 | ["key4"]=> 100 | string(4) "key4" 101 | ["key5"]=> 102 | string(4) "key5" 103 | ["key6"]=> 104 | string(4) "key6" 105 | ["key7"]=> 106 | string(4) "key7" 107 | ["key8"]=> 108 | string(4) "key8" 109 | ["key9"]=> 110 | string(4) "key9" 111 | } 112 | ===DONE=== 113 | -------------------------------------------------------------------------------- /apc_stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | | George Schlossnagle | 17 | +----------------------------------------------------------------------+ 18 | 19 | This software was contributed to PHP by Community Connect Inc. in 2002 20 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 21 | Future revisions and derivatives of this source code must acknowledge 22 | Community Connect Inc. as the original contributor of this module by 23 | leaving this note intact in the source code. 24 | 25 | All other licensing and usage conditions are those of the PHP Group. 26 | 27 | */ 28 | 29 | /* $Id: apc_stack.h 307048 2011-01-03 23:53:17Z kalle $ */ 30 | 31 | #ifndef APC_STACK_H 32 | #define APC_STACK_H 33 | 34 | /* Basic stack datatype */ 35 | 36 | #define T apc_stack_t* 37 | typedef struct apc_stack_t apc_stack_t; /* opaque stack type */ 38 | 39 | extern T apc_stack_create(int size_hint TSRMLS_DC); 40 | extern void apc_stack_destroy(T stack TSRMLS_DC); 41 | extern void apc_stack_clear(T stack); 42 | extern void apc_stack_push(T stack, void* item TSRMLS_DC); 43 | extern void* apc_stack_pop(T stack); 44 | extern void* apc_stack_top(T stack); 45 | extern void* apc_stack_get(T stack, int n); 46 | extern int apc_stack_size(T stack); 47 | 48 | #undef T 49 | #endif 50 | 51 | /* 52 | * Local variables: 53 | * tab-width: 4 54 | * c-basic-offset: 4 55 | * End: 56 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 57 | * vim<600: expandtab sw=4 ts=4 sts=4 58 | */ 59 | -------------------------------------------------------------------------------- /tests/apc_012.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_delete_file test with file_md5=on (see #61352) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | apc.stat=On 10 | apc.file_md5=1 11 | report_memleaks=0 12 | --FILE-- 13 | 66 | ===DONE=== 67 | 68 | --CLEAN-- 69 | 73 | --EXPECTF-- 74 | apc_012.php Found File 75 | apc_012.php Not Found 76 | apc_012.php Not Found 77 | apc_012.php Not Found 78 | array(0) { 79 | } 80 | apc_012.php Found File 81 | apc_009-1.php Found File 82 | 83 | Parse error: syntax error, unexpected '!' in %s/apc_009-2.php on line 1 84 | 85 | Warning: apc_compile_file(): Error compiling apc_009-2.php in apc_compile_file. in %s/apc_012.php on line 29 86 | 87 | Warning: apc_compile_file(): Error compiling nofile.php in apc_compile_file. in %s/apc_012.php on line 29 88 | array(2) { 89 | ["apc_009-2.php"]=> 90 | int(-1) 91 | ["nofile.php"]=> 92 | int(-1) 93 | } 94 | apc_012.php Found File 95 | apc_009-1.php Found File 96 | apc_009-2.php Not Found 97 | nofile.php Not Found 98 | ===DONE=== 99 | -------------------------------------------------------------------------------- /tests/apc54_016.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Test trait properties in using class (simple) (php 5.4) 3 | --SKIPIF-- 4 | one; 25 | } 26 | } 27 | 28 | \$w = new World; 29 | var_dump(\$w->loud()); 30 | FL; 31 | 32 | $args = array( 33 | 'apc.cache_by_default=On', 34 | 'apc.canonicalize=On', 35 | 'apc.coredump_unmap=Off', 36 | 'apc.enable_cli=On', 37 | 'apc.enabled=On', 38 | 'apc.file_md5=Off', 39 | 'apc.file_update_protection=2', 40 | 'apc.filters=no', 41 | 'apc.gc_ttl=3600', 42 | 'apc.include_once_override=Off', 43 | 'apc.lazy_classes=Off', 44 | 'apc.lazy_functions=Off', 45 | 'apc.max_file_size=1M', 46 | 'apc.mmap_file_mask=no', 47 | 'apc.num_files_hint=1000', 48 | 'apc.preload_path=no', 49 | 'apc.report_autofilter=Off', 50 | 'apc.rfc1867=Off', 51 | 'apc.rfc1867_freq=0', 52 | 'apc.rfc1867_name=APC_UPLOAD_PROGRESS', 53 | 'apc.rfc1867_prefix=upload_', 54 | 'apc.rfc1867_ttl=3600', 55 | 'apc.serializer=default', 56 | 'apc.shm_segments=1', 57 | 'apc.shm_size=128M', 58 | 'apc.shm_strings_buffer=4M', 59 | 'apc.slam_defense=On', 60 | 'apc.stat=On', 61 | 'apc.stat_ctime=Off', 62 | 'apc.ttl=0', 63 | 'apc.use_request_time=On', 64 | 'apc.user_entries_hint=4096', 65 | 'apc.user_ttl=0', 66 | 'apc.write_lock=On', 67 | ); 68 | 69 | server_start($file, $args); 70 | 71 | for ($i = 0; $i < 10; $i++) { 72 | run_test_simple(); 73 | } 74 | echo 'done'; 75 | 76 | --EXPECT-- 77 | string(7) "123aoeu" 78 | string(7) "123aoeu" 79 | string(7) "123aoeu" 80 | string(7) "123aoeu" 81 | string(7) "123aoeu" 82 | string(7) "123aoeu" 83 | string(7) "123aoeu" 84 | string(7) "123aoeu" 85 | string(7) "123aoeu" 86 | string(7) "123aoeu" 87 | string(7) "123aoeu" 88 | string(7) "123aoeu" 89 | string(7) "123aoeu" 90 | string(7) "123aoeu" 91 | string(7) "123aoeu" 92 | string(7) "123aoeu" 93 | string(7) "123aoeu" 94 | string(7) "123aoeu" 95 | string(7) "123aoeu" 96 | string(7) "123aoeu" 97 | string(7) "123aoeu" 98 | string(7) "123aoeu" 99 | string(7) "123aoeu" 100 | string(7) "123aoeu" 101 | string(7) "123aoeu" 102 | string(7) "123aoeu" 103 | string(7) "123aoeu" 104 | string(7) "123aoeu" 105 | string(7) "123aoeu" 106 | string(7) "123aoeu" 107 | done 108 | -------------------------------------------------------------------------------- /tests/apc_009.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: apc_delete_file test 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | apc.enabled=1 7 | apc.enable_cli=1 8 | apc.file_update_protection=0 9 | apc.stat=On 10 | report_memleaks=0 11 | --FILE-- 12 | 68 | ===DONE=== 69 | 70 | --CLEAN-- 71 | 75 | --EXPECTF-- 76 | apc_009.php Found File 77 | apc_009.php Not Found 78 | apc_009.php Not Found 79 | apc_009.php Not Found 80 | array(0) { 81 | } 82 | apc_009.php Found File 83 | apc_009-1.php Found File 84 | 85 | Parse error: syntax error, unexpected '!' in %s/apc_009-2.php on line 1 86 | 87 | Warning: apc_compile_file(): Error compiling apc_009-2.php in apc_compile_file. in %s/apc_009.php on line 32 88 | 89 | Warning: apc_compile_file(): Error compiling nofile.php in apc_compile_file. in %s/apc_009.php on line 32 90 | array(2) { 91 | ["apc_009-2.php"]=> 92 | int(-1) 93 | ["nofile.php"]=> 94 | int(-1) 95 | } 96 | apc_009.php Found File 97 | apc_009-1.php Found File 98 | apc_009-2.php Not Found 99 | nofile.php Not Found 100 | ===DONE=== 101 | -------------------------------------------------------------------------------- /tests/bug52144_functions.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #52144 (Error: Base lambda function for closure not found) 3 | --SKIPIF-- 4 | 70 | --EXPECT-- 71 | ----------------------------- 72 | string(6) "cached" 73 | ----------------------------- 74 | string(5) "dummy" 75 | string(11) "{closure}#1" 76 | string(11) "{closure}#2" 77 | ----------------------------- 78 | string(6) "cached" 79 | ----------------------------- 80 | string(5) "dummy" 81 | string(11) "{closure}#1" 82 | string(11) "{closure}#2" 83 | ----------------------------- 84 | string(6) "cached" 85 | ----------------------------- 86 | string(5) "dummy" 87 | string(11) "{closure}#1" 88 | string(11) "{closure}#2" 89 | ----------------------------- 90 | string(6) "cached" 91 | ----------------------------- 92 | string(5) "dummy" 93 | string(11) "{closure}#1" 94 | string(11) "{closure}#2" 95 | ----------------------------- 96 | string(6) "cached" 97 | ----------------------------- 98 | string(5) "dummy" 99 | string(11) "{closure}#1" 100 | string(11) "{closure}#2" 101 | -------------------------------------------------------------------------------- /apc_debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | | Arun C. Murthy | 17 | | Gopal Vijayaraghavan | 18 | +----------------------------------------------------------------------+ 19 | 20 | This software was contributed to PHP by Community Connect Inc. in 2002 21 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 22 | Future revisions and derivatives of this source code must acknowledge 23 | Community Connect Inc. as the original contributor of this module by 24 | leaving this note intact in the source code. 25 | 26 | All other licensing and usage conditions are those of the PHP Group. 27 | */ 28 | 29 | /* $Id: apc_debug.c 307048 2011-01-03 23:53:17Z kalle $ */ 30 | #include "apc.h" 31 | #include 32 | #include "zend.h" 33 | #include "zend_compile.h" 34 | 35 | #if defined(__DEBUG_APC__) 36 | 37 | /* keep track of vld_dump_oparray() signature */ 38 | typedef void (*vld_dump_f) (zend_op_array * TSRMLS_DC); 39 | 40 | #endif 41 | 42 | void dump(zend_op_array *op_array TSRMLS_DC) 43 | { 44 | #if defined(__DEBUG_APC__) 45 | vld_dump_f dump_op_array; 46 | DL_HANDLE handle = NULL; 47 | 48 | #ifdef PHP_WIN32 49 | handle = GetModuleHandle(NULL); 50 | 51 | if (!handle) { 52 | apc_warning("unable to fetch current module handle." TSRMLS_CC); 53 | } 54 | #endif 55 | 56 | dump_op_array = (vld_dump_f) DL_FETCH_SYMBOL(handle, "vld_dump_oparray"); 57 | 58 | #ifdef PHP_WIN32 59 | DL_UNLOAD(handle); 60 | #endif 61 | 62 | if(dump_op_array) { 63 | dump_op_array(op_array TSRMLS_CC); 64 | 65 | return; 66 | } 67 | 68 | apc_warning("vld is not installed or something even worse." TSRMLS_CC); 69 | #endif 70 | } 71 | -------------------------------------------------------------------------------- /apc_windows_srwlock_kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Pierre Joye | 16 | +----------------------------------------------------------------------+ 17 | */ 18 | /* $Id$ */ 19 | 20 | #ifndef APC_WINDOWS_CS_RWLOCK_H 21 | #define APC_WINDOWS_CS_RWLOCK_H 22 | 23 | #include "apc.h" 24 | 25 | #ifdef APC_SRWLOCK_KERNEL 26 | 27 | typedef struct _RTL_RWLOCK { 28 | RTL_CRITICAL_SECTION rtlCS; 29 | 30 | HANDLE hSharedReleaseSemaphore; 31 | UINT uSharedWaiters; 32 | 33 | HANDLE hExclusiveReleaseSemaphore; 34 | UINT uExclusiveWaiters; 35 | 36 | INT iNumberActive; 37 | HANDLE hOwningThreadId; 38 | DWORD dwTimeoutBoost; 39 | PVOID pDebugInfo; 40 | } RTL_RWLOCK, *LPRTL_RWLOCK; 41 | 42 | #define apc_windows_cs_rwlock_t RTL_RWLOCK 43 | 44 | struct apc_windows_cs_rwlock_t { 45 | CRITICAL_SECTION cs; 46 | LONG writers_waiting_count; 47 | LONG readers_waiting_count; 48 | DWORD active_writers_readers_flag; 49 | HANDLE ready_to_read; 50 | HANDLE ready_to_write; 51 | DWORD reader_races_lost; 52 | }; 53 | 54 | apc_windows_cs_rwlock_t *apc_windows_cs_create(apc_windows_cs_rwlock_t *lock TSRMLS_DC); 55 | void apc_windows_cs_destroy(apc_windows_cs_rwlock_t *lock); 56 | void apc_windows_cs_lock(apc_windows_cs_rwlock_t *lock TSRMLS_DC); 57 | void apc_windows_cs_rdlock(apc_windows_cs_rwlock_t *lock TSRMLS_DC); 58 | void apc_windows_cs_unlock_rd(apc_windows_cs_rwlock_t *lock TSRMLS_DC); 59 | void apc_windows_cs_unlock_wr(apc_windows_cs_rwlock_t *lock TSRMLS_DC); 60 | # if NONBLOCKING_LOCK_AVAILABLE==1 /* Only in win7/2008 */ 61 | zend_bool apc_pthreadrwlock_nonblocking_lock(apc_windows_cs_rwlock_t *lock TSRMLS_DC); 62 | # endif 63 | #endif 64 | 65 | #endif 66 | 67 | /* 68 | * Local variables: 69 | * tab-width: 4 70 | * c-basic-offset: 4 71 | * End: 72 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 73 | * vim<600: expandtab sw=4 ts=4 sts=4 74 | */ 75 | -------------------------------------------------------------------------------- /tests/apc54_013.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Closures basic test 3 | --SKIPIF-- 4 | say() . ' ' . \$f()); 30 | var_dump(\$f); 31 | FL; 32 | 33 | $args = array( 34 | 'apc.enabled=1', 35 | 'apc.enable_cli=1', 36 | ); 37 | 38 | server_start($file, $args); 39 | 40 | for ($i = 0; $i < 10; $i++) { 41 | run_test_simple(); 42 | } 43 | echo 'done'; 44 | 45 | --EXPECTF-- 46 | string(11) "hello world" 47 | object(Closure)#2 (0) { 48 | } 49 | string(11) "hello world" 50 | object(Closure)#2 (0) { 51 | } 52 | string(11) "hello world" 53 | object(Closure)#2 (0) { 54 | } 55 | string(11) "hello world" 56 | object(Closure)#2 (0) { 57 | } 58 | string(11) "hello world" 59 | object(Closure)#2 (0) { 60 | } 61 | string(11) "hello world" 62 | object(Closure)#2 (0) { 63 | } 64 | string(11) "hello world" 65 | object(Closure)#2 (0) { 66 | } 67 | string(11) "hello world" 68 | object(Closure)#2 (0) { 69 | } 70 | string(11) "hello world" 71 | object(Closure)#2 (0) { 72 | } 73 | string(11) "hello world" 74 | object(Closure)#2 (0) { 75 | } 76 | string(11) "hello world" 77 | object(Closure)#2 (0) { 78 | } 79 | string(11) "hello world" 80 | object(Closure)#2 (0) { 81 | } 82 | string(11) "hello world" 83 | object(Closure)#2 (0) { 84 | } 85 | string(11) "hello world" 86 | object(Closure)#2 (0) { 87 | } 88 | string(11) "hello world" 89 | object(Closure)#2 (0) { 90 | } 91 | string(11) "hello world" 92 | object(Closure)#2 (0) { 93 | } 94 | string(11) "hello world" 95 | object(Closure)#2 (0) { 96 | } 97 | string(11) "hello world" 98 | object(Closure)#2 (0) { 99 | } 100 | string(11) "hello world" 101 | object(Closure)#2 (0) { 102 | } 103 | string(11) "hello world" 104 | object(Closure)#2 (0) { 105 | } 106 | string(11) "hello world" 107 | object(Closure)#2 (0) { 108 | } 109 | string(11) "hello world" 110 | object(Closure)#2 (0) { 111 | } 112 | string(11) "hello world" 113 | object(Closure)#2 (0) { 114 | } 115 | string(11) "hello world" 116 | object(Closure)#2 (0) { 117 | } 118 | string(11) "hello world" 119 | object(Closure)#2 (0) { 120 | } 121 | string(11) "hello world" 122 | object(Closure)#2 (0) { 123 | } 124 | string(11) "hello world" 125 | object(Closure)#2 (0) { 126 | } 127 | string(11) "hello world" 128 | object(Closure)#2 (0) { 129 | } 130 | string(11) "hello world" 131 | object(Closure)#2 (0) { 132 | } 133 | string(11) "hello world" 134 | object(Closure)#2 (0) { 135 | } 136 | done 137 | -------------------------------------------------------------------------------- /tests/apc54_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: interned strings same method names (php 5.4 nts) 3 | --SKIPIF-- 4 | hello(); 39 | \$two->hello(); 40 | hello(); 41 | FL; 42 | 43 | $args = array( 44 | 'apc.enabled=1', 45 | 'apc.enable_cli=1', 46 | 'apc.stat=0', 47 | ); 48 | 49 | server_start($file, $args); 50 | 51 | list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); 52 | $port = intval($port)?:80; 53 | 54 | for ($i = 0; $i < 10; $i++) { 55 | run_test_simple(); 56 | } 57 | echo 'done'; 58 | 59 | --EXPECT-- 60 | hello class one 61 | hello class two 62 | hello function 63 | hello class one 64 | hello class two 65 | hello function 66 | hello class one 67 | hello class two 68 | hello function 69 | hello class one 70 | hello class two 71 | hello function 72 | hello class one 73 | hello class two 74 | hello function 75 | hello class one 76 | hello class two 77 | hello function 78 | hello class one 79 | hello class two 80 | hello function 81 | hello class one 82 | hello class two 83 | hello function 84 | hello class one 85 | hello class two 86 | hello function 87 | hello class one 88 | hello class two 89 | hello function 90 | hello class one 91 | hello class two 92 | hello function 93 | hello class one 94 | hello class two 95 | hello function 96 | hello class one 97 | hello class two 98 | hello function 99 | hello class one 100 | hello class two 101 | hello function 102 | hello class one 103 | hello class two 104 | hello function 105 | hello class one 106 | hello class two 107 | hello function 108 | hello class one 109 | hello class two 110 | hello function 111 | hello class one 112 | hello class two 113 | hello function 114 | hello class one 115 | hello class two 116 | hello function 117 | hello class one 118 | hello class two 119 | hello function 120 | hello class one 121 | hello class two 122 | hello function 123 | hello class one 124 | hello class two 125 | hello function 126 | hello class one 127 | hello class two 128 | hello function 129 | hello class one 130 | hello class two 131 | hello function 132 | hello class one 133 | hello class two 134 | hello function 135 | hello class one 136 | hello class two 137 | hello function 138 | hello class one 139 | hello class two 140 | hello function 141 | hello class one 142 | hello class two 143 | hello function 144 | hello class one 145 | hello class two 146 | hello function 147 | hello class one 148 | hello class two 149 | hello function 150 | done 151 | -------------------------------------------------------------------------------- /tests/apc54_bug62699.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #62699 Wrong behavior with traits 3 | --SKIPIF-- 4 | test(); 34 | \$foo->test2(); 35 | \$foo->tast(); 36 | FL; 37 | 38 | $args = array( 39 | 'apc.enabled=1', 40 | 'apc.cache_by_default=1', 41 | 'apc.enable_cli=1', 42 | 'apc.shm_segments=1', 43 | 'apc.optimization=0', 44 | 'apc.shm_size=384M', 45 | 'apc.ttl=0', 46 | 'apc.user_ttl=0', 47 | 'apc.num_files_hint=4096', 48 | 'apc.canonicalize=0', 49 | 'apc.write_lock=1', 50 | ); 51 | 52 | server_start($file, $args); 53 | 54 | for ($i = 0; $i < 10; $i++) { 55 | run_test_simple(); 56 | } 57 | echo 'done'; 58 | --EXPECT-- 59 | string(3) "Foo" 60 | string(1) "A" 61 | string(1) "A" 62 | string(3) "Foo" 63 | string(1) "A" 64 | string(1) "A" 65 | string(3) "Foo" 66 | string(1) "A" 67 | string(1) "A" 68 | string(3) "Foo" 69 | string(1) "A" 70 | string(1) "A" 71 | string(3) "Foo" 72 | string(1) "A" 73 | string(1) "A" 74 | string(3) "Foo" 75 | string(1) "A" 76 | string(1) "A" 77 | string(3) "Foo" 78 | string(1) "A" 79 | string(1) "A" 80 | string(3) "Foo" 81 | string(1) "A" 82 | string(1) "A" 83 | string(3) "Foo" 84 | string(1) "A" 85 | string(1) "A" 86 | string(3) "Foo" 87 | string(1) "A" 88 | string(1) "A" 89 | string(3) "Foo" 90 | string(1) "A" 91 | string(1) "A" 92 | string(3) "Foo" 93 | string(1) "A" 94 | string(1) "A" 95 | string(3) "Foo" 96 | string(1) "A" 97 | string(1) "A" 98 | string(3) "Foo" 99 | string(1) "A" 100 | string(1) "A" 101 | string(3) "Foo" 102 | string(1) "A" 103 | string(1) "A" 104 | string(3) "Foo" 105 | string(1) "A" 106 | string(1) "A" 107 | string(3) "Foo" 108 | string(1) "A" 109 | string(1) "A" 110 | string(3) "Foo" 111 | string(1) "A" 112 | string(1) "A" 113 | string(3) "Foo" 114 | string(1) "A" 115 | string(1) "A" 116 | string(3) "Foo" 117 | string(1) "A" 118 | string(1) "A" 119 | string(3) "Foo" 120 | string(1) "A" 121 | string(1) "A" 122 | string(3) "Foo" 123 | string(1) "A" 124 | string(1) "A" 125 | string(3) "Foo" 126 | string(1) "A" 127 | string(1) "A" 128 | string(3) "Foo" 129 | string(1) "A" 130 | string(1) "A" 131 | string(3) "Foo" 132 | string(1) "A" 133 | string(1) "A" 134 | string(3) "Foo" 135 | string(1) "A" 136 | string(1) "A" 137 | string(3) "Foo" 138 | string(1) "A" 139 | string(1) "A" 140 | string(3) "Foo" 141 | string(1) "A" 142 | string(1) "A" 143 | string(3) "Foo" 144 | string(1) "A" 145 | string(1) "A" 146 | string(3) "Foo" 147 | string(1) "A" 148 | string(1) "A" 149 | done 150 | -------------------------------------------------------------------------------- /apc_php.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | | George Schlossnagle | 17 | | Rasmus Lerdorf | 18 | | Arun C. Murthy | 19 | | Gopal Vijayaraghavan | 20 | +----------------------------------------------------------------------+ 21 | 22 | This software was contributed to PHP by Community Connect Inc. in 2002 23 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 24 | Future revisions and derivatives of this source code must acknowledge 25 | Community Connect Inc. as the original contributor of this module by 26 | leaving this note intact in the source code. 27 | 28 | All other licensing and usage conditions are those of the PHP Group. 29 | 30 | */ 31 | 32 | /* $Id: apc_php.h 328674 2012-12-05 09:58:27Z ab $ */ 33 | 34 | #ifndef APC_PHP_H 35 | #define APC_PHP_H 36 | 37 | /* 38 | * The purpose of this header file is to include all PHP and Zend headers that 39 | * are typically needed elsewhere in APC. This makes it easy to insure that 40 | * all required headers are available. 41 | */ 42 | 43 | #include "php.h" 44 | #include "zend.h" 45 | #include "zend_API.h" 46 | #include "zend_compile.h" 47 | #include "zend_hash.h" 48 | #include "zend_extensions.h" 49 | 50 | #if ZEND_MODULE_API_NO >= 20121204 51 | #define ZEND_ENGINE_2_5 52 | #endif 53 | #if ZEND_MODULE_API_NO >= 20100409 54 | #define ZEND_ENGINE_2_4 55 | #endif 56 | #if ZEND_MODULE_API_NO > 20060613 57 | #define ZEND_ENGINE_2_3 58 | #endif 59 | #if ZEND_MODULE_API_NO > 20050922 60 | #define ZEND_ENGINE_2_2 61 | #endif 62 | #if ZEND_MODULE_API_NO > 20050921 63 | #define ZEND_ENGINE_2_1 64 | #endif 65 | #ifdef ZEND_ENGINE_2_1 66 | #include "zend_vm.h" 67 | #endif 68 | 69 | #ifndef IS_CONSTANT_TYPE_MASK 70 | #define IS_CONSTANT_TYPE_MASK (~IS_CONSTANT_INDEX) 71 | #endif 72 | 73 | #include "rfc1867.h" 74 | 75 | #endif 76 | 77 | /* 78 | * Local variables: 79 | * tab-width: 4 80 | * c-basic-offset: 4 81 | * End: 82 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 83 | * vim<600: expandtab sw=4 ts=4 sts=4 84 | */ 85 | -------------------------------------------------------------------------------- /tests/bug61398_2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #61398 APC fails to find class methods (based on ext/standard/tests/file/fopencookie.phpt) 3 | --SKIPIF-- 4 | data, \$this->position, \$count); 32 | \$this->position += strlen(\$ret); 33 | return \$ret; 34 | } 35 | 36 | function stream_tell() 37 | { 38 | return \$this->position; 39 | } 40 | 41 | function stream_eof() 42 | { 43 | return \$this->position >= strlen(\$this->data); 44 | } 45 | 46 | function stream_seek(\$offset, \$whence) 47 | { 48 | switch(\$whence) { 49 | case SEEK_SET: 50 | if (\$offset < strlen(\$this->data) && \$offset >= 0) { 51 | \$this->position = \$offset; 52 | return true; 53 | } else { 54 | return false; 55 | } 56 | break; 57 | case SEEK_CUR: 58 | if (\$offset >= 0) { 59 | \$this->position += \$offset; 60 | return true; 61 | } else { 62 | return false; 63 | } 64 | break; 65 | case SEEK_END: 66 | if (strlen(\$this->data) + \$offset >= 0) { 67 | \$this->position = strlen(\$this->data) + \$offset; 68 | return true; 69 | } else { 70 | return false; 71 | } 72 | break; 73 | default: 74 | return false; 75 | } 76 | } 77 | function stream_stat() { 78 | return array('size' => strlen(\$this->data)); 79 | } 80 | } 81 | stream_wrapper_register("cookietest", "userstream"); 82 | include("cookietest://foo"); 83 | FL; 84 | 85 | server_start($file, $args); 86 | 87 | for ($i = 0; $i < 10; $i++) { 88 | run_test_simple(); 89 | } 90 | echo 'done'; 91 | ?> 92 | --EXPECT-- 93 | If you can read this, it worked 94 | If you can read this, it worked 95 | If you can read this, it worked 96 | If you can read this, it worked 97 | If you can read this, it worked 98 | If you can read this, it worked 99 | If you can read this, it worked 100 | If you can read this, it worked 101 | If you can read this, it worked 102 | If you can read this, it worked 103 | If you can read this, it worked 104 | If you can read this, it worked 105 | If you can read this, it worked 106 | If you can read this, it worked 107 | If you can read this, it worked 108 | If you can read this, it worked 109 | If you can read this, it worked 110 | If you can read this, it worked 111 | If you can read this, it worked 112 | If you can read this, it worked 113 | If you can read this, it worked 114 | If you can read this, it worked 115 | If you can read this, it worked 116 | If you can read this, it worked 117 | If you can read this, it worked 118 | If you can read this, it worked 119 | If you can read this, it worked 120 | If you can read this, it worked 121 | If you can read this, it worked 122 | If you can read this, it worked 123 | done 124 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------- 2 | The PHP License, version 3.01 3 | Copyright (c) 1999 - 2011 The PHP Group. All rights reserved. 4 | -------------------------------------------------------------------- 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, is permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in 15 | the documentation and/or other materials provided with the 16 | distribution. 17 | 18 | 3. The name "PHP" must not be used to endorse or promote products 19 | derived from this software without prior written permission. For 20 | written permission, please contact group@php.net. 21 | 22 | 4. Products derived from this software may not be called "PHP", nor 23 | may "PHP" appear in their name, without prior written permission 24 | from group@php.net. You may indicate that your software works in 25 | conjunction with PHP by saying "Foo for PHP" instead of calling 26 | it "PHP Foo" or "phpfoo" 27 | 28 | 5. The PHP Group may publish revised and/or new versions of the 29 | license from time to time. Each version will be given a 30 | distinguishing version number. 31 | Once covered code has been published under a particular version 32 | of the license, you may always continue to use it under the terms 33 | of that version. You may also choose to use such covered code 34 | under the terms of any subsequent version of the license 35 | published by the PHP Group. No one other than the PHP Group has 36 | the right to modify the terms applicable to covered code created 37 | under this License. 38 | 39 | 6. Redistributions of any form whatsoever must retain the following 40 | acknowledgment: 41 | "This product includes PHP software, freely available from 42 | ". 43 | 44 | THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND 45 | ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 46 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 47 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP 48 | DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 49 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 50 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 51 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 53 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 54 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 55 | OF THE POSSIBILITY OF SUCH DAMAGE. 56 | 57 | -------------------------------------------------------------------- 58 | 59 | This software consists of voluntary contributions made by many 60 | individuals on behalf of the PHP Group. 61 | 62 | The PHP Group can be contacted via Email at group@php.net. 63 | 64 | For more information on the PHP Group and the PHP project, 65 | please see . 66 | 67 | PHP includes the Zend Engine, freely available at 68 | . 69 | -------------------------------------------------------------------------------- /apc_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | | George Schlossnagle | 17 | | Rasmus Lerdorf | 18 | | Arun C. Murthy | 19 | | Gopal Vijayaraghavan | 20 | +----------------------------------------------------------------------+ 21 | 22 | This software was contributed to PHP by Community Connect Inc. in 2002 23 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 24 | Future revisions and derivatives of this source code must acknowledge 25 | Community Connect Inc. as the original contributor of this module by 26 | leaving this note intact in the source code. 27 | 28 | All other licensing and usage conditions are those of the PHP Group. 29 | 30 | */ 31 | 32 | /* $Id: apc_main.h 308594 2011-02-23 12:35:33Z gopalv $ */ 33 | 34 | #ifndef APC_MAIN_H 35 | #define APC_MAIN_H 36 | 37 | #include "apc_pool.h" 38 | #include "apc_serializer.h" 39 | 40 | /* 41 | * This module provides the primary interface between PHP and APC. 42 | */ 43 | 44 | extern int apc_module_init(int module_number TSRMLS_DC); 45 | extern int apc_module_shutdown(TSRMLS_D); 46 | extern int apc_process_init(int module_number TSRMLS_DC); 47 | extern int apc_process_shutdown(TSRMLS_D); 48 | extern int apc_request_init(TSRMLS_D); 49 | extern int apc_request_shutdown(TSRMLS_D); 50 | 51 | typedef enum _apc_copy_type { 52 | APC_NO_COPY = 0, 53 | APC_COPY_IN_OPCODE, 54 | APC_COPY_OUT_OPCODE, 55 | APC_COPY_IN_USER, 56 | APC_COPY_OUT_USER 57 | } apc_copy_type; 58 | 59 | typedef struct _apc_context_t 60 | { 61 | apc_pool *pool; 62 | apc_copy_type copy; 63 | unsigned int force_update:1; 64 | } apc_context_t; 65 | 66 | /* {{{ struct apc_serializer_t */ 67 | typedef struct apc_serializer_t apc_serializer_t; 68 | struct apc_serializer_t { 69 | const char *name; 70 | apc_serialize_t serialize; 71 | apc_unserialize_t unserialize; 72 | void *config; 73 | }; 74 | /* }}} */ 75 | 76 | apc_serializer_t* apc_get_serializers(TSRMLS_D); 77 | apc_serializer_t* apc_find_serializer(const char* name TSRMLS_DC); 78 | 79 | #endif 80 | 81 | /* 82 | * Local variables: 83 | * tab-width: 4 84 | * c-basic-offset: 4 85 | * End: 86 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 87 | * vim<600: expandtab sw=4 ts=4 sts=4 88 | */ 89 | -------------------------------------------------------------------------------- /tests/apc54_019.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #59907 Issue with custom stream wrapper, include and APC 3 | --SKIPIF-- 4 | path = \$path; 24 | 25 | return true; 26 | } 27 | 28 | public function stream_read(\$count) { 29 | 30 | \$ret = substr(self::\$data[\$this->path], \$this->position, \$count); 31 | \$this->position += strlen(\$ret); 32 | 33 | return \$ret; 34 | } 35 | 36 | public function stream_write(\$data) { 37 | 38 | self::\$data[\$this->path] = \$data; 39 | 40 | return strlen(\$data); 41 | } 42 | 43 | public function stream_tell() { 44 | 45 | return \$this->position; 46 | } 47 | 48 | public function stream_eof() { 49 | 50 | return \$this->position >= strlen(self::\$data[\$this->path]); 51 | } 52 | 53 | public function url_stat(\$path, \$flags) { 54 | 55 | return \$this->stream_stat(); 56 | } 57 | 58 | public function stream_stat() { 59 | 60 | \$stat = array( 61 | 'dev' => 1, 62 | 'ino' => 1, 63 | 'mode' => 1, 64 | 'nlink' => 1, 65 | 'uid' => 1, 66 | 'gid' => 1, 67 | 'rdev' => 1, 68 | 'size' => 1, 69 | 'atime' => 1, 70 | 'mtime' => 1, 71 | 'ctime' => 1, 72 | 'blksize' => 1, 73 | 'blocks' => 1 74 | ); 75 | 76 | return array_merge(array_values(\$stat), \$stat); 77 | } 78 | } 79 | 80 | stream_wrapper_register(StreamWrapper::PROTOCOL, 'StreamWrapper'); 81 | 82 | \$class1 = ' | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: $ */ 21 | 22 | #ifndef APC_SERIALIZER_H 23 | #define APC_SERIALIZER_H 24 | 25 | /* this is a shipped .h file, do not include any other header in this file */ 26 | #define APC_SERIALIZER_NAME(module) module##_apc_serializer 27 | #define APC_UNSERIALIZER_NAME(module) module##_apc_unserializer 28 | 29 | #define APC_SERIALIZER_ARGS unsigned char **buf, size_t *buf_len, const zval *value, void *config TSRMLS_DC 30 | #define APC_UNSERIALIZER_ARGS zval **value, unsigned char *buf, size_t buf_len, void *config TSRMLS_DC 31 | 32 | typedef int (*apc_serialize_t)(APC_SERIALIZER_ARGS); 33 | typedef int (*apc_unserialize_t)(APC_UNSERIALIZER_ARGS); 34 | 35 | typedef int (*apc_register_serializer_t)(const char* name, 36 | apc_serialize_t serialize, 37 | apc_unserialize_t unserialize, 38 | void *config TSRMLS_DC); 39 | 40 | /* 41 | * ABI version for constant hooks. Increment this any time you make any changes 42 | * to any function in this file. 43 | */ 44 | #define APC_SERIALIZER_ABI "0" 45 | #define APC_SERIALIZER_CONSTANT "\000apc_register_serializer-" APC_SERIALIZER_ABI 46 | 47 | #if !defined(APC_UNUSED) 48 | # if defined(__GNUC__) 49 | # define APC_UNUSED __attribute__((unused)) 50 | # else 51 | # define APC_UNUSED 52 | # endif 53 | #endif 54 | 55 | static APC_UNUSED int apc_register_serializer(const char* name, 56 | apc_serialize_t serialize, 57 | apc_unserialize_t unserialize, 58 | void *config TSRMLS_DC) 59 | { 60 | zval apc_magic_constant; 61 | int retval = 0; 62 | 63 | /* zend_get_constant will return 1 on success, otherwise apc_magic_constant wouldn't be touched at all */ 64 | if (zend_get_constant(APC_SERIALIZER_CONSTANT, sizeof(APC_SERIALIZER_CONSTANT)-1, &apc_magic_constant TSRMLS_CC)) { 65 | apc_register_serializer_t register_func = (apc_register_serializer_t)(Z_LVAL(apc_magic_constant)); 66 | if(register_func) { 67 | retval = register_func(name, serialize, unserialize, NULL TSRMLS_CC); 68 | } 69 | zval_dtor(&apc_magic_constant); 70 | } 71 | 72 | return retval; 73 | } 74 | 75 | #endif 76 | 77 | /* 78 | * Local variables: 79 | * tab-width: 4 80 | * c-basic-offset: 4 81 | * End: 82 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 83 | * vim<600: expandtab sw=4 ts=4 sts=4 84 | */ 85 | -------------------------------------------------------------------------------- /apc_stack.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | +----------------------------------------------------------------------+ 17 | 18 | This software was contributed to PHP by Community Connect Inc. in 2002 19 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 20 | Future revisions and derivatives of this source code must acknowledge 21 | Community Connect Inc. as the original contributor of this module by 22 | leaving this note intact in the source code. 23 | 24 | All other licensing and usage conditions are those of the PHP Group. 25 | 26 | */ 27 | 28 | /* $Id: apc_stack.c 307048 2011-01-03 23:53:17Z kalle $ */ 29 | 30 | #include "apc.h" 31 | #include "apc_stack.h" 32 | 33 | struct apc_stack_t { 34 | void** data; 35 | int capacity; 36 | int size; 37 | }; 38 | 39 | apc_stack_t* apc_stack_create(int size_hint TSRMLS_DC) 40 | { 41 | apc_stack_t* stack = (apc_stack_t*) apc_emalloc(sizeof(apc_stack_t) TSRMLS_CC); 42 | 43 | stack->capacity = (size_hint > 0) ? size_hint : 10; 44 | stack->size = 0; 45 | stack->data = (void**) apc_emalloc(sizeof(void*) * stack->capacity TSRMLS_CC); 46 | 47 | return stack; 48 | } 49 | 50 | void apc_stack_destroy(apc_stack_t* stack TSRMLS_DC) 51 | { 52 | if (stack != NULL) { 53 | apc_efree(stack->data TSRMLS_CC); 54 | apc_efree(stack TSRMLS_CC); 55 | } 56 | } 57 | 58 | void apc_stack_clear(apc_stack_t* stack) 59 | { 60 | assert(stack != NULL); 61 | stack->size = 0; 62 | } 63 | 64 | void apc_stack_push(apc_stack_t* stack, void* item TSRMLS_DC) 65 | { 66 | assert(stack != NULL); 67 | if (stack->size == stack->capacity) { 68 | stack->capacity *= 2; 69 | stack->data = apc_erealloc(stack->data, sizeof(void*)*stack->capacity TSRMLS_CC); 70 | } 71 | stack->data[stack->size++] = item; 72 | } 73 | 74 | void* apc_stack_pop(apc_stack_t* stack) 75 | { 76 | assert(stack != NULL && stack->size > 0); 77 | return stack->data[--stack->size]; 78 | } 79 | 80 | void* apc_stack_top(apc_stack_t* stack) 81 | { 82 | assert(stack != NULL && stack->size > 0); 83 | return stack->data[stack->size-1]; 84 | } 85 | 86 | void* apc_stack_get(apc_stack_t* stack, int n) 87 | { 88 | assert(stack != NULL && stack->size > n); 89 | return stack->data[n]; 90 | } 91 | 92 | int apc_stack_size(apc_stack_t* stack) 93 | { 94 | assert(stack != NULL); 95 | return stack->size; 96 | } 97 | 98 | 99 | /* 100 | * Local variables: 101 | * tab-width: 4 102 | * c-basic-offset: 4 103 | * End: 104 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 105 | * vim<600: expandtab sw=4 ts=4 sts=4 106 | */ 107 | -------------------------------------------------------------------------------- /tests/apc54_017.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Test use trait properties in a class and its parent (php 5.4) 3 | --SKIPIF-- 4 | me . ' | ' . \$this->one . ' | ' . \$this->two . ' | ' . \$this->three; 37 | } 38 | } 39 | 40 | \$w = new World; 41 | var_dump(\$w->loud()); 42 | FL; 43 | 44 | $args = array( 45 | 'apc.cache_by_default=On', 46 | 'apc.canonicalize=On', 47 | 'apc.coredump_unmap=Off', 48 | 'apc.enable_cli=On', 49 | 'apc.enabled=On', 50 | 'apc.file_md5=Off', 51 | 'apc.file_update_protection=2', 52 | 'apc.filters=no', 53 | 'apc.gc_ttl=3600', 54 | 'apc.include_once_override=Off', 55 | 'apc.lazy_classes=Off', 56 | 'apc.lazy_functions=Off', 57 | 'apc.max_file_size=1M', 58 | 'apc.mmap_file_mask=no', 59 | 'apc.num_files_hint=1000', 60 | 'apc.preload_path=no', 61 | 'apc.report_autofilter=Off', 62 | 'apc.rfc1867=Off', 63 | 'apc.rfc1867_freq=0', 64 | 'apc.rfc1867_name=APC_UPLOAD_PROGRESS', 65 | 'apc.rfc1867_prefix=upload_', 66 | 'apc.rfc1867_ttl=3600', 67 | 'apc.serializer=default', 68 | 'apc.shm_segments=1', 69 | 'apc.shm_size=128M', 70 | 'apc.shm_strings_buffer=4M', 71 | 'apc.slam_defense=On', 72 | 'apc.stat=On', 73 | 'apc.stat_ctime=Off', 74 | 'apc.ttl=0', 75 | 'apc.use_request_time=On', 76 | 'apc.user_entries_hint=4096', 77 | 'apc.user_ttl=0', 78 | 'apc.write_lock=On', 79 | ); 80 | 81 | server_start($file, $args); 82 | 83 | for ($i = 0; $i < 10; $i++) { 84 | run_test_simple(); 85 | } 86 | echo 'done'; 87 | 88 | --EXPECT-- 89 | string(36) "self | trait | parent | parent trait" 90 | string(36) "self | trait | parent | parent trait" 91 | string(36) "self | trait | parent | parent trait" 92 | string(36) "self | trait | parent | parent trait" 93 | string(36) "self | trait | parent | parent trait" 94 | string(36) "self | trait | parent | parent trait" 95 | string(36) "self | trait | parent | parent trait" 96 | string(36) "self | trait | parent | parent trait" 97 | string(36) "self | trait | parent | parent trait" 98 | string(36) "self | trait | parent | parent trait" 99 | string(36) "self | trait | parent | parent trait" 100 | string(36) "self | trait | parent | parent trait" 101 | string(36) "self | trait | parent | parent trait" 102 | string(36) "self | trait | parent | parent trait" 103 | string(36) "self | trait | parent | parent trait" 104 | string(36) "self | trait | parent | parent trait" 105 | string(36) "self | trait | parent | parent trait" 106 | string(36) "self | trait | parent | parent trait" 107 | string(36) "self | trait | parent | parent trait" 108 | string(36) "self | trait | parent | parent trait" 109 | string(36) "self | trait | parent | parent trait" 110 | string(36) "self | trait | parent | parent trait" 111 | string(36) "self | trait | parent | parent trait" 112 | string(36) "self | trait | parent | parent trait" 113 | string(36) "self | trait | parent | parent trait" 114 | string(36) "self | trait | parent | parent trait" 115 | string(36) "self | trait | parent | parent trait" 116 | string(36) "self | trait | parent | parent trait" 117 | string(36) "self | trait | parent | parent trait" 118 | string(36) "self | trait | parent | parent trait" 119 | done 120 | -------------------------------------------------------------------------------- /apc_php_pcre.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC/PHP Version 5 | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 1997-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Author: Andrei Zmievski | 16 | +----------------------------------------------------------------------+ 17 | */ 18 | 19 | /* $Id: apc_php_pcre.h 307048 2011-01-03 23:53:17Z kalle $ */ 20 | 21 | #ifndef PHP_PCRE_H 22 | #define PHP_PCRE_H 23 | 24 | #if HAVE_PCRE || HAVE_BUNDLED_PCRE 25 | 26 | #if HAVE_BUNDLED_PCRE 27 | #include "ext/pcre/pcrelib/pcre.h" 28 | #else 29 | #include "pcre.h" 30 | #endif 31 | 32 | #if HAVE_LOCALE_H 33 | #include 34 | #endif 35 | 36 | PHP_FUNCTION(preg_match); 37 | PHP_FUNCTION(preg_match_all); 38 | PHP_FUNCTION(preg_replace); 39 | PHP_FUNCTION(preg_replace_callback); 40 | PHP_FUNCTION(preg_split); 41 | PHP_FUNCTION(preg_quote); 42 | PHP_FUNCTION(preg_grep); 43 | 44 | PHPAPI char *php_pcre_replace(char *regex, int regex_len, char *subject, int subject_len, zval *replace_val, int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC); 45 | PHPAPI pcre* pcre_get_compiled_regex(char *regex, pcre_extra **extra, int *options TSRMLS_DC); 46 | PHPAPI pcre* pcre_get_compiled_regex_ex(char *regex, pcre_extra **extra, int *preg_options, int *coptions TSRMLS_DC); 47 | 48 | extern zend_module_entry pcre_module_entry; 49 | #define pcre_module_ptr &pcre_module_entry 50 | 51 | typedef struct { 52 | pcre *re; 53 | pcre_extra *extra; 54 | int preg_options; 55 | #if HAVE_SETLOCALE 56 | char *locale; 57 | unsigned const char *tables; 58 | #endif 59 | int compile_options; 60 | int refcount; 61 | } pcre_cache_entry; 62 | 63 | PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len TSRMLS_DC); 64 | 65 | PHPAPI void php_pcre_match_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, 66 | zval *subpats, int global, int use_flags, long flags, long start_offset TSRMLS_DC); 67 | 68 | PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, 69 | int is_callable_replace, int *result_len, int limit, int *replace_count TSRMLS_DC); 70 | 71 | PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value, 72 | long limit_val, long flags TSRMLS_DC); 73 | 74 | PHPAPI void php_pcre_grep_impl( pcre_cache_entry *pce, zval *input, zval *return_value, 75 | long flags TSRMLS_DC); 76 | 77 | ZEND_BEGIN_MODULE_GLOBALS(pcre) 78 | HashTable pcre_cache; 79 | long backtrack_limit; 80 | long recursion_limit; 81 | int error_code; 82 | ZEND_END_MODULE_GLOBALS(pcre) 83 | 84 | #ifdef ZTS 85 | # define PCRE_G(v) TSRMG(pcre_globals_id, zend_pcre_globals *, v) 86 | #else 87 | # define PCRE_G(v) (pcre_globals.v) 88 | #endif 89 | 90 | #else 91 | 92 | #define pcre_module_ptr NULL 93 | 94 | #endif /* HAVE_PCRE || HAVE_BUNDLED_PCRE */ 95 | 96 | #define phpext_pcre_ptr pcre_module_ptr 97 | 98 | #endif /* PHP_PCRE_H */ 99 | -------------------------------------------------------------------------------- /apc_sma.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | +----------------------------------------------------------------------+ 17 | 18 | This software was contributed to PHP by Community Connect Inc. in 2002 19 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 20 | Future revisions and derivatives of this source code must acknowledge 21 | Community Connect Inc. as the original contributor of this module by 22 | leaving this note intact in the source code. 23 | 24 | All other licensing and usage conditions are those of the PHP Group. 25 | 26 | */ 27 | 28 | /* $Id: apc_sma.h 307048 2011-01-03 23:53:17Z kalle $ */ 29 | 30 | #ifndef APC_SMA_H 31 | #define APC_SMA_H 32 | 33 | #define ALLOC_DISTRIBUTION 0 34 | 35 | #include "apc.h" 36 | 37 | /* Simple shared memory allocator */ 38 | 39 | typedef struct _apc_segment_t apc_segment_t; 40 | 41 | struct _apc_segment_t { 42 | size_t size; 43 | void* shmaddr; 44 | #ifdef APC_MEMPROTECT 45 | void* roaddr; 46 | #endif 47 | }; 48 | 49 | extern void apc_sma_init(int numseg, size_t segsize, char *mmap_file_mask TSRMLS_DC); 50 | extern void apc_sma_cleanup(TSRMLS_D); 51 | extern void* apc_sma_malloc(size_t size TSRMLS_DC); 52 | extern void* apc_sma_malloc_ex(size_t size, size_t fragment, size_t* allocated TSRMLS_DC); 53 | extern void* apc_sma_realloc(void* p, size_t size TSRMLS_DC); 54 | extern char* apc_sma_strdup(const char *s TSRMLS_DC); 55 | extern void apc_sma_free(void* p TSRMLS_DC); 56 | #if ALLOC_DISTRIBUTION 57 | extern size_t *apc_sma_get_alloc_distribution(); 58 | #endif 59 | 60 | extern void* apc_sma_protect(void *p); 61 | extern void* apc_sma_unprotect(void *p); 62 | 63 | /* {{{ struct definition: apc_sma_link_t */ 64 | typedef struct apc_sma_link_t apc_sma_link_t; 65 | struct apc_sma_link_t { 66 | long size; /* size of this free block */ 67 | long offset; /* offset in segment of this block */ 68 | apc_sma_link_t* next; /* link to next free block */ 69 | }; 70 | /* }}} */ 71 | 72 | /* {{{ struct definition: apc_sma_info_t */ 73 | typedef struct apc_sma_info_t apc_sma_info_t; 74 | struct apc_sma_info_t { 75 | int num_seg; /* number of shared memory segments */ 76 | size_t seg_size; /* size of each shared memory segment */ 77 | apc_sma_link_t** list; /* there is one list per segment */ 78 | }; 79 | /* }}} */ 80 | 81 | extern apc_sma_info_t* apc_sma_info(zend_bool limited TSRMLS_DC); 82 | extern void apc_sma_free_info(apc_sma_info_t* info TSRMLS_DC); 83 | 84 | extern size_t apc_sma_get_avail_mem(); 85 | extern zend_bool apc_sma_get_avail_size(size_t size); 86 | extern void apc_sma_check_integrity(); 87 | 88 | /* {{{ ALIGNWORD: pad up x, aligned to the system's word boundary */ 89 | typedef union { void* p; int i; long l; double d; void (*f)(); } apc_word_t; 90 | #define ALIGNSIZE(x, size) ((size) * (1 + (((x)-1)/(size)))) 91 | #define ALIGNWORD(x) ALIGNSIZE(x, sizeof(apc_word_t)) 92 | /* }}} */ 93 | 94 | #endif 95 | 96 | /* 97 | * Local variables: 98 | * tab-width: 4 99 | * c-basic-offset: 4 100 | * End: 101 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 102 | * vim<600: expandtab sw=4 ts=4 sts=4 103 | */ 104 | -------------------------------------------------------------------------------- /tests/apc54_004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #62456 Incorrect description of notice variation 1 (php 5.4 nts) 3 | --SKIPIF-- 4 | qwerty; 17 | FL; 18 | 19 | $args = array( 20 | 'apc.enabled=1', 21 | 'apc.enable_cli=1', 22 | ); 23 | 24 | server_start($file, $args); 25 | 26 | for ($i = 0; $i < 10; $i++) { 27 | run_test_simple(); 28 | } 29 | echo 'done'; 30 | 31 | 32 | --EXPECTF-- 33 |
34 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
35 |
36 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
37 |
38 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
39 |
40 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
41 |
42 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
43 |
44 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
45 |
46 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
47 |
48 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
49 |
50 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
51 |
52 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
53 |
54 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
55 |
56 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
57 |
58 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
59 |
60 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
61 |
62 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
63 |
64 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
65 |
66 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
67 |
68 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
69 |
70 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
71 |
72 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
73 |
74 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
75 |
76 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
77 |
78 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
79 |
80 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
81 |
82 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
83 |
84 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
85 |
86 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
87 |
88 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
89 |
90 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
91 |
92 | Notice: Undefined property: stdClass::$qwerty in %s/tests/index.php on line 3
93 | done 94 | -------------------------------------------------------------------------------- /apc_pool.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt. | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Gopal Vijayaraghavan | 16 | +----------------------------------------------------------------------+ 17 | 18 | This software was contributed to PHP by Yahoo! Inc. in 2008. 19 | 20 | Future revisions and derivatives of this source code must acknowledge 21 | Yahoo! Inc. as the original contributor of this module by 22 | leaving this note intact in the source code. 23 | 24 | All other licensing and usage conditions are those of the PHP Group. 25 | 26 | */ 27 | 28 | /* $Id: apc_pool.h 307048 2011-01-03 23:53:17Z kalle $ */ 29 | 30 | #ifndef APC_POOL_H 31 | #define APC_POOL_H 32 | 33 | #include "apc.h" 34 | #include "apc_sma.h" 35 | 36 | /* #define APC_POOL_DEBUG 1 */ 37 | 38 | typedef enum { 39 | APC_UNPOOL = 0x0, 40 | APC_SMALL_POOL = 0x1, 41 | APC_MEDIUM_POOL = 0x2, 42 | APC_LARGE_POOL = 0x3, 43 | APC_POOL_SIZE_MASK = 0x7, /* waste a bit */ 44 | #if APC_POOL_DEBUG 45 | APC_POOL_REDZONES = 0x08, 46 | APC_POOL_SIZEINFO = 0x10, 47 | APC_POOL_OPT_MASK = 0x18 48 | #endif 49 | } apc_pool_type; 50 | 51 | #if APC_POOL_DEBUG 52 | #define APC_POOL_HAS_SIZEINFO(pool) ((pool->type & APC_POOL_SIZEINFO)!=0) 53 | #define APC_POOL_HAS_REDZONES(pool) ((pool->type & APC_POOL_REDZONES)!=0) 54 | #else 55 | /* let gcc optimize away the optional features */ 56 | #define APC_POOL_HAS_SIZEINFO(pool) (0) 57 | #define APC_POOL_HAS_REDZONES(pool) (0) 58 | #endif 59 | 60 | 61 | typedef struct _apc_pool apc_pool; 62 | 63 | typedef void (*apc_pcleanup_t)(apc_pool *pool TSRMLS_DC); 64 | 65 | typedef void* (*apc_palloc_t)(apc_pool *pool, size_t size TSRMLS_DC); 66 | typedef void (*apc_pfree_t) (apc_pool *pool, void* p TSRMLS_DC); 67 | 68 | typedef void* (*apc_protect_t) (void *p); 69 | typedef void* (*apc_unprotect_t)(void *p); 70 | 71 | struct _apc_pool { 72 | apc_pool_type type; 73 | 74 | apc_malloc_t allocate; 75 | apc_free_t deallocate; 76 | 77 | apc_palloc_t palloc; 78 | apc_pfree_t pfree; 79 | 80 | apc_protect_t protect; 81 | apc_unprotect_t unprotect; 82 | 83 | apc_pcleanup_t cleanup; 84 | 85 | size_t size; 86 | size_t used; 87 | 88 | /* apc_realpool and apc_unpool add more here */ 89 | }; 90 | 91 | #define apc_pool_alloc(pool, size) ((void *) pool->palloc(pool, size TSRMLS_CC)) 92 | #define apc_pool_free(pool, ptr) ((void) pool->pfree (pool, ptr TSRMLS_CC)) 93 | 94 | #define apc_pool_protect(pool, ptr) (pool->protect ? \ 95 | (pool)->protect((ptr)) : (ptr)) 96 | 97 | #define apc_pool_unprotect(pool, ptr) (pool->unprotect ? \ 98 | (pool)->unprotect((ptr)) : (ptr)) 99 | 100 | extern void apc_pool_init(); 101 | 102 | extern apc_pool* apc_pool_create(apc_pool_type pool_type, 103 | apc_malloc_t allocate, 104 | apc_free_t deallocate, 105 | apc_protect_t protect, 106 | apc_unprotect_t unprotect 107 | TSRMLS_DC); 108 | 109 | extern void apc_pool_destroy(apc_pool* pool TSRMLS_DC); 110 | 111 | extern void* apc_pmemcpy(const void* p, size_t n, apc_pool* pool TSRMLS_DC); 112 | extern void* apc_pstrdup(const char* s, apc_pool* pool TSRMLS_DC); 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /apc_shm.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | | Rasmus Lerdorf | 17 | +----------------------------------------------------------------------+ 18 | 19 | This software was contributed to PHP by Community Connect Inc. in 2002 20 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 21 | Future revisions and derivatives of this source code must acknowledge 22 | Community Connect Inc. as the original contributor of this module by 23 | leaving this note intact in the source code. 24 | 25 | All other licensing and usage conditions are those of the PHP Group. 26 | 27 | */ 28 | 29 | /* $Id: apc_shm.c 307259 2011-01-08 12:05:24Z gopalv $ */ 30 | 31 | #include "apc_shm.h" 32 | #include "apc.h" 33 | #ifdef PHP_WIN32 34 | /* shm functions are available in TSRM */ 35 | #include 36 | #define key_t long 37 | #else 38 | #include 39 | #include 40 | #include 41 | #endif 42 | 43 | #ifndef SHM_R 44 | # define SHM_R 0444 /* read permission */ 45 | #endif 46 | #ifndef SHM_A 47 | # define SHM_A 0222 /* write permission */ 48 | #endif 49 | 50 | int apc_shm_create(int proj, size_t size TSRMLS_DC) 51 | { 52 | int shmid; /* shared memory id */ 53 | int oflag; /* permissions on shm */ 54 | key_t key = IPC_PRIVATE; /* shm key */ 55 | 56 | oflag = IPC_CREAT | SHM_R | SHM_A; 57 | if ((shmid = shmget(key, size, oflag)) < 0) { 58 | apc_error("apc_shm_create: shmget(%d, %d, %d) failed: %s. It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of 32MB per segment." TSRMLS_CC, key, size, oflag, strerror(errno)); 59 | } 60 | 61 | return shmid; 62 | } 63 | 64 | void apc_shm_destroy(int shmid) 65 | { 66 | /* we expect this call to fail often, so we do not check */ 67 | shmctl(shmid, IPC_RMID, 0); 68 | } 69 | 70 | apc_segment_t apc_shm_attach(int shmid, size_t size TSRMLS_DC) 71 | { 72 | apc_segment_t segment; /* shm segment */ 73 | 74 | if ((long)(segment.shmaddr = shmat(shmid, 0, 0)) == -1) { 75 | apc_error("apc_shm_attach: shmat failed:" TSRMLS_CC); 76 | } 77 | 78 | #ifdef APC_MEMPROTECT 79 | 80 | if ((long)(segment.roaddr = shmat(shmid, 0, SHM_RDONLY)) == -1) { 81 | segment.roaddr = NULL; 82 | } 83 | 84 | #endif 85 | 86 | segment.size = size; 87 | 88 | /* 89 | * We set the shmid for removal immediately after attaching to it. The 90 | * segment won't disappear until all processes have detached from it. 91 | */ 92 | apc_shm_destroy(shmid); 93 | return segment; 94 | } 95 | 96 | void apc_shm_detach(apc_segment_t* segment TSRMLS_DC) 97 | { 98 | if (shmdt(segment->shmaddr) < 0) { 99 | apc_error("apc_shm_detach: shmdt failed:" TSRMLS_CC); 100 | } 101 | 102 | #ifdef APC_MEMPROTECT 103 | if (segment->roaddr && shmdt(segment->roaddr) < 0) { 104 | apc_error("apc_shm_detach: shmdt failed:" TSRMLS_CC); 105 | } 106 | #endif 107 | } 108 | 109 | /* 110 | * Local variables: 111 | * tab-width: 4 112 | * c-basic-offset: 4 113 | * End: 114 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 115 | * vim<600: expandtab sw=4 ts=4 sts=4 116 | */ 117 | -------------------------------------------------------------------------------- /apc_fcntl.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: George Schlossnagle | 16 | | Rasmus Lerdorf | 17 | +----------------------------------------------------------------------+ 18 | 19 | This software was contributed to PHP by Community Connect Inc. in 2002 20 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 21 | Future revisions and derivatives of this source code must acknowledge 22 | Community Connect Inc. as the original contributor of this module by 23 | leaving this note intact in the source code. 24 | 25 | All other licensing and usage conditions are those of the PHP Group. 26 | 27 | */ 28 | 29 | /* $Id: apc_fcntl.c 307048 2011-01-03 23:53:17Z kalle $ */ 30 | 31 | #include "apc.h" 32 | 33 | #ifdef APC_FCNTL_LOCKS 34 | 35 | #include "apc_fcntl.h" 36 | #include 37 | #include 38 | 39 | int apc_fcntl_create(const char* pathname TSRMLS_DC) 40 | { 41 | int fd; 42 | if(pathname == NULL) { 43 | char lock_path[] = "/tmp/.apc.XXXXXX"; 44 | mktemp(lock_path); 45 | fd = open(lock_path, O_RDWR|O_CREAT, 0666); 46 | if(fd > 0 ) { 47 | unlink(lock_path); 48 | return fd; 49 | } else { 50 | apc_error("apc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:" TSRMLS_CC, lock_path); 51 | return -1; 52 | } 53 | } 54 | fd = open(pathname, O_RDWR|O_CREAT, 0666); 55 | if(fd > 0 ) { 56 | unlink(pathname); 57 | return fd; 58 | } 59 | apc_error("apc_fcntl_create: open(%s, O_RDWR|O_CREAT, 0666) failed:" TSRMLS_CC, pathname); 60 | return -1; 61 | } 62 | 63 | void apc_fcntl_destroy(int fd) 64 | { 65 | close(fd); 66 | } 67 | 68 | static int lock_reg(int fd, int cmd, int type, off_t offset, int whence, off_t len) 69 | { 70 | int ret; 71 | struct flock lock; 72 | 73 | lock.l_type = type; 74 | lock.l_start = offset; 75 | lock.l_whence = whence; 76 | lock.l_len = len; 77 | lock.l_pid = 0; 78 | 79 | do { ret = fcntl(fd, cmd, &lock) ; } 80 | while(ret < 0 && errno == EINTR); 81 | return(ret); 82 | } 83 | 84 | void apc_fcntl_lock(int fd TSRMLS_DC) 85 | { 86 | if(lock_reg(fd, F_SETLKW, F_WRLCK, 0, SEEK_SET, 0) < 0) { 87 | apc_error("apc_fcntl_lock failed:" TSRMLS_CC); 88 | } 89 | } 90 | 91 | void apc_fcntl_rdlock(int fd TSRMLS_DC) 92 | { 93 | if(lock_reg(fd, F_SETLKW, F_RDLCK, 0, SEEK_SET, 0) < 0) { 94 | apc_error("apc_fcntl_rdlock failed:" TSRMLS_CC); 95 | } 96 | } 97 | 98 | zend_bool apc_fcntl_nonblocking_lock(int fd TSRMLS_DC) 99 | { 100 | if(lock_reg(fd, F_SETLK, F_WRLCK, 0, SEEK_SET, 0) < 0) { 101 | if(errno==EACCES||errno==EAGAIN) return 0; 102 | else apc_error("apc_fcntl_lock failed:" TSRMLS_CC); 103 | } 104 | return 1; 105 | } 106 | 107 | void apc_fcntl_unlock(int fd TSRMLS_DC) 108 | { 109 | if(lock_reg(fd, F_SETLKW, F_UNLCK, 0, SEEK_SET, 0) < 0) { 110 | apc_error("apc_fcntl_unlock failed:" TSRMLS_CC); 111 | } 112 | } 113 | 114 | #endif /* APC_FCNTL_LOCKS */ 115 | 116 | /* 117 | * Local variables: 118 | * tab-width: 4 119 | * c-basic-offset: 4 120 | * End: 121 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 122 | * vim<600: expandtab sw=4 ts=4 sts=4 123 | */ 124 | -------------------------------------------------------------------------------- /apc_fcntl_win32.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: George Schlossnagle | 16 | | Edin Kadribasic | 17 | | Pierre Joye | 18 | +----------------------------------------------------------------------+ 19 | 20 | This software was contributed to PHP by Community Connect Inc. in 2002 21 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 22 | Future revisions and derivatives of this source code must acknowledge 23 | Community Connect Inc. as the original contributor of this module by 24 | leaving this note intact in the source code. 25 | 26 | All other licensing and usage conditions are those of the PHP Group. 27 | 28 | */ 29 | 30 | /* $Id: apc_fcntl_win32.c 309203 2011-03-14 06:47:16Z pajoye $ */ 31 | 32 | #include "apc.h" 33 | #include "apc_fcntl.h" 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | int apc_fcntl_create(const char* pathname TSRMLS_DC) 42 | { 43 | char lock_file[MAXPATHLEN]; 44 | HANDLE fd; 45 | DWORD tmp_dirname_len; 46 | char lock_filename_tpl[] = ".apc.XXXXXX"; 47 | char *lock_filename; 48 | 49 | tmp_dirname_len = GetTempPath(MAXPATHLEN, lock_file); 50 | if (!tmp_dirname_len) { 51 | return -1; 52 | } 53 | 54 | lock_filename = _mktemp(lock_filename_tpl); 55 | if (lock_filename == NULL) { 56 | return -1; 57 | } 58 | 59 | snprintf(lock_file + tmp_dirname_len, MAXPATHLEN - tmp_dirname_len - 1, "%s", lock_filename); 60 | 61 | fd = CreateFile(lock_file, 62 | GENERIC_READ | GENERIC_WRITE, 63 | FILE_SHARE_READ | FILE_SHARE_WRITE, 64 | NULL, 65 | OPEN_ALWAYS, 66 | FILE_ATTRIBUTE_NORMAL, 67 | NULL); 68 | 69 | if (fd == INVALID_HANDLE_VALUE) { 70 | apc_error("apc_fcntl_create: could not open %s" TSRMLS_CC, lock_file); 71 | return -1; 72 | } 73 | 74 | return (int)fd; 75 | } 76 | 77 | void apc_fcntl_destroy(int fd) 78 | { 79 | CloseHandle((HANDLE)fd); 80 | } 81 | 82 | void apc_fcntl_lock(int fd TSRMLS_DC) 83 | { 84 | OVERLAPPED offset = {0, 0, 0, 0, NULL}; 85 | 86 | if (!LockFileEx((HANDLE)fd, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &offset)) { 87 | apc_error("apc_fcntl_lock failed errno:%d" TSRMLS_CC, GetLastError()); 88 | } 89 | } 90 | 91 | void apc_fcntl_rdlock(int fd TSRMLS_DC) 92 | { 93 | OVERLAPPED offset = {0, 0, 0, 0, NULL}; 94 | 95 | if (!LockFileEx((HANDLE)fd, 0, 0, 1, 0, &offset)) { 96 | apc_error("apc_fcntl_rdlock failed errno:%d" TSRMLS_CC, GetLastError()); 97 | } 98 | } 99 | 100 | void apc_fcntl_unlock(int fd TSRMLS_DC) 101 | { 102 | OVERLAPPED offset = {0, 0, 0, 0, NULL}; 103 | 104 | if (!UnlockFileEx((HANDLE)fd, 0, 1, 0, &offset)) { 105 | DWORD error_code = GetLastError(); 106 | /* Ignore already unlocked error */ 107 | if (error_code != ERROR_NOT_LOCKED) { 108 | apc_error("apc_fcntl_unlock failed errno:%d" TSRMLS_CC, error_code); 109 | } 110 | } 111 | } 112 | 113 | /* 114 | * Local variables: 115 | * tab-width: 4 116 | * c-basic-offset: 4 117 | * End: 118 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 119 | * vim<600: expandtab sw=4 ts=4 sts=4 120 | */ 121 | -------------------------------------------------------------------------------- /apc_pthreadmutex.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Brian Shire | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: apc_pthreadmutex.c 307048 2011-01-03 23:53:17Z kalle $ */ 21 | 22 | #include "apc_pthreadmutex.h" 23 | 24 | #ifdef APC_PTHREADMUTEX_LOCKS 25 | 26 | pthread_mutex_t *apc_pthreadmutex_create(pthread_mutex_t *lock TSRMLS_DC) 27 | { 28 | int result; 29 | pthread_mutexattr_t* attr; 30 | attr = malloc(sizeof(pthread_mutexattr_t)); 31 | 32 | result = pthread_mutexattr_init(attr); 33 | if(result == ENOMEM) { 34 | apc_error("pthread mutex error: Insufficient memory exists to create the mutex attribute object." TSRMLS_CC); 35 | } else if(result == EINVAL) { 36 | apc_error("pthread mutex error: attr does not point to writeable memory." TSRMLS_CC); 37 | } else if(result == EFAULT) { 38 | apc_error("pthread mutex error: attr is an invalid pointer." TSRMLS_CC); 39 | } 40 | 41 | #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 42 | result = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_ADAPTIVE_NP); 43 | if (result == EINVAL) { 44 | apc_error("pthread_mutexattr_settype: unable to set adaptive mutexes" TSRMLS_CC); 45 | } 46 | #endif 47 | 48 | /* pthread_mutexattr_settype(attr, PTHREAD_MUTEX_ERRORCHECK); */ 49 | result = pthread_mutexattr_setpshared(attr, PTHREAD_PROCESS_SHARED); 50 | if(result == EINVAL) { 51 | apc_error("pthread mutex error: attr is not an initialized mutex attribute object, or pshared is not a valid process-shared state setting." TSRMLS_CC); 52 | } else if(result == EFAULT) { 53 | apc_error("pthread mutex error: attr is an invalid pointer." TSRMLS_CC); 54 | } else if(result == ENOTSUP) { 55 | apc_error("pthread mutex error: pshared was set to PTHREAD_PROCESS_SHARED." TSRMLS_CC); 56 | } 57 | 58 | if(pthread_mutex_init(lock, attr)) { 59 | apc_error("unable to initialize pthread lock" TSRMLS_CC); 60 | } 61 | return lock; 62 | } 63 | 64 | void apc_pthreadmutex_destroy(pthread_mutex_t *lock) 65 | { 66 | return; /* we don't actually destroy the mutex, as it would destroy it for all processes */ 67 | } 68 | 69 | void apc_pthreadmutex_lock(pthread_mutex_t *lock TSRMLS_DC) 70 | { 71 | int result; 72 | result = pthread_mutex_lock(lock); 73 | if(result == EINVAL) { 74 | apc_error("unable to obtain pthread lock (EINVAL)" TSRMLS_CC); 75 | } else if(result == EDEADLK) { 76 | apc_error("unable to obtain pthread lock (EDEADLK)" TSRMLS_CC); 77 | } 78 | } 79 | 80 | void apc_pthreadmutex_unlock(pthread_mutex_t *lock TSRMLS_DC) 81 | { 82 | if(pthread_mutex_unlock(lock)) { 83 | apc_error("unable to unlock pthread lock" TSRMLS_CC); 84 | } 85 | } 86 | 87 | zend_bool apc_pthreadmutex_nonblocking_lock(pthread_mutex_t *lock TSRMLS_DC) 88 | { 89 | int rval; 90 | rval = pthread_mutex_trylock(lock); 91 | if(rval == EBUSY) { /* Lock is already held */ 92 | return 0; 93 | } else if(rval == 0) { /* Obtained lock */ 94 | return 1; 95 | } else { /* Other error */ 96 | apc_error("unable to obtain pthread trylock" TSRMLS_CC); 97 | return 0; 98 | } 99 | } 100 | 101 | 102 | #endif 103 | 104 | /* 105 | * Local variables: 106 | * tab-width: 4 107 | * c-basic-offset: 4 108 | * End: 109 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 110 | * vim<600: expandtab sw=4 ts=4 sts=4 111 | */ 112 | -------------------------------------------------------------------------------- /tests/server_test.inc: -------------------------------------------------------------------------------- 1 | STDIN, 22 | 1 => STDOUT, 23 | 2 => STDERR, 24 | ); 25 | 26 | $php_args = getenv('TEST_PHP_ARGS'); 27 | if (empty($php_args)) { 28 | $ext = (substr(PHP_OS, 0, 3) == 'WIN') ? 'php_apc.dll' : 'apc.so'; 29 | $php_args = "-d extension_dir=$doc_root/../modules -d extension=$ext"; 30 | } 31 | if ($php_opts) { 32 | $php_args = "$php_args -d " . implode(' -d ', $php_opts);; 33 | } 34 | 35 | if (substr(PHP_OS, 0, 3) == 'WIN') { 36 | $cmd = "{$php_executable} -n $php_args -t {$doc_root} -S $host:$port"; 37 | if (!$no_router) { 38 | $cmd .= " {$router}"; 39 | } 40 | 41 | $handle = proc_open(addslashes($cmd), $descriptorspec, $pipes, $doc_root, NULL, array("bypass_shell" => true, "suppress_errors" => true)); 42 | } else { 43 | $cmd = "exec {$php_executable} -n $php_args -t {$doc_root} -S $host:$port"; 44 | if (!$no_router) { 45 | $cmd .= " {$doc_root}/{$router}"; 46 | } 47 | $cmd .= " 2>/dev/null"; 48 | 49 | $handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root); 50 | } 51 | 52 | // note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.' 53 | // it might not be listening yet...need to wait until fsockopen() call returns 54 | $i = 0; 55 | while (($i++ < 10) && !connection_test($host, $port)) { 56 | usleep(10000); 57 | } 58 | 59 | return $handle; 60 | } 61 | 62 | function server_start($code = 'echo "Hello world";', $php_opts = array(), $no_router = FALSE) 63 | { 64 | global $doc_root, $router, $handles, $ports, $num_servers; 65 | 66 | 67 | if ($code) { 68 | file_put_contents($doc_root . '/' . $router, ''); 69 | } 70 | 71 | for ($i = 0; $i < $num_servers; $i++) { 72 | $h = server_start_one(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT+$i, $code, $php_opts, $no_router); 73 | $handles[] = $h; 74 | } 75 | 76 | register_shutdown_function( 77 | function($handles) use($router) { 78 | foreach ($handles as $handle) { 79 | proc_terminate($handle); 80 | } 81 | @unlink(__DIR__ . "/{$router}"); 82 | }, 83 | $handles 84 | ); 85 | // don't bother sleeping, server is already up 86 | // server can take a variable amount of time to be up, so just sleeping a guessed amount of time 87 | // does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass 88 | // sleeping doesn't work. 89 | } 90 | 91 | function get_response($fp, $data_only = true) 92 | { 93 | $s = ''; 94 | 95 | while (!feof($fp)) { 96 | $s .= fgets($fp); 97 | } 98 | 99 | if ($data_only) { 100 | $parts = explode("\r\n\r\n", $s); 101 | $s = $parts[1]; 102 | } 103 | 104 | return $s; 105 | } 106 | 107 | 108 | function connection_test($host, $port) 109 | { 110 | $port = intval($port)?:80; 111 | 112 | $fp = @fsockopen($host, $port, $errno, $errstr, 0.5); 113 | if (!$fp) { 114 | return false; 115 | } 116 | 117 | $send = "GET / HTTP/1.1\nHost: {$host}\r\n\r\n"; 118 | 119 | /* will not out here, just test if the connection has worked*/ 120 | if(@fwrite($fp, $send)) { 121 | get_response($fp); 122 | fclose($fp); 123 | 124 | return true; 125 | } 126 | 127 | @fclose($fp); 128 | 129 | return false; 130 | } 131 | 132 | function run_test_simple($request_uri = NULL) 133 | { 134 | global $num_servers; 135 | $send = "GET /" . $request_uri ." HTTP/1.1\nHost: " . PHP_CLI_SERVER_HOSTNAME . "\r\n\r\n"; 136 | 137 | for ($i = 0; $i < $num_servers; $i++) { 138 | run_test(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT+$i, $send); 139 | } 140 | } 141 | 142 | function run_test($host, $port, $send) 143 | { 144 | $fp = fsockopen($host, $port, $errno, $errstr, 0.5); 145 | if (!$fp) { 146 | die(sprintf("connect failed errno=%d errstr='%s'", $errno, $errstr)); 147 | } 148 | 149 | if(fwrite($fp, $send)) { 150 | echo get_response($fp); 151 | } 152 | 153 | fclose($fp); 154 | } 155 | -------------------------------------------------------------------------------- /apc_pthreadrwlock.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Gopal V | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: $ */ 21 | 22 | #include "apc_pthreadrwlock.h" 23 | 24 | #ifdef APC_PTHREADRW_LOCKS 25 | 26 | pthread_rwlock_t *apc_pthreadrwlock_create(pthread_rwlock_t *lock TSRMLS_DC) 27 | { 28 | int result; 29 | pthread_rwlockattr_t attr; 30 | 31 | result = pthread_rwlockattr_init(&attr); 32 | if(result == ENOMEM) { 33 | apc_error("pthread rwlock error: Insufficient memory exists to create the rwlock attribute object." TSRMLS_CC); 34 | } else if(result == EINVAL) { 35 | apc_error("pthread rwlock error: attr does not point to writeable memory." TSRMLS_CC); 36 | } else if(result == EFAULT) { 37 | apc_error("pthread rwlock error: attr is an invalid pointer." TSRMLS_CC); 38 | } 39 | 40 | #ifdef __USE_UNIX98 41 | pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); 42 | #endif 43 | 44 | result = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); 45 | if(result == EINVAL) { 46 | apc_error("pthread rwlock error: attr is not an initialized rwlock attribute object, or pshared is not a valid process-shared state setting." TSRMLS_CC); 47 | } else if(result == EFAULT) { 48 | apc_error("pthread rwlock error: attr is an invalid pointer." TSRMLS_CC); 49 | } else if(result == ENOTSUP) { 50 | apc_error("pthread rwlock error: pshared was set to PTHREAD_PROCESS_SHARED." TSRMLS_CC); 51 | } 52 | 53 | if(pthread_rwlock_init(lock, &attr)) { 54 | apc_error("unable to initialize pthread rwlock" TSRMLS_CC); 55 | } 56 | 57 | pthread_rwlockattr_destroy(&attr); 58 | 59 | return lock; 60 | } 61 | 62 | void apc_pthreadrwlock_destroy(pthread_rwlock_t *lock) 63 | { 64 | return; /* we don't actually destroy the rwlock, as it would destroy it for all processes */ 65 | } 66 | 67 | void apc_pthreadrwlock_lock(pthread_rwlock_t *lock TSRMLS_DC) 68 | { 69 | int result; 70 | result = pthread_rwlock_wrlock(lock); 71 | if(result == EINVAL) { 72 | apc_error("unable to obtain pthread lock (EINVAL)" TSRMLS_CC); 73 | } else if(result == EDEADLK) { 74 | apc_error("unable to obtain pthread lock (EDEADLK)" TSRMLS_CC); 75 | } 76 | } 77 | 78 | void apc_pthreadrwlock_rdlock(pthread_rwlock_t *lock TSRMLS_DC) 79 | { 80 | int result; 81 | result = pthread_rwlock_rdlock(lock); 82 | if(result == EINVAL) { 83 | apc_error("unable to obtain pthread lock (EINVAL)" TSRMLS_CC); 84 | } else if(result == EDEADLK) { 85 | apc_error("unable to obtain pthread lock (EDEADLK)" TSRMLS_CC); 86 | } 87 | } 88 | 89 | void apc_pthreadrwlock_unlock(pthread_rwlock_t *lock TSRMLS_DC) 90 | { 91 | if(pthread_rwlock_unlock(lock)) { 92 | apc_error("unable to unlock pthread lock" TSRMLS_CC); 93 | } 94 | } 95 | 96 | zend_bool apc_pthreadrwlock_nonblocking_lock(pthread_rwlock_t *lock TSRMLS_DC) 97 | { 98 | int rval; 99 | rval = pthread_rwlock_trywrlock(lock); 100 | if(rval == EBUSY) { /* Lock is already held */ 101 | return 0; 102 | } else if(rval == 0) { /* Obtained lock */ 103 | return 1; 104 | } else { /* Other error */ 105 | apc_error("unable to obtain pthread trylock" TSRMLS_CC); 106 | return 0; 107 | } 108 | } 109 | 110 | 111 | #endif 112 | 113 | /* 114 | * Local variables: 115 | * tab-width: 4 116 | * c-basic-offset: 4 117 | * End: 118 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 119 | * vim<600: expandtab sw=4 ts=4 sts=4 120 | */ 121 | -------------------------------------------------------------------------------- /apc_iterator.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Brian Shire | 16 | +----------------------------------------------------------------------+ 17 | 18 | */ 19 | 20 | /* $Id: apc_iterator.h 307048 2011-01-03 23:53:17Z kalle $ */ 21 | 22 | #ifndef APC_ITERATOR_H 23 | #define APC_ITERATOR_H 24 | 25 | #include "apc.h" 26 | #include "apc_stack.h" 27 | 28 | #if HAVE_PCRE || HAVE_BUNDLED_PCRE 29 | /* Deal with problem present until php-5.2.2 where php_pcre.h was not installed correctly */ 30 | # if !HAVE_BUNDLED_PCRE && PHP_MAJOR_VERSION == 5 && (PHP_MINOR_VERSION < 2 || (PHP_MINOR_VERSION == 2 && PHP_RELEASE_VERSION < 2)) 31 | # include "apc_php_pcre.h" 32 | # else 33 | # include "ext/pcre/php_pcre.h" 34 | # endif 35 | # include "ext/standard/php_smart_str.h" 36 | # define ITERATOR_PCRE 1 37 | #endif 38 | 39 | 40 | #define APC_ITERATOR_NAME "APCIterator" 41 | 42 | #define APC_DEFAULT_CHUNK_SIZE 100 43 | 44 | #define APC_LIST_ACTIVE 0x1 45 | #define APC_LIST_DELETED 0x2 46 | 47 | #define APC_ITER_TYPE (1L << 0) 48 | #define APC_ITER_KEY (1L << 1) 49 | #define APC_ITER_FILENAME (1L << 2) 50 | #define APC_ITER_DEVICE (1L << 3) 51 | #define APC_ITER_INODE (1L << 4) 52 | #define APC_ITER_VALUE (1L << 5) 53 | #define APC_ITER_MD5 (1L << 6) 54 | #define APC_ITER_NUM_HITS (1L << 7) 55 | #define APC_ITER_MTIME (1L << 8) 56 | #define APC_ITER_CTIME (1L << 9) 57 | #define APC_ITER_DTIME (1L << 10) 58 | #define APC_ITER_ATIME (1L << 11) 59 | #define APC_ITER_REFCOUNT (1L << 12) 60 | #define APC_ITER_MEM_SIZE (1L << 13) 61 | #define APC_ITER_TTL (1L << 14) 62 | 63 | #define APC_ITER_NONE (0x00000000L) 64 | #define APC_ITER_ALL (0xffffffffL) 65 | 66 | typedef void* (*apc_iterator_item_cb_t)(slot_t **slot); 67 | 68 | 69 | /* {{{ apc_iterator_t */ 70 | typedef struct _apc_iterator_t { 71 | zend_object obj; /* must always be first */ 72 | short int initialized; /* sanity check in case __construct failed */ 73 | long format; /* format bitmask of the return values ie: key, value, info */ 74 | int (*fetch)(struct _apc_iterator_t *iterator TSRMLS_DC); 75 | /* fetch callback to fetch items from cache slots or lists */ 76 | apc_cache_t *cache; /* cache which we are iterating on */ 77 | long slot_idx; /* index to the slot array or linked list */ 78 | long chunk_size; /* number of entries to pull down per fetch */ 79 | apc_stack_t *stack; /* stack of entries pulled from cache */ 80 | int stack_idx; /* index into the current stack */ 81 | #ifdef ITERATOR_PCRE 82 | pcre *re; /* regex filter on entry identifiers */ 83 | #endif 84 | char *regex; /* original regex expression or NULL */ 85 | int regex_len; /* regex length */ 86 | HashTable *search_hash; /* hash of keys to iterate over */ 87 | long key_idx; /* incrementing index for numerical keys */ 88 | short int totals_flag; /* flag if totals have been calculated */ 89 | long hits; /* hit total */ 90 | size_t size; /* size total */ 91 | long count; /* count total */ 92 | } apc_iterator_t; 93 | /* }}} */ 94 | 95 | /* {{{ apc_iterator_item */ 96 | typedef struct _apc_iterator_item_t { 97 | char *key; /* string key */ 98 | long key_len; /* strlen of key */ 99 | char *filename_key; /* filename key used for deletion */ 100 | zval *value; 101 | } apc_iterator_item_t; 102 | /* }}} */ 103 | 104 | 105 | extern int apc_iterator_init(int module_number TSRMLS_DC); 106 | extern int apc_iterator_delete(zval *zobj TSRMLS_DC); 107 | 108 | #endif 109 | 110 | /* 111 | * Local variables: 112 | * tab-width: 4 113 | * c-basic-offset: 4 114 | * End: 115 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 116 | * vim<600: expandtab sw=4 ts=4 sts=4 117 | */ 118 | -------------------------------------------------------------------------------- /tests/bug61398.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #61398 APC fails to find class methods (based on bug #38779) 3 | --SKIPIF-- 4 | '; 20 | $file = <<data = '$data'; 26 | \$this->position = 0; 27 | return true; 28 | } 29 | function stream_read(\$count) { 30 | \$ret = substr(\$this->data, \$this->position, \$count); 31 | \$this->position += strlen(\$ret); 32 | return \$ret; 33 | } 34 | function stream_eof() { 35 | return \$this->position >= strlen(\$this->data); 36 | } 37 | function stream_stat() { 38 | return array('size' => strlen(\$this->data)); 39 | } 40 | } 41 | stream_wrapper_register('Loader', 'Loader'); 42 | require 'Loader://qqq.php'; 43 | FL; 44 | 45 | server_start($file, $args); 46 | 47 | for ($i = 0; $i < 10; $i++) { 48 | run_test_simple(); 49 | } 50 | echo 'done'; 51 | ?> 52 | --EXPECTF-- 53 |
54 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
55 |
56 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
57 |
58 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
59 |
60 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
61 |
62 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
63 |
64 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
65 |
66 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
67 |
68 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
69 |
70 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
71 |
72 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
73 |
74 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
75 |
76 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
77 |
78 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
79 |
80 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
81 |
82 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
83 |
84 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
85 |
86 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
87 |
88 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
89 |
90 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
91 |
92 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
93 |
94 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
95 |
96 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
97 |
98 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
99 |
100 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
101 |
102 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
103 |
104 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
105 |
106 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
107 |
108 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
109 |
110 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
111 |
112 | Parse error: syntax error, unexpected 'l' (T_STRING) in Loader://qqq.php on line 2
113 | done 114 | -------------------------------------------------------------------------------- /tests/apc54_015.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Test parent class properties in child class (php 5.4) 3 | --SKIPIF-- 4 | one; 25 | } 26 | public function loud1() 27 | { 28 | return \$this->two; 29 | } 30 | } 31 | 32 | \$w = new World; 33 | var_dump(\$w->loud0()); 34 | var_dump(\$w->loud1()); 35 | FL; 36 | 37 | $args = array( 38 | 'apc.cache_by_default=On', 39 | 'apc.canonicalize=On', 40 | 'apc.coredump_unmap=Off', 41 | 'apc.enable_cli=On', 42 | 'apc.enabled=On', 43 | 'apc.file_md5=Off', 44 | 'apc.file_update_protection=2', 45 | 'apc.filters=no', 46 | 'apc.gc_ttl=3600', 47 | 'apc.include_once_override=Off', 48 | 'apc.lazy_classes=Off', 49 | 'apc.lazy_functions=Off', 50 | 'apc.max_file_size=1M', 51 | 'apc.mmap_file_mask=no', 52 | 'apc.num_files_hint=1000', 53 | 'apc.preload_path=no', 54 | 'apc.report_autofilter=Off', 55 | 'apc.rfc1867=Off', 56 | 'apc.rfc1867_freq=0', 57 | 'apc.rfc1867_name=APC_UPLOAD_PROGRESS', 58 | 'apc.rfc1867_prefix=upload_', 59 | 'apc.rfc1867_ttl=3600', 60 | 'apc.serializer=default', 61 | 'apc.shm_segments=1', 62 | 'apc.shm_size=128M', 63 | 'apc.shm_strings_buffer=4M', 64 | 'apc.slam_defense=On', 65 | 'apc.stat=On', 66 | 'apc.stat_ctime=Off', 67 | 'apc.ttl=0', 68 | 'apc.use_request_time=On', 69 | 'apc.user_entries_hint=4096', 70 | 'apc.user_ttl=0', 71 | 'apc.write_lock=On', 72 | ); 73 | 74 | server_start($file, $args); 75 | 76 | for ($i = 0; $i < 10; $i++) { 77 | run_test_simple(); 78 | } 79 | echo 'done'; 80 | 81 | --EXPECT-- 82 | string(7) "123aoeu" 83 | array(2) { 84 | [0]=> 85 | int(10) 86 | [1]=> 87 | string(4) "jaga" 88 | } 89 | string(7) "123aoeu" 90 | array(2) { 91 | [0]=> 92 | int(10) 93 | [1]=> 94 | string(4) "jaga" 95 | } 96 | string(7) "123aoeu" 97 | array(2) { 98 | [0]=> 99 | int(10) 100 | [1]=> 101 | string(4) "jaga" 102 | } 103 | string(7) "123aoeu" 104 | array(2) { 105 | [0]=> 106 | int(10) 107 | [1]=> 108 | string(4) "jaga" 109 | } 110 | string(7) "123aoeu" 111 | array(2) { 112 | [0]=> 113 | int(10) 114 | [1]=> 115 | string(4) "jaga" 116 | } 117 | string(7) "123aoeu" 118 | array(2) { 119 | [0]=> 120 | int(10) 121 | [1]=> 122 | string(4) "jaga" 123 | } 124 | string(7) "123aoeu" 125 | array(2) { 126 | [0]=> 127 | int(10) 128 | [1]=> 129 | string(4) "jaga" 130 | } 131 | string(7) "123aoeu" 132 | array(2) { 133 | [0]=> 134 | int(10) 135 | [1]=> 136 | string(4) "jaga" 137 | } 138 | string(7) "123aoeu" 139 | array(2) { 140 | [0]=> 141 | int(10) 142 | [1]=> 143 | string(4) "jaga" 144 | } 145 | string(7) "123aoeu" 146 | array(2) { 147 | [0]=> 148 | int(10) 149 | [1]=> 150 | string(4) "jaga" 151 | } 152 | string(7) "123aoeu" 153 | array(2) { 154 | [0]=> 155 | int(10) 156 | [1]=> 157 | string(4) "jaga" 158 | } 159 | string(7) "123aoeu" 160 | array(2) { 161 | [0]=> 162 | int(10) 163 | [1]=> 164 | string(4) "jaga" 165 | } 166 | string(7) "123aoeu" 167 | array(2) { 168 | [0]=> 169 | int(10) 170 | [1]=> 171 | string(4) "jaga" 172 | } 173 | string(7) "123aoeu" 174 | array(2) { 175 | [0]=> 176 | int(10) 177 | [1]=> 178 | string(4) "jaga" 179 | } 180 | string(7) "123aoeu" 181 | array(2) { 182 | [0]=> 183 | int(10) 184 | [1]=> 185 | string(4) "jaga" 186 | } 187 | string(7) "123aoeu" 188 | array(2) { 189 | [0]=> 190 | int(10) 191 | [1]=> 192 | string(4) "jaga" 193 | } 194 | string(7) "123aoeu" 195 | array(2) { 196 | [0]=> 197 | int(10) 198 | [1]=> 199 | string(4) "jaga" 200 | } 201 | string(7) "123aoeu" 202 | array(2) { 203 | [0]=> 204 | int(10) 205 | [1]=> 206 | string(4) "jaga" 207 | } 208 | string(7) "123aoeu" 209 | array(2) { 210 | [0]=> 211 | int(10) 212 | [1]=> 213 | string(4) "jaga" 214 | } 215 | string(7) "123aoeu" 216 | array(2) { 217 | [0]=> 218 | int(10) 219 | [1]=> 220 | string(4) "jaga" 221 | } 222 | string(7) "123aoeu" 223 | array(2) { 224 | [0]=> 225 | int(10) 226 | [1]=> 227 | string(4) "jaga" 228 | } 229 | string(7) "123aoeu" 230 | array(2) { 231 | [0]=> 232 | int(10) 233 | [1]=> 234 | string(4) "jaga" 235 | } 236 | string(7) "123aoeu" 237 | array(2) { 238 | [0]=> 239 | int(10) 240 | [1]=> 241 | string(4) "jaga" 242 | } 243 | string(7) "123aoeu" 244 | array(2) { 245 | [0]=> 246 | int(10) 247 | [1]=> 248 | string(4) "jaga" 249 | } 250 | string(7) "123aoeu" 251 | array(2) { 252 | [0]=> 253 | int(10) 254 | [1]=> 255 | string(4) "jaga" 256 | } 257 | string(7) "123aoeu" 258 | array(2) { 259 | [0]=> 260 | int(10) 261 | [1]=> 262 | string(4) "jaga" 263 | } 264 | string(7) "123aoeu" 265 | array(2) { 266 | [0]=> 267 | int(10) 268 | [1]=> 269 | string(4) "jaga" 270 | } 271 | string(7) "123aoeu" 272 | array(2) { 273 | [0]=> 274 | int(10) 275 | [1]=> 276 | string(4) "jaga" 277 | } 278 | string(7) "123aoeu" 279 | array(2) { 280 | [0]=> 281 | int(10) 282 | [1]=> 283 | string(4) "jaga" 284 | } 285 | string(7) "123aoeu" 286 | array(2) { 287 | [0]=> 288 | int(10) 289 | [1]=> 290 | string(4) "jaga" 291 | } 292 | done 293 | -------------------------------------------------------------------------------- /apc.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Daniel Cowgill | 16 | | George Schlossnagle | 17 | | Rasmus Lerdorf | 18 | | Arun C. Murthy | 19 | | Gopal Vijayaraghavan | 20 | +----------------------------------------------------------------------+ 21 | 22 | This software was contributed to PHP by Community Connect Inc. in 2002 23 | and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1. 24 | Future revisions and derivatives of this source code must acknowledge 25 | Community Connect Inc. as the original contributor of this module by 26 | leaving this note intact in the source code. 27 | 28 | All other licensing and usage conditions are those of the PHP Group. 29 | 30 | */ 31 | 32 | /* $Id: apc.h 328292 2012-11-09 07:05:17Z laruence $ */ 33 | 34 | #ifndef APC_H 35 | #define APC_H 36 | 37 | /* 38 | * This module defines utilities and helper functions used elsewhere in APC. 39 | */ 40 | 41 | /* Commonly needed C library headers. */ 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | /* UNIX headers (needed for struct stat) */ 51 | #include 52 | #include 53 | #ifndef PHP_WIN32 54 | #include 55 | #endif 56 | 57 | #ifdef HAVE_CONFIG_H 58 | #include 59 | #endif 60 | 61 | #include "php.h" 62 | #include "main/php_streams.h" 63 | 64 | /* typedefs for extensible memory allocators */ 65 | typedef void* (*apc_malloc_t)(size_t TSRMLS_DC); 66 | typedef void (*apc_free_t) (void * TSRMLS_DC); 67 | 68 | /* wrappers for memory allocation routines */ 69 | extern void* apc_emalloc(size_t n TSRMLS_DC); 70 | extern void* apc_erealloc(void* p, size_t n TSRMLS_DC); 71 | extern void apc_efree(void* p TSRMLS_DC); 72 | extern char* apc_estrdup(const char* s TSRMLS_DC); 73 | extern void* apc_xstrdup(const char* s, apc_malloc_t f TSRMLS_DC); 74 | extern void* apc_xmemcpy(const void* p, size_t n, apc_malloc_t f TSRMLS_DC); 75 | 76 | /* console display functions */ 77 | extern void apc_error(const char *format TSRMLS_DC, ...); 78 | extern void apc_warning(const char *format TSRMLS_DC, ...); 79 | extern void apc_notice(const char *format TSRMLS_DC, ...); 80 | extern void apc_debug(const char *format TSRMLS_DC, ...); 81 | 82 | /* string and text manipulation */ 83 | extern char* apc_append(const char* s, const char* t TSRMLS_DC); 84 | extern char* apc_substr(const char* s, int start, int length TSRMLS_DC); 85 | extern char** apc_tokenize(const char* s, char delim TSRMLS_DC); 86 | 87 | /* filesystem functions */ 88 | 89 | typedef struct apc_fileinfo_t 90 | { 91 | char *fullpath; 92 | char path_buf[MAXPATHLEN]; 93 | php_stream_statbuf st_buf; 94 | } apc_fileinfo_t; 95 | 96 | extern int apc_search_paths(const char* filename, const char* path, apc_fileinfo_t* fileinfo TSRMLS_DC); 97 | 98 | /* regular expression wrapper functions */ 99 | extern void* apc_regex_compile_array(char* patterns[] TSRMLS_DC); 100 | extern void apc_regex_destroy_array(void* p TSRMLS_DC); 101 | extern int apc_regex_match_array(void* p, const char* input); 102 | 103 | /* apc_crc32: returns the CRC-32 checksum of the first len bytes in buf */ 104 | extern unsigned int apc_crc32(const unsigned char* buf, unsigned int len); 105 | 106 | /* apc_flip_hash flips keys and values for faster searching */ 107 | extern HashTable* apc_flip_hash(HashTable *hash); 108 | 109 | #define APC_NEGATIVE_MATCH 1 110 | #define APC_POSITIVE_MATCH 2 111 | 112 | #define apc_time() \ 113 | (APCG(use_request_time) ? (time_t) sapi_get_request_time(TSRMLS_C) : time(0)); 114 | 115 | #if defined(__GNUC__) 116 | # define APC_UNUSED __attribute__((unused)) 117 | # define APC_USED __attribute__((used)) 118 | # define APC_ALLOC __attribute__((malloc)) 119 | # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2) 120 | # define APC_HOTSPOT __attribute__((hot)) 121 | # else 122 | # define APC_HOTSPOT 123 | # endif 124 | #else 125 | # define APC_UNUSED 126 | # define APC_USED 127 | # define APC_ALLOC 128 | # define APC_HOTSPOT 129 | #endif 130 | 131 | #endif 132 | 133 | /* 134 | * Local variables: 135 | * tab-width: 4 136 | * c-basic-offset: 4 137 | * End: 138 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 139 | * vim<600: expandtab sw=4 ts=4 sts=4 140 | */ 141 | -------------------------------------------------------------------------------- /apc_windows_srwlock_kernel.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | APC | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 2006-2011 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Pierre Joye | 16 | +----------------------------------------------------------------------+ 17 | */ 18 | /* $Id$ */ 19 | /* 20 | These APIs are not actually exposed nor documented. But should work fine 21 | from a binary as available since XP without signature changes. 22 | */ 23 | /* 24 | TODOs: 25 | non blocking could be possible using the fWait argument (to 0). However 26 | I'm not sure whether the wait handlers is actually implemented in all 27 | supported platforms (xp+). could be enabled later once really tested. 28 | */ 29 | /* $Id: $ */ 30 | 31 | #include 32 | 33 | #ifdef APC_SRWLOCK_KERNEL 34 | #include "apc_windows_srwlock_kernel.h" 35 | 36 | /* 37 | For references: 38 | void WINAPI RtlInitializeResource(LPRTL_RWLOCK rwl); 39 | void WINAPI RtlDeleteResource(LPRTL_RWLOCK rwl); 40 | BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK rwl, BYTE fWait); 41 | BYTE WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK rwl, BYTE fWait); 42 | void WINAPI RtlReleaseResource(LPRTL_RWLOCK rwl); 43 | */ 44 | typedef void (WINAPI *tRtlInitializeResource)(LPRTL_RWLOCK rwl); 45 | typedef void (WINAPI *tRtlDeleteResource)(LPRTL_RWLOCK rwl); 46 | typedef BYTE (WINAPI *tRtlAcquireResourceExclusive)(LPRTL_RWLOCK rwl, BYTE fWait); 47 | typedef BYTE (WINAPI *tRtlAcquireResourceShared)(LPRTL_RWLOCK rwl, BYTE fWait); 48 | typedef void (WINAPI *tRtlReleaseResource)(LPRTL_RWLOCK rwl); 49 | typedef void (WINAPI *tRtlDumpResource)(LPRTL_RWLOCK rwl); 50 | 51 | tRtlInitializeResource pRtlInitializeResource = 0; 52 | tRtlDeleteResource pRtlDeleteResource = 0; 53 | tRtlAcquireResourceExclusive pRtlAcquireResourceExclusive = 0; 54 | tRtlAcquireResourceShared pRtlAcquireResourceShared = 0; 55 | tRtlReleaseResource pRtlReleaseResource = 0; 56 | tRtlDumpResource pRtlDumpResource = 0; 57 | 58 | HINSTANCE ntdll; 59 | 60 | void apc_windows_cs_status(apc_windows_cs_rwlock_t *lock ); 61 | apc_windows_cs_rwlock_t *apc_windows_cs_create(apc_windows_cs_rwlock_t *lock TSRMLS_DC) 62 | { 63 | ntdll = LoadLibrary("ntdll.dll"); 64 | if (ntdll == 0) { 65 | return NULL; 66 | } 67 | 68 | pRtlInitializeResource = (tRtlInitializeResource) GetProcAddress(ntdll, "RtlInitializeResource"); 69 | pRtlDeleteResource = (tRtlDeleteResource) GetProcAddress(ntdll, "RtlDeleteResource"); 70 | pRtlAcquireResourceExclusive = (tRtlAcquireResourceExclusive) GetProcAddress(ntdll, "RtlAcquireResourceExclusive"); 71 | pRtlAcquireResourceShared = (tRtlAcquireResourceShared) GetProcAddress(ntdll, "RtlAcquireResourceShared"); 72 | pRtlReleaseResource = (tRtlReleaseResource) GetProcAddress(ntdll, "RtlReleaseResource"); 73 | pRtlDumpResource = (tRtlReleaseResource) GetProcAddress(ntdll, "RtlDumpResource"); 74 | if (pRtlInitializeResource == 0 || pRtlDeleteResource == 0 || pRtlAcquireResourceExclusive == 0 || 75 | pRtlAcquireResourceShared == 0 || pRtlReleaseResource == 0 || pRtlDumpResource == 0) { 76 | return NULL; 77 | } 78 | pRtlInitializeResource(lock); 79 | return lock; 80 | } 81 | 82 | void apc_windows_cs_destroy(apc_windows_cs_rwlock_t *lock) 83 | { 84 | __try 85 | { 86 | pRtlDeleteResource(lock); 87 | } 88 | __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? 89 | EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) 90 | { 91 | /* Ignore exception (resource was freed during shutdown of another thread) */ 92 | } 93 | FreeLibrary(ntdll); 94 | return; 95 | } 96 | 97 | void apc_windows_cs_lock(apc_windows_cs_rwlock_t *lock TSRMLS_DC) 98 | { 99 | pRtlAcquireResourceExclusive(lock, 1); 100 | } 101 | 102 | void apc_windows_cs_rdlock(apc_windows_cs_rwlock_t *lock TSRMLS_DC) 103 | { 104 | pRtlAcquireResourceShared(lock, 1); 105 | } 106 | 107 | void apc_windows_cs_unlock_rd(apc_windows_cs_rwlock_t *lock TSRMLS_DC) 108 | { 109 | pRtlReleaseResource(lock); 110 | } 111 | 112 | void apc_windows_cs_unlock_wr(apc_windows_cs_rwlock_t *lock TSRMLS_DC) 113 | { 114 | pRtlReleaseResource(lock); 115 | } 116 | 117 | /* debugging purposes, output using trace msgs */ 118 | void apc_windows_cs_status(apc_windows_cs_rwlock_t *lock) 119 | { 120 | pRtlDumpResource(lock); 121 | return; 122 | } 123 | 124 | #endif 125 | 126 | /* 127 | * Local variables: 128 | * tab-width: 4 129 | * c-basic-offset: 4 130 | * End: 131 | * vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker 132 | * vim<600: expandtab sw=4 ts=4 sts=4 133 | */ 134 | -------------------------------------------------------------------------------- /tests/apc54_018.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | APC: Bug #59938 APCIterator fails with large user cache 3 | --SKIPIF-- 4 | getTotalCount()); //returns 50000 23 | var_dump(\$it->current()); //returns false on error 24 | FL; 25 | 26 | $args = array( 27 | 'apc.enabled=1', 28 | 'apc.enable_cli=1', 29 | 'apc.shm_size=256M', 30 | ); 31 | 32 | server_start($file, $args); 33 | 34 | for ($i = 0; $i < 3; $i++) { 35 | run_test_simple(); 36 | } 37 | echo 'done'; 38 | 39 | --EXPECTF-- 40 | int(50000) 41 | array(11) { 42 | ["type"]=> 43 | string(4) "user" 44 | ["key"]=> 45 | string(42) "test-niko-asdfasdfasdfkjasdflkasjdfasf%d" 46 | ["value"]=> 47 | string(%d) "%s" 48 | ["num_hits"]=> 49 | int(0) 50 | ["mtime"]=> 51 | int(%d) 52 | ["creation_time"]=> 53 | int(%d) 54 | ["deletion_time"]=> 55 | int(0) 56 | ["access_time"]=> 57 | int(%d) 58 | ["ref_count"]=> 59 | int(0) 60 | ["mem_size"]=> 61 | int(%d) 62 | ["ttl"]=> 63 | int(0) 64 | } 65 | int(50000) 66 | array(11) { 67 | ["type"]=> 68 | string(4) "user" 69 | ["key"]=> 70 | string(42) "test-niko-asdfasdfasdfkjasdflkasjdfasf%d" 71 | ["value"]=> 72 | string(%d) "%s" 73 | ["num_hits"]=> 74 | int(0) 75 | ["mtime"]=> 76 | int(%d) 77 | ["creation_time"]=> 78 | int(%d) 79 | ["deletion_time"]=> 80 | int(0) 81 | ["access_time"]=> 82 | int(%d) 83 | ["ref_count"]=> 84 | int(0) 85 | ["mem_size"]=> 86 | int(%d) 87 | ["ttl"]=> 88 | int(0) 89 | } 90 | int(50000) 91 | array(11) { 92 | ["type"]=> 93 | string(4) "user" 94 | ["key"]=> 95 | string(42) "test-niko-asdfasdfasdfkjasdflkasjdfasf%d" 96 | ["value"]=> 97 | string(%d) "%s" 98 | ["num_hits"]=> 99 | int(0) 100 | ["mtime"]=> 101 | int(%d) 102 | ["creation_time"]=> 103 | int(%d) 104 | ["deletion_time"]=> 105 | int(0) 106 | ["access_time"]=> 107 | int(%d) 108 | ["ref_count"]=> 109 | int(0) 110 | ["mem_size"]=> 111 | int(%d) 112 | ["ttl"]=> 113 | int(0) 114 | } 115 | int(50000) 116 | array(11) { 117 | ["type"]=> 118 | string(4) "user" 119 | ["key"]=> 120 | string(42) "test-niko-asdfasdfasdfkjasdflkasjdfasf%d" 121 | ["value"]=> 122 | string(%d) "%s" 123 | ["num_hits"]=> 124 | int(0) 125 | ["mtime"]=> 126 | int(%d) 127 | ["creation_time"]=> 128 | int(%d) 129 | ["deletion_time"]=> 130 | int(0) 131 | ["access_time"]=> 132 | int(%d) 133 | ["ref_count"]=> 134 | int(0) 135 | ["mem_size"]=> 136 | int(%d) 137 | ["ttl"]=> 138 | int(0) 139 | } 140 | int(50000) 141 | array(11) { 142 | ["type"]=> 143 | string(4) "user" 144 | ["key"]=> 145 | string(42) "test-niko-asdfasdfasdfkjasdflkasjdfasf%d" 146 | ["value"]=> 147 | string(%d) "%s" 148 | ["num_hits"]=> 149 | int(0) 150 | ["mtime"]=> 151 | int(%d) 152 | ["creation_time"]=> 153 | int(%d) 154 | ["deletion_time"]=> 155 | int(0) 156 | ["access_time"]=> 157 | int(%d) 158 | ["ref_count"]=> 159 | int(0) 160 | ["mem_size"]=> 161 | int(%d) 162 | ["ttl"]=> 163 | int(0) 164 | } 165 | int(50000) 166 | array(11) { 167 | ["type"]=> 168 | string(4) "user" 169 | ["key"]=> 170 | string(42) "test-niko-asdfasdfasdfkjasdflkasjdfasf%d" 171 | ["value"]=> 172 | string(%d) "%s" 173 | ["num_hits"]=> 174 | int(0) 175 | ["mtime"]=> 176 | int(%d) 177 | ["creation_time"]=> 178 | int(%d) 179 | ["deletion_time"]=> 180 | int(0) 181 | ["access_time"]=> 182 | int(%d) 183 | ["ref_count"]=> 184 | int(0) 185 | ["mem_size"]=> 186 | int(%d) 187 | ["ttl"]=> 188 | int(0) 189 | } 190 | int(50000) 191 | array(11) { 192 | ["type"]=> 193 | string(4) "user" 194 | ["key"]=> 195 | string(42) "test-niko-asdfasdfasdfkjasdflkasjdfasf%d" 196 | ["value"]=> 197 | string(%d) "%s" 198 | ["num_hits"]=> 199 | int(0) 200 | ["mtime"]=> 201 | int(%d) 202 | ["creation_time"]=> 203 | int(%d) 204 | ["deletion_time"]=> 205 | int(0) 206 | ["access_time"]=> 207 | int(%d) 208 | ["ref_count"]=> 209 | int(0) 210 | ["mem_size"]=> 211 | int(%d) 212 | ["ttl"]=> 213 | int(0) 214 | } 215 | int(50000) 216 | array(11) { 217 | ["type"]=> 218 | string(4) "user" 219 | ["key"]=> 220 | string(42) "test-niko-asdfasdfasdfkjasdflkasjdfasf%d" 221 | ["value"]=> 222 | string(%d) "%s" 223 | ["num_hits"]=> 224 | int(0) 225 | ["mtime"]=> 226 | int(%d) 227 | ["creation_time"]=> 228 | int(%d) 229 | ["deletion_time"]=> 230 | int(0) 231 | ["access_time"]=> 232 | int(%d) 233 | ["ref_count"]=> 234 | int(0) 235 | ["mem_size"]=> 236 | int(%d) 237 | ["ttl"]=> 238 | int(0) 239 | } 240 | int(50000) 241 | array(11) { 242 | ["type"]=> 243 | string(4) "user" 244 | ["key"]=> 245 | string(42) "test-niko-asdfasdfasdfkjasdflkasjdfasf%d" 246 | ["value"]=> 247 | string(%d) "%s" 248 | ["num_hits"]=> 249 | int(0) 250 | ["mtime"]=> 251 | int(%d) 252 | ["creation_time"]=> 253 | int(%d) 254 | ["deletion_time"]=> 255 | int(0) 256 | ["access_time"]=> 257 | int(%d) 258 | ["ref_count"]=> 259 | int(0) 260 | ["mem_size"]=> 261 | int(%d) 262 | ["ttl"]=> 263 | int(0) 264 | } 265 | done 266 | --------------------------------------------------------------------------------