From:
Operating system: Linux
PHP version: Irrelevant
Package: Semaphore related
Bug Type: Feature/Change Request
Bug description:shm_stat to get total & free
Description:
------------
Adding function to get total size of memory and to get free size of memory
of the opened shm segment.
Test script:
---------------
>From test script:
// test errors
var_dump(shm_stat());
var_dump(shm_stat(1));
var_dump(shm_stat(""));
// open shm segment
$key = ftok(dirname(__FILE__)."/008.phpt", 't');
$shmId = shm_attach($key, 1024);
var_dump($shmId);
// first stat call
var_dump(shm_stat($shmId));
// write data + stat
var_dump(shm_put_var($shmId, 10, '10'));
var_dump(shm_put_var($shmId, 20, '20'));
var_dump(shm_put_var($shmId, 30, '30'));
var_dump(shm_stat($shmId));
// remove data + stat
var_dump(shm_remove_var($shmId, 20));
var_dump(shm_stat($shmId));
// re-open shm segment with different size + stat
var_dump(shm_detach($shmId));
$shmId = shm_attach($key, 10240);
var_dump($shmId);
var_dump(shm_stat($shmId));
// remove shm segment + stat
var_dump(shm_remove($shmId));
var_dump(shm_stat($shmId));
echo "Done\n";
Expected result:
----------------
Warning: shm_stat() expects exactly 1 parameter, 0 given in %s on line %d
bool(false)
Warning: shm_stat() expects parameter 1 to be resource, integer given in %s
on line %d
bool(false)
Warning: shm_stat() expects parameter 1 to be resource, string given in %s
on line %d
bool(false)
resource(%d) of type (sysvshm)
array(2) {
["total"]=>
int(1024)
["free"]=>
int(%d)
}
bool(true)
bool(true)
bool(true)
array(2) {
["total"]=>
int(1024)
["free"]=>
int(%d)
}
bool(true)
array(2) {
["total"]=>
int(1024)
["free"]=>
int(%d)
}
bool(true)
resource(%d) of type (sysvshm)
array(2) {
["total"]=>
int(1024)
["free"]=>
int(%d)
}
bool(true)
array(2) {
["total"]=>
int(1024)
["free"]=>
int(%d)
}
Done
--
Edit bug report at http://bugs.php.net/bug.php?id=53173&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53173&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53173&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53173&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53173&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53173&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53173&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53173&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53173&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53173&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53173&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53173&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53173&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53173&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53173&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53173&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53173&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53173&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53173&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53173&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53173&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53173&r=mysqlcfg