Commit 3a153eb9 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-698 Renamed IPC backend to IPC Provider, added general config

section, added config file for memcache provider, InterProcessData
autoloads available IPC providers.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 0170c18d
<?php
/***********************************************
* File : ipcmemcached/config.php
* Project : Z-Push
* Descr : Configuration file for the
* memcache IPC provider.
*
* Created : 02.05.2016
*
* Copyright 2007-2016 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation with the following additional
* term according to sec. 7:
*
* According to sec. 7 of the GNU Affero General Public License, version 3,
* the terms of the AGPL are supplemented with the following terms:
*
* "Zarafa" is a registered trademark of Zarafa B.V.
* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
* The licensing of the Program under the AGPL does not imply a trademark license.
* Therefore any rights, title and interest in our trademarks remain entirely with us.
*
* However, if you propagate an unmodified version of the Program you are
* allowed to use the term "Z-Push" to indicate that you distribute the Program.
* Furthermore you may use our trademarks where it is necessary to indicate
* the intended purpose of a product or service provided you use it in accordance
* with honest practices in industrial or commercial matters.
* If you want to propagate modified versions of the Program under the name "Z-Push",
* you may only do so if you have a written permission by Zarafa Deutschland GmbH
* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
// The list of available memcache servers
// More servers can be added as 'hostname:port'
// if no port is specified, the default port 11211 will be used
$zpush_ipc_memcached_servers = array('localhost');
// Prefix to used for keys
define('MEMCACHED_PREFIX', 'z-push-ipc');
// Connection timeout in ms
define('MEMCACHED_TIMEOUT', 100);
// Mutex timeout in s
define('MEMCACHED_MUTEX_TIMEOUT', 5);
// Waiting time before re-trying to aquire mutext (in millionth of sec)
define('MEMCACHED_BLOCK_USLEEP', 10000);
<?php <?php
/*********************************************** /***********************************************
* File : ipcbackendmemcached.php * File : ipcmemcachedorovider.php
* Project : Z-Push * Project : Z-Push
* Descr : IPC backend using Memcached PHP extension * Descr : IPC provider using Memcached PHP extension
* and memcached servers defined in $zpush_ipc_memcached_servers * and memcached servers defined in
* $zpush_ipc_memcached_servers
* *
* Created : 22.11.2015 by Ralf Becker <rb@stylite.de> * Created : 22.11.2015 by Ralf Becker <rb@stylite.de>
* *
* Copyright 2007 - 2013 Zarafa Deutschland GmbH * Copyright 2007 - 2016 Zarafa Deutschland GmbH
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -42,73 +43,71 @@ ...@@ -42,73 +43,71 @@
* Consult LICENSE file for details * Consult LICENSE file for details
************************************************/ ************************************************/
include_once('lib/interface/iipcbackend.php'); class IpcMemcachedProvider implements IIpcProvider {
protected $type;
class IpcBackendMemcached implements IIpcBackend private $maxWaitCycles;
{
protected $type; /**
/** * Instance of memcached class
* Instance of memcached class *
* * @var memcached
* @var Memcached */
*/ protected $memcached;
protected $memcached;
/** /**
* Timeout in ms
*/
const TIMEOUT = 20;
/**
* Prefix to use for keys
*/
const PREFIX = 'z-push-ipc';
/**
* Constructor * Constructor
* *
* @param int $type * @param int $type
* @param int $allocate * @param int $allocate
* @param string $class * @param string $class
*/ */
public function __construct($type, $allocate, $class) { public function __construct($type, $allocate, $class) {
global $zpush_ipc_memcached_servers; global $zpush_ipc_memcached_servers;
unset($allocate, $class); // not used, but required by function signature $this->type = $type;
$this->type = $type; $this->maxWaitCycles = round(MEMCACHED_MUTEX_TIMEOUT * 1000 * 1000 / MEMCACHED_BLOCK_USLEEP);
$this->memcached = new Memcached(md5(serialize($zpush_ipc_memcached_servers))); // not used, but required by function signature
unset($allocate, $class);
$this->memcache->setOptions(array(
// setting a short timeout, to better kope with failed nodes if (!class_exists('Memcached')) {
Memcached::OPT_CONNECT_TIMEOUT => self::TIMEOUT, throw new FatalMisconfigurationException("IpcMemcachedProvider failure: can not find class Memcached. Please make sure the php memcached extension is installed.");
Memcached::OPT_SEND_TIMEOUT => self::TIMEOUT, }
Memcached::OPT_RECV_TIMEOUT => self::TIMEOUT,
// use igbinary, if available $this->memcached = new Memcached(md5(serialize($zpush_ipc_memcached_servers)));
Memcached::OPT_SERIALIZER => Memcached::HAVE_IGBINARY ? Memcached::SERIALIZER_IGBINARY : Memcached::SERIALIZER_JSON,
// use more effician binary protocol (also required for consistent hashing $this->memcached->setOptions(array(
Memcached::OPT_BINARY_PROTOCOL => true, // setting a short timeout, to better kope with failed nodes
// enable Libketama compatible consistent hashing Memcached::OPT_CONNECT_TIMEOUT => 5,
Memcached::OPT_LIBKETAMA_COMPATIBLE => true, Memcached::OPT_SEND_TIMEOUT => MEMCACHED_TIMEOUT * 1000,
// automatic failover and disabling of failed nodes Memcached::OPT_RECV_TIMEOUT => MEMCACHED_TIMEOUT * 1000,
Memcached::OPT_SERVER_FAILURE_LIMIT => 2, Memcached::OPT_TCP_NODELAY => true,
Memcached::OPT_AUTO_EJECT_HOSTS => true, Memcached::OPT_NO_BLOCK => false,
// setting a prefix for all keys
Memcached::OPT_PREFIX_KEY => self::PREFIX, // use igbinary, if available
)); Memcached::OPT_SERIALIZER => Memcached::HAVE_IGBINARY ? Memcached::SERIALIZER_IGBINARY : (Memcached::HAVE_JSON ? Memcached::SERIALIZER_JSON : Memcached::SERIALIZER_PHP),
// use more efficient binary protocol (also required for consistent hashing)
// with persistent connections, only add servers, if they not already added! Memcached::OPT_BINARY_PROTOCOL => true,
if (!count($this->memcache->getServerList())) // enable Libketama compatible consistent hashing
{ Memcached::OPT_LIBKETAMA_COMPATIBLE => true,
foreach($zpush_ipc_memcached_servers as $host_port) // automatic failover and disabling of failed nodes
{ Memcached::OPT_SERVER_FAILURE_LIMIT => 2,
$parts = explode(':',$host_port); Memcached::OPT_AUTO_EJECT_HOSTS => true,
$host = array_shift($parts); // setting a prefix for all keys
$port = $parts ? array_shift($parts) : 11211; // default port Memcached::OPT_PREFIX_KEY => MEMCACHED_PREFIX,
));
$this->memcache->addServer($host,$port);
} // with persistent connections, only add servers, if they not already added!
} if (!count($this->memcached->getServerList())) {
} foreach($zpush_ipc_memcached_servers as $host_port) {
$parts = explode(':', $host_port);
$host = array_shift($parts);
$port = $parts ? array_shift($parts) : 11211; // default port
$this->memcached->addServer($host, $port);
}
}
}
/** /**
* Reinitializes shared memory by removing, detaching and re-allocating it * Reinitializes shared memory by removing, detaching and re-allocating it
...@@ -140,30 +139,34 @@ class IpcBackendMemcached implements IIpcBackend ...@@ -140,30 +139,34 @@ class IpcBackendMemcached implements IIpcBackend
return true; return true;
} }
/**
* How long to wait, before trying again to aquire mutext (in millionth of sec)
*/
const BLOCK_USLEEP=20000;
/** /**
* Blocks the class mutex * Blocks the class mutex
* Method blocks until mutex is available! * Method blocks until mutex is available!
* ATTENTION: make sure that you *always* release a blocked mutex! * ATTENTION: make sure that you *always* release a blocked mutex!
* *
* We try to add mutex to our cache, until we sucseed. * We try to add mutex to our cache, until we succeed.
* It will fail as long other client has stored it * It will fail as long other client has stored it or the
* MEMCACHED_MUTEX_TIMEOUT is reached.
* *
* @access protected * @access protected
* @return boolean * @return boolean
*/ */
public function blockMutex() { public function blockMutex() {
$n = 0; $n = 0;
while(!$this->memcached->add($this->type+10, true, 10)) while(!$this->memcached->add($this->type+10, true, MEMCACHED_MUTEX_TIMEOUT)) {
{ if ($n++) {
if (!$n++) error_log(__METHOD__."() waiting to aquire mutex (this->type=$this->type)"); ZLog::Write(LOGLEVEL_DEBUG, sprintf("IpcMemcachedProvider->BlockMutex() waiting to aquire mutex for type: %s", $this->type));
usleep(self::BLOCK_USLEEP); // wait 20ms before retrying }
} // wait before retrying
if ($n) error_log(__METHOD__."() mutex aquired after waiting for ".($n*self::BLOCK_USLEEP/1000)."ms (this->type=$this->type)"); usleep(MEMCACHED_BLOCK_USLEEP);
if ($n > $this->maxWaitCycles) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("IpcMemcachedProvider->BlockMutex() could not aquire mutex for type: %s. Check memcache service!", $this->type));
return false;
}
}
if ($n) {
ZLog::Write(LOGLEVEL_WARN, sprintf("IpcMemcachedProvider->BlockMutex() mutex aquired after waiting for %sms for type: %s", ($n*MEMCACHED_BLOCK_USLEEP/1000), $this->type));
}
return true; return true;
} }
...@@ -175,8 +178,7 @@ class IpcBackendMemcached implements IIpcBackend ...@@ -175,8 +178,7 @@ class IpcBackendMemcached implements IIpcBackend
* @return boolean * @return boolean
*/ */
public function releaseMutex() { public function releaseMutex() {
//error_log(__METHOD__."() this->type=$this->type"); return $this->memcached->delete($this->type+10);
return $this->memcached->delete($this->type+10);
} }
/** /**
...@@ -188,8 +190,8 @@ class IpcBackendMemcached implements IIpcBackend ...@@ -188,8 +190,8 @@ class IpcBackendMemcached implements IIpcBackend
* @return boolean * @return boolean
*/ */
public function hasData($id = 2) { public function hasData($id = 2) {
$this->memcached->get($this->type.':'.$id); $this->memcached->get($this->type.':'.$id);
return $this->memcached->getResultCode() === Memcached::RES_SUCCESS; return $this->memcached->getResultCode() === Memcached::RES_SUCCESS;
} }
/** /**
...@@ -201,7 +203,7 @@ class IpcBackendMemcached implements IIpcBackend ...@@ -201,7 +203,7 @@ class IpcBackendMemcached implements IIpcBackend
* @return mixed * @return mixed
*/ */
public function getData($id = 2) { public function getData($id = 2) {
return $this->memcached->get($this->type.':'.$id); return $this->memcached->get($this->type.':'.$id);
} }
/** /**
...@@ -215,7 +217,7 @@ class IpcBackendMemcached implements IIpcBackend ...@@ -215,7 +217,7 @@ class IpcBackendMemcached implements IIpcBackend
* @return boolean * @return boolean
*/ */
public function setData($data, $id = 2) { public function setData($data, $id = 2) {
return $this->memcached->set($this->type.':'.$id, $data); return $this->memcached->set($this->type.':'.$id, $data);
} }
/** /**
...@@ -225,6 +227,6 @@ class IpcBackendMemcached implements IIpcBackend ...@@ -225,6 +227,6 @@ class IpcBackendMemcached implements IIpcBackend
* @return boolean * @return boolean
*/ */
private function setInitialCleanTime() { private function setInitialCleanTime() {
return true;
} }
} }
<?php <?php
/*********************************************** /***********************************************
* File : ipcbackendshm.php * File : ipcsharedmemoryprovider.php
* Project : Z-Push * Project : Z-Push
* Descr : IPC backend using SHM PHP extension * Descr : IPC Provider for PHP shared memory extension
* *
* Created : 20.10.2011 * Created : 20.10.2011
* *
* Copyright 2007 - 2013 Zarafa Deutschland GmbH * Copyright 2007 - 2016 Zarafa Deutschland GmbH
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -41,10 +41,7 @@ ...@@ -41,10 +41,7 @@
* Consult LICENSE file for details * Consult LICENSE file for details
************************************************/ ************************************************/
include_once('lib/interface/iipcbackend.php'); class IpcSharedMemoryProvider implements IIpcProvider {
class IpcBackendShm implements IIpcBackend
{
private $mutexid; private $mutexid;
private $memid; private $memid;
protected $type; protected $type;
...@@ -53,13 +50,13 @@ class IpcBackendShm implements IIpcBackend ...@@ -53,13 +50,13 @@ class IpcBackendShm implements IIpcBackend
/** /**
* Constructor * Constructor
* *
* @param int $type * @param int $type
* @param int $allocate * @param int $allocate
* @param string $class * @param string $class
*/ */
public function __construct($type, $allocate, $class) { public function __construct($type, $allocate, $class) {
$this->type = $type; $this->type = $type;
$this->allocate = $allocate; $this->allocate = $allocate;
if ($this->InitSharedMem()) if ($this->InitSharedMem())
ZLog::Write(LOGLEVEL_DEBUG, sprintf("%s(): Initialized mutexid %s and memid %s.", $class, $this->mutexid, $this->memid)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("%s(): Initialized mutexid %s and memid %s.", $class, $this->mutexid, $this->memid));
...@@ -72,28 +69,22 @@ class IpcBackendShm implements IIpcBackend ...@@ -72,28 +69,22 @@ class IpcBackendShm implements IIpcBackend
* @return boolean * @return boolean
*/ */
private function InitSharedMem() { private function InitSharedMem() {
// shared mem general "turn off switch"
if (defined("USE_SHARED_MEM") && USE_SHARED_MEM === false) {
ZLog::Write(LOGLEVEL_INFO, "InterProcessData::InitSharedMem(): the usage of shared memory for Z-Push has been disabled. Check your config for 'USE_SHARED_MEM'.");
return false;
}
if (!function_exists('sem_get') || !function_exists('shm_attach') || !function_exists('sem_acquire')|| !function_exists('shm_get_var')) { if (!function_exists('sem_get') || !function_exists('shm_attach') || !function_exists('sem_acquire')|| !function_exists('shm_get_var')) {
ZLog::Write(LOGLEVEL_INFO, "InterProcessData::InitSharedMem(): PHP libraries for the use shared memory are not available. Functionalities like z-push-top or loop detection are not available. Check your php packages."); ZLog::Write(LOGLEVEL_INFO, "IpcSharedMemoryProvider->InitSharedMem(): PHP libraries for the use shared memory are not available. Check the isntalled php packages or use e.g. the memcache IPC provider.");
return false; return false;
} }
// Create mutex // Create mutex
$this->mutexid = @sem_get($this->type, 1); $this->mutexid = @sem_get($this->type, 1);
if ($this->mutexid === false) { if ($this->mutexid === false) {
ZLog::Write(LOGLEVEL_ERROR, "InterProcessData::InitSharedMem(): could not aquire semaphore"); ZLog::Write(LOGLEVEL_ERROR, "IpcSharedMemoryProvider->InitSharedMem(): could not aquire semaphore");
return false; return false;
} }
// Attach shared memory // Attach shared memory
$this->memid = shm_attach($this->type+10, $this->allocate); $this->memid = shm_attach($this->type+10, $this->allocate);
if ($this->memid === false) { if ($this->memid === false) {
ZLog::Write(LOGLEVEL_ERROR, "InterProcessData::InitSharedMem(): could not attach shared memory"); ZLog::Write(LOGLEVEL_ERROR, "IpcSharedMemoryProvider->InitSharedMem(): could not attach shared memory");
@sem_remove($this->mutexid); @sem_remove($this->mutexid);
$this->mutexid = false; $this->mutexid = false;
return false; return false;
......
...@@ -71,10 +71,19 @@ ...@@ -71,10 +71,19 @@
define('USE_FULLEMAIL_FOR_LOGIN', true); define('USE_FULLEMAIL_FOR_LOGIN', true);
/********************************************************************************** /**********************************************************************************
* Default FileStateMachine settings * Default State settings
*/ */
define('STATE_DIR', '/var/lib/z-push/'); define('STATE_DIR', '/var/lib/z-push/');
/**********************************************************************************
* IPC - InterProcessCommunication
*
* Is either provided by using shared memory on a single host or
* using the memcache provider for multi-host environments.
* When another implementation should be used, the class can be set here explicitly.
* If empty Z-Push will try to use available providers.
*/
define('IPC_PROVIDER', '');
/********************************************************************************** /**********************************************************************************
* Logging settings * Logging settings
...@@ -246,15 +255,6 @@ ...@@ -246,15 +255,6 @@
// the backend data provider // the backend data provider
define('BACKEND_PROVIDER', ''); define('BACKEND_PROVIDER', '');
// IPC backend class must either be already loaded, autoloadable or in lib/core/, like default IpcBackendShm!
if (!function_exists('sem_get') || !function_exists('shm_attach') || !function_exists('sem_acquire')|| !function_exists('shm_get_var'))
{
define('IPC_BACKEND_CLASS', 'IpcBackendShm');
}
// Memcached IPC backend configuration:
// $zpush_ipc_memcached_servers = array('localhost'); // or 'hostname:port'
// define('IPC_BACKEND_CLASS', 'IpcBackendMemcached');
/********************************************************************************** /**********************************************************************************
* Search provider settings * Search provider settings
* *
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* Created : 20.10.2011 * Created : 20.10.2011
* *
* Copyright 2007 - 2013 Zarafa Deutschland GmbH * Copyright 2007 - 2016 Zarafa Deutschland GmbH
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -43,7 +43,13 @@ ...@@ -43,7 +43,13 @@
* Consult LICENSE file for details * Consult LICENSE file for details
************************************************/ ************************************************/
// TODO ZP-821 - remove when autoloading
include_once('backend/ipcsharedmemory/ipcsharedmemoryprovider.php');
abstract class InterProcessData { abstract class InterProcessData {
// Defines which IPC provider to laod, first has preference
// if IPC_PROVIDER in the main config is set, that class will be loaded
const PROVIDER_LOAD_ORDER = array('IpcMemcachedProvider', 'IpcSharedMemoryProvider');
const CLEANUPTIME = 1; const CLEANUPTIME = 1;
static protected $devid; static protected $devid;
...@@ -52,14 +58,14 @@ abstract class InterProcessData { ...@@ -52,14 +58,14 @@ abstract class InterProcessData {
static protected $start; static protected $start;
protected $type; protected $type;
protected $allocate; protected $allocate;
protected $provider_class;
/** /**
* * @var IIpcProvider
* @var IIpcBackend */
*/ private $ipcProvider;
private $backend;
/** /**
* Constructor * Constructor
* *
* @access public * @access public
...@@ -68,21 +74,31 @@ abstract class InterProcessData { ...@@ -68,21 +74,31 @@ abstract class InterProcessData {
if (!isset($this->type) || !isset($this->allocate)) if (!isset($this->type) || !isset($this->allocate))
throw new FatalNotImplementedException(sprintf("Class InterProcessData can not be initialized. Subclass %s did not initialize type and allocable memory.", get_class($this))); throw new FatalNotImplementedException(sprintf("Class InterProcessData can not be initialized. Subclass %s did not initialize type and allocable memory.", get_class($this)));
$ipc_backend = defined('IPC_BACKEND_CLASS') ? IPC_BACKEND_CLASS : 'IpcBackendShm'; $this->provider_class = defined('IPC_PROVIDER') ? IPC_PROVIDER : false;
ZLog::Write(LOGLEVEL_DEBUG, "---------------------------------------------- provider class:". Utils::PrintAsString($this->provider_class));
// until z-push autoloads, manually load IpcBackend if (!$this->provider_class) {
if (!class_exists($ipc_backend)) foreach(self::PROVIDER_LOAD_ORDER as $provider) {
{ ZLog::Write(LOGLEVEL_DEBUG, "---------------------------------------------- provider $provider exists:". class_exists($provider));
include_onced('lib/core/'.strtolower($ipc_backend)); if (class_exists($provider)) {
} $this->provider_class = $provider;
break;
try { }
$this->backend = new $ipc_backend($this->type, $this->allocate, get_class($this)); }
} }
catch (Exception $e) {
// backend could not initialise try {
ZLog::Write(LOGLEVEL_ERROR, __METHOD__."() could not initialise IPC backend '$ipc_backend': ".$e->getMessage()); if (!$this->provider_class) {
} throw new Exception("No IPC provider available");
}
$this->ipcProvider = new $this->provider_class($this->type, $this->allocate, get_class($this));
ZLog::Write(LOGLEVEL_DEBUG, sprintf("%s initialised with IPC provider '%s'", get_class($this), $this->provider_class));
}
catch (Exception $e) {
// ipcProvider could not initialise
ZLog::Write(LOGLEVEL_ERROR, sprintf("%s could not initialise IPC provider '%s': %s", get_class($this), $this->provider_class, $e->getMessage()));
}
} }
/** /**
...@@ -108,7 +124,7 @@ abstract class InterProcessData { ...@@ -108,7 +124,7 @@ abstract class InterProcessData {
* @return boolean * @return boolean
*/ */
public function Clean() { public function Clean() {
return $this->backend ? $this->backend->Clean() : false; return $this->ipcProvider ? $this->ipcProvider->Clean() : false;
} }
/** /**
...@@ -118,7 +134,7 @@ abstract class InterProcessData { ...@@ -118,7 +134,7 @@ abstract class InterProcessData {
* @return boolean * @return boolean
*/ */
public function IsActive() { public function IsActive() {
return $this->backend ? $this->backend->IsActive() : false; return $this->ipcProvider ? $this->ipcProvider->IsActive() : false;
} }
/** /**
...@@ -130,7 +146,7 @@ abstract class InterProcessData { ...@@ -130,7 +146,7 @@ abstract class InterProcessData {
* @return boolean * @return boolean
*/ */
protected function blockMutex() { protected function blockMutex() {
return $this->backend ? $this->backend->blockMutex() : false; return $this->ipcProvider ? $this->ipcProvider->blockMutex() : false;
} }
/** /**
...@@ -141,7 +157,7 @@ abstract class InterProcessData { ...@@ -141,7 +157,7 @@ abstract class InterProcessData {
* @return boolean * @return boolean
*/ */
protected function releaseMutex() { protected function releaseMutex() {
return $this->backend ? $this->backend->releaseMutex() : false; return $this->ipcProvider ? $this->ipcProvider->releaseMutex() : false;
} }
/** /**
...@@ -153,7 +169,7 @@ abstract class InterProcessData { ...@@ -153,7 +169,7 @@ abstract class InterProcessData {
* @return boolean * @return boolean
*/ */
protected function hasData($id = 2) { protected function hasData($id = 2) {
return $this->backend ? $this->backend->hasData($id) : false; return $this->ipcProvider ? $this->ipcProvider->hasData($id) : false;
} }
/** /**
...@@ -165,7 +181,7 @@ abstract class InterProcessData { ...@@ -165,7 +181,7 @@ abstract class InterProcessData {
* @return mixed * @return mixed
*/ */
protected function getData($id = 2) { protected function getData($id = 2) {
return $this->backend ? $this->backend->getData($id) : null; return $this->ipcProvider ? $this->ipcProvider->getData($id) : null;
} }
/** /**
...@@ -179,6 +195,6 @@ abstract class InterProcessData { ...@@ -179,6 +195,6 @@ abstract class InterProcessData {
* @return boolean * @return boolean
*/ */
protected function setData($data, $id = 2) { protected function setData($data, $id = 2) {
return $this->backend ? $this->backend->setData($data, $id) : false; return $this->ipcProvider ? $this->ipcProvider->setData($data, $id) : false;
} }
} }
<?php <?php
/*********************************************** /***********************************************
* File : iipcbackend.php * File : iipcprovider.php
* Project : Z-Push * Project : Z-Push
* Descr : Interface for interprocess communication * Descr : Interface for interprocess communication
* backends for different purposes * providers for different purposes
* *
* Created : 20.10.2011 * Created : 20.10.2011
* *
* Copyright 2007 - 2013 Zarafa Deutschland GmbH * Copyright 2007 - 2016 Zarafa Deutschland GmbH
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
* Consult LICENSE file for details * Consult LICENSE file for details
************************************************/ ************************************************/
interface IIpcBackend interface IIpcProvider
{ {
/** /**
* Constructor * Constructor
......
Copyright (c) 2015 Nils Adermann, Jordi Boggiano Copyright (c) 2016 Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
......
...@@ -34,6 +34,7 @@ return array( ...@@ -34,6 +34,7 @@ return array(
'IChanges' => $baseDir . '/lib/interface/ichanges.php', 'IChanges' => $baseDir . '/lib/interface/ichanges.php',
'IExportChanges' => $baseDir . '/lib/interface/iexportchanges.php', 'IExportChanges' => $baseDir . '/lib/interface/iexportchanges.php',
'IImportChanges' => $baseDir . '/lib/interface/iimportchanges.php', 'IImportChanges' => $baseDir . '/lib/interface/iimportchanges.php',
'IIpcProvider' => $baseDir . '/lib/interface/iipcprovider.php',
'ISearchProvider' => $baseDir . '/lib/interface/isearchprovider.php', 'ISearchProvider' => $baseDir . '/lib/interface/isearchprovider.php',
'IStateMachine' => $baseDir . '/lib/interface/istatemachine.php', 'IStateMachine' => $baseDir . '/lib/interface/istatemachine.php',
'ImportChangesDiff' => $baseDir . '/lib/default/diffbackend/importchangesdiff.php', 'ImportChangesDiff' => $baseDir . '/lib/default/diffbackend/importchangesdiff.php',
......
...@@ -23,24 +23,35 @@ class ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f ...@@ -23,24 +23,35 @@ class ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInitd6749fc2fb9944bbe86b2b7d79a7852f', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php'; $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION');
foreach ($map as $namespace => $path) { if ($useStaticLoader) {
$loader->set($namespace, $path); require_once __DIR__ . '/autoload_static.php';
}
$map = require __DIR__ . '/autoload_psr4.php'; call_user_func(\Composer\Autoload\ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f::getInitializer($loader));
foreach ($map as $namespace => $path) { } else {
$loader->setPsr4($namespace, $path); $map = require __DIR__ . '/autoload_namespaces.php';
} foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php'; $map = require __DIR__ . '/autoload_psr4.php';
if ($classMap) { foreach ($map as $namespace => $path) {
$loader->addClassMap($classMap); $loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
} }
$loader->register(true); $loader->register(true);
$includeFiles = require __DIR__ . '/autoload_files.php'; if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequired6749fc2fb9944bbe86b2b7d79a7852f($fileIdentifier, $file); composerRequired6749fc2fb9944bbe86b2b7d79a7852f($fileIdentifier, $file);
} }
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment