php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53173 shm_stat to get total & free
Submitted: 2010-10-26 21:18 UTC Modified: 2021-09-19 04:22 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: marc-bennewitz at arcor dot de Assigned: cmb (profile)
Status: No Feedback Package: Semaphore related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
36 + 10 = ?
Subscribe to this entry?

 
 [2010-10-26 21:18 UTC] marc-bennewitz at arcor dot de
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


Patches

sysvshm.diff (last revision 2010-10-26 19:19 UTC by marc-bennewitz at arcor dot de)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-03 06:15 UTC] marc-bennewitz at arcor dot de
what is the state of this issue ?
The patch exists for 9 month !
 [2021-09-08 17:00 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-09-08 17:00 UTC] cmb@php.net
> The patch exists for 9 month !

Checks notes – 10 years now!  Consider to submit the patch as pull
request[1] for better visibility.

[1] <https://github.com/php/php-src/pulls>
 [2021-09-19 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC