1
|
|
|
<?php namespace Comodojo\Daemon\Worker; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package Comodojo Daemon |
5
|
|
|
* @author Marco Giovinazzi <[email protected]> |
6
|
|
|
* @license MIT |
7
|
|
|
* |
8
|
|
|
* LICENSE: |
9
|
|
|
* |
10
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
11
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
12
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
13
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
14
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
15
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
16
|
|
|
* THE SOFTWARE. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
class SharedMemory { |
20
|
|
|
|
21
|
|
|
private $key; |
22
|
|
|
|
23
|
|
|
public function __construct($id) { |
24
|
|
|
|
25
|
|
|
$this->key = shmop_open($id, "c", 0644, 128); |
26
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function getKey() { |
30
|
|
|
|
31
|
|
|
return $this->key; |
32
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function send($signal) { |
36
|
|
|
|
37
|
|
|
return shmop_write($this->key, $signal, 0); |
38
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function read() { |
42
|
|
|
|
43
|
|
|
return trim(shmop_read($this->key, 0, 128)); |
44
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function delete() { |
48
|
|
|
|
49
|
|
|
return shmop_write($this->key, str_pad('', 128), 0); |
50
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function close() { |
54
|
|
|
|
55
|
|
|
shmop_delete($this->key); |
56
|
|
|
|
57
|
|
|
return shmop_close($this->key); |
|
|
|
|
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.