本文整理汇总了PHP中shmop_close函数的典型用法代码示例。如果您正苦于以下问题:PHP shmop_close函数的具体用法?PHP shmop_close怎么用?PHP shmop_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shmop_close函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Writes a message to the shared memory.
*
* @param mixed $message The message to send
* @param integer $signal The signal to send afterward
* @param integer $pause The number of microseconds to pause after signalling
*/
public function send($message, $signal = null, $pause = 500)
{
$messageArray = array();
if (($shmId = @shmop_open($this->pid, 'a', 0, 0)) > 0) {
// Read any existing messages in shared memory
$readMessage = shmop_read($shmId, 0, shmop_size($shmId));
$messageArray[] = unserialize($readMessage);
shmop_delete($shmId);
shmop_close($shmId);
}
// Add the current message to the end of the array, and serialize it
$messageArray[] = $message;
$serializedMessage = serialize($messageArray);
// Write new serialized message to shared memory
$shmId = shmop_open($this->pid, 'c', 0644, strlen($serializedMessage));
if (!$shmId) {
throw new ProcessControlException(sprintf('Not able to create shared memory segment for PID: %s', $this->pid));
} else {
if (shmop_write($shmId, $serializedMessage, 0) !== strlen($serializedMessage)) {
throw new ProcessControlException(sprintf('Not able to write message to shared memory segment for segment ID: %s', $shmId));
}
}
if (false === $signal) {
return;
}
$this->signal($signal ?: $this->signal);
usleep($pause);
}
开发者ID:edwardstock,项目名称:spork,代码行数:35,代码来源:SharedMemory.php
示例2: MonClose
function MonClose()
{
if (!shmop_delete($this->{$shm_id})) {
debug("No se pudo borrar el segmento de memoria compartida.", "red");
}
shmop_close($this->{$shm_id});
}
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:7,代码来源:lib_monitor.php
示例3: close
function close()
{
if (isset($this->segment)) {
shmop_close($this->segment);
$this->segment = null;
}
}
开发者ID:Garcy111,项目名称:Garcy-Framework-2,代码行数:7,代码来源:Cache.php
示例4: close
public function close()
{
if ($this->status == self::STATUS_OPENED) {
shmop_close($this->shmId);
$this->status = self::STATUS_CLOSED;
}
}
开发者ID:dan-homorodean,项目名称:falx-concurrency-and-ipc,代码行数:7,代码来源:Handle.php
示例5: session_value
function session_value($name, $index)
{
global $shm_key, $shm_var, $sem_id;
switch ($index) {
case 'config':
$shm_size = 859;
break;
case 'ipdata':
$shm_size = 30050;
break;
default:
$shm_size = 0;
}
sem_acquire($sem_id['shlock']);
$shm_id = shmop_open($shm_key[$index], 'c', 0644, $shm_size);
if ($name == 'update') {
$shm_data = serialize($shm_var[$index]);
shmop_write($shm_id, str_pad($shm_data, $shm_size, "", STR_PAD_RIGHT), 0);
} else {
$shm_data = shmop_read($shm_id, 0, $shm_size);
$shm_var[$index] = @unserialize($shm_data);
}
shmop_close($shm_id);
sem_release($sem_id['shlock']);
}
开发者ID:phateio,项目名称:php-radio-kernel,代码行数:25,代码来源:shmop.inc.php
示例6: read
/**
* @param $key
* @param int $mode
* @param int $size
* @return mixed|null
* @throws OpenSharedMemoryException
* @throws ReadSharedMemoryException
* @throws SupportSharedMemoryException
*/
public static function read($key, $mode = 0644, $size = 100)
{
if (!self::checkSHMOPSupport()) {
return null;
}
@($shm_id = shmop_open($key, "a", $mode, $size));
//read only
if (!$shm_id) {
throw new OpenSharedMemoryException("The shared memory block could not be opened");
}
@($cached_string = shmop_read($shm_id, 0, $size));
if (!$cached_string) {
shmop_delete($shm_id);
shmop_close($shm_id);
throw new ReadSharedMemoryException("The shared memory block could not be read");
}
$data = json_decode($cached_string, true);
if (isset($data['expiration']) && time() > $data['expiration'] || !isset($data['expiration'])) {
shmop_delete($shm_id);
shmop_close($shm_id);
return null;
}
shmop_close($shm_id);
return unserialize($data['value']);
}
开发者ID:splitio,项目名称:php-client,代码行数:34,代码来源:SharedMemory.php
示例7: __destruct
public function __destruct()
{
if ($this->tempFilename) {
unlink($this->tempFilename);
}
shmop_close($this->shmID);
}
开发者ID:panlatent,项目名称:easy-shm,代码行数:7,代码来源:Shm.php
示例8: save
public function save($shmKey, $appVars)
{
$memBlobkId = @shmop_open($shmKey, "w", 0644, 1024);
$result = shmop_write($memBlobkId, serialize($appVars), 0);
shmop_close($memBlobkId);
return $result;
}
开发者ID:chathura86,项目名称:zf2-application-variable,代码行数:7,代码来源:Memory.php
示例9: resize
/**
* Resize memory block
* @param int $size
* @return bool
*/
protected function resize($size)
{
if ($size > $this->max_size) {
return false;
}
//should be called AFTER reading memory (to not loose changing of variables)
if (empty($this->mem)) {
return false;
}
ignore_user_abort(true);
set_time_limit(180);
if (is_array($this->mem)) {
$this->mem[self::map_info][self::map_info_resized] = $this->mem[self::map_info][self::map_info_resized] + 1;
$this->mem[self::map_info][self::map_info_resizetime] = time();
}
shmop_delete($this->shm);
shmop_close($this->shm);
$t = serialize($this->mem);
$memsize = strlen($t);
if ($memsize > $size) {
$size = $memsize + 1000;
}
$this->shm = shmop_open($this->shmkey, "n", 0777, $size);
if (!$this->shm) {
return false;
}
//mmm... oops.
unset($this->mem);
$w = shmop_write($this->shm, str_pad($t, shmop_size($this->shm), ' ', STR_PAD_RIGHT), 0);
if (!$w) {
return false;
}
return true;
}
开发者ID:rhodesiaxlo,项目名称:ngx_lua_php_queue,代码行数:39,代码来源:ShmMem.php
示例10: rm
function rm($key)
{
$this->shmop_key = ftok($this->pre . $key);
$this->shmop_id = shmop_open($this->shmop_key, 'c', 0644, 0);
$result = shmop_delete($this->shmop_id);
shmop_close($this->shmop_id);
return $result;
}
开发者ID:hcd2008,项目名称:destoon,代码行数:8,代码来源:cache_shmop.class.php
示例11: __unlock
function __unlock()
{
if (isset($_SERVER['sync'])) {
shmop_delete($_SERVER['sync']);
shmop_close($_SERVER['sync']);
unset($_SERVER['sync']);
}
}
开发者ID:melogamepay,项目名称:xp-framework,代码行数:8,代码来源:synchronized.sapi.php
示例12: getExceptions
/**
* Get all the exceptions added to the shared memory.
*
* @return \Throwable[]
*/
public function getExceptions() : array
{
$memory = shmop_open($this->key, "a", 0, 0);
$exceptions = $this->unserialize($memory);
shmop_delete($memory);
shmop_close($memory);
return $exceptions;
}
开发者ID:duncan3dc,项目名称:fork-helper,代码行数:13,代码来源:SharedMemory.php
示例13: delete
/**
* @return boolean
*/
public function delete()
{
if (!$this->exists()) {
return true;
}
$shmId = shmop_open($this->shmKey, 'w', 0, 0);
$result = (bool) shmop_delete($shmId);
shmop_close($shmId);
return $result;
}
开发者ID:sgc-fireball,项目名称:libphp,代码行数:13,代码来源:SHM.php
示例14: getCallbackParams
public function getCallbackParams()
{
$shmId = @shmop_open($this->pid, 'a', 0644, 0);
if (empty($shmId)) {
return false;
}
$datas = unserialize(shmop_read($shmId, 0, shmop_size($shmId)));
shmop_delete($shmId);
shmop_close($shmId);
return $datas;
}
开发者ID:Lith,项目名称:nofussframework,代码行数:11,代码来源:Task.php
示例15: close
public function close()
{
if (false === $this->m_segmentId) {
return false;
}
// Ensure correct object state for the case shmop_close fails in FATAL.
$segmentId = $this->m_segmentId;
$this->m_segmentId = false;
shmop_close($segmentId);
return true;
}
开发者ID:evalcodenet,项目名称:net.evalcode.components.runtime,代码行数:11,代码来源:shmop.php
示例16: tearDown
protected function tearDown()
{
if ($shmid = @shmop_open(self::SHMOP_ID, 'w', 0644, 0)) {
/*
* Fill memory block for fix bug
* @link https://bugs.php.net/bug.php?id=71921
*/
shmop_write($shmid, str_pad('', strlen(self::WORD), ' '), 0);
shmop_delete($shmid);
shmop_close($shmid);
}
}
开发者ID:anime-db,项目名称:shmop,代码行数:12,代码来源:FixedBlockTest.php
示例17: __destruct
public function __destruct()
{
if ($this->changed) {
$serialized = serialize($this->data);
if (strlen($serialized) > shmop_size($this->res)) {
shmop_delete($this->res);
$this->res = shmop_open($id, 'c', 0644, ceil(strlen($serialized) * 1.25));
}
shmop_write($this->res, $serialized, 0);
}
shmop_close($this->res);
}
开发者ID:wapmorgan,项目名称:kvstorage,代码行数:12,代码来源:Shmop.php
示例18: delete
/**
* delete shared memory
*
* @return void
* @throws RuntimeException
*/
public function delete()
{
$s = @shmop_open($this->genKey(), 'a', 0, 0);
if ($s === false) {
return;
}
if (!shmop_delete($s)) {
throw new RuntimeException('could not delete shared memory');
}
shmop_close($s);
unlink('/tmp/' . sha1($this->pid));
}
开发者ID:TomoakiNagahara,项目名称:snidel,代码行数:18,代码来源:Data.php
示例19: _write
private function _write(&$val, &$lh)
{
$id = shmop_open($this->handler, 'c', 0600, $this->options['size']);
if ($id) {
$ret = shmop_write($id, $val, 0) == strlen($val);
shmop_close($id);
$this->_unlock($lh);
return $ret;
}
$this->_unlock($lh);
return false;
}
开发者ID:BGCX067,项目名称:fakebook-svn-to-git,代码行数:12,代码来源:CacheShmop.class.php
示例20: execute
function execute()
{
set_error_handler('fragtable_error_handler');
define('FRAGTABLE_ROOT', dirname(__FILE__));
$HTTP_HOST = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'NULL';
$HTTP_USER_AGENT = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'NULL';
if (!isset($_SERVER['REQUEST_URI'])) {
trigger_error("'REQUEST_URI' not found", E_USER_WARNING);
}
$salt = $HTTP_USER_AGENT . $_SERVER['REQUEST_URI'];
$hashi = hexdec(substr(hash('crc32b', $salt), 0, 2));
$subject = "[{$HTTP_HOST}] DDoS WARNING!!";
$accucnt = 0;
$logfile = FRAGTABLE_ROOT . '/secure.log';
$shm_key['data'] = ftok(__FILE__, 't');
$shm_key['lock'] = ftok(__FILE__, 'u');
$sem_id = sem_get($shm_key['lock']);
$shm_size = 9626;
sem_acquire($sem_id);
$shm_id = shmop_open($shm_key['data'], 'c', 0644, $shm_size);
$shm_data = shmop_read($shm_id, 0, $shm_size);
$fragtable = @unserialize($shm_data);
if (!$fragtable) {
$fragtable = array();
}
$nowtime = time();
if (isset($fragtable[$hashi]) && $nowtime < $fragtable[$hashi][0] + self::$intervsl) {
$accucnt = $fragtable[$hashi][1] < 99 ? $fragtable[$hashi][1] + 1 : $fragtable[$hashi][1];
$acctime = $fragtable[$hashi][0];
} else {
$accucnt = 1;
$acctime = $nowtime;
}
$fragtable[$hashi] = array($acctime, $accucnt);
$shm_data = serialize($fragtable);
shmop_write($shm_id, str_pad($shm_data, $shm_size, "", STR_PAD_RIGHT), 0);
shmop_close($shm_id);
sem_release($sem_id);
$fragtable = $shm_data = NULL;
if ($accucnt > self::$threshold) {
if (!file_exists($logfile) || filesize($logfile) < 10 * 1024 * 1024) {
$message = sprintf("%s | %d | %d | %s | %s | %s\n", gmdate('Y-m-d H:i:s', $nowtime + self::$timezone * 3600), $acctime, $hashi, str_pad($_SERVER["REMOTE_ADDR"], 15, ' ', STR_PAD_RIGHT), "{$_SERVER['REQUEST_METHOD']} {$_SERVER['REQUEST_URI']} {$_SERVER['SERVER_PROTOCOL']}", $HTTP_USER_AGENT);
if (!file_exists($logfile) || $nowtime > filemtime($logfile) + 3600) {
@mail(self::$mailto, $subject, $message);
}
file_put_contents($logfile, $message, FILE_APPEND | LOCK_EX);
}
header('HTTP/1.1 503 Service Temporarily Unavailable');
die('<h1>Service Temporarily Unavailable</h1>');
}
restore_error_handler();
}
开发者ID:phateio,项目名称:php-radio-kernel,代码行数:52,代码来源:loader.php
注:本文中的shmop_close函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论