Projects
Kolab:Winterfell
kolab-syncroton
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 10
View file
kolab-syncroton.spec
Changed
@@ -31,7 +31,7 @@ Name: kolab-syncroton Version: 2.3.3 -Release: 0.20160605.git%{?dist} +Release: 0.20160921.git%{?dist} Summary: ActiveSync for Kolab Groupware Group: Applications/Internet
View file
debian.changelog
Changed
@@ -1,4 +1,4 @@ -kolab-syncroton (2.3.3~dev20160605-0~kolab1) unstable; urgency=low +kolab-syncroton (2.3.3~dev20160921-0~kolab1) unstable; urgency=low * Release of version 2.3.2, see:
View file
kolab-syncroton-2.3.3.tar.gz/lib/ext/Roundcube/rcube.php
Changed
@@ -199,23 +199,8 @@ return false; } - $this->memcache = new Memcache; - $this->mc_available = 0; - - // add all configured hosts to pool - $pconnect = $this->config->get('memcache_pconnect', true); - foreach ($this->config->get('memcache_hosts', array()) as $host) { - if (substr($host, 0, 7) != 'unix://') { - list($host, $port) = explode(':', $host); - if (!$port) $port = 11211; - } - else { - $port = 0; - } - - $this->mc_available += intval($this->memcache->addServer( - $host, $port, $pconnect, 1, 1, 15, false, array($this, 'memcache_failure'))); - } + $this->memcache = new Memcache; + $this->memcache_init(); // test connection and failover (will result in $this->mc_available == 0 on complete failure) $this->memcache->increment('__CONNECTIONTEST__', 1); // NOP if key doesn't exist @@ -230,6 +215,31 @@ /** + * Get global handle for memcache access + * + * @return object Memcache + */ + protected function memcache_init() + { + $this->mc_available = 0; + + // add all configured hosts to pool + $pconnect = $this->config->get('memcache_pconnect', true); + foreach ($this->config->get('memcache_hosts', array()) as $host) { + if (substr($host, 0, 7) != 'unix://') { + list($host, $port) = explode(':', $host); + if (!$port) $port = 11211; + } + else { + $port = 0; + } + + $this->mc_available += intval($this->memcache->addServer( + $host, $port, $pconnect, 1, 1, 15, false, array($this, 'memcache_failure'))); + } + } + + /** * Callback for memcache failure */ public function memcache_failure($host, $port) @@ -1038,6 +1048,40 @@ /** + * When you're going to sleep the script execution for a longer time + * it is good to close all external connections (sql, memcache, SMTP, IMAP). + * + * No action is required on wake up, all connections will be + * re-established automatically. + */ + public function sleep() + { + foreach ($this->caches as $cache) { + if (is_object($cache)) { + $cache->close(); + } + } + + if ($this->storage) { + $this->storage->close(); + } + + if ($this->db) { + $this->db->closeConnection(); + } + + if ($this->memcache) { + $this->memcache->close(); + // after close() need to re-init memcache + $this->memcache_init(); + } + + if ($this->smtp) { + $this->smtp->disconnect(); + } + } + + /** * Quote a given string. * Shortcut function for rcube_utils::rep_specialchars_output() *
View file
kolab-syncroton-2.3.3.tar.gz/lib/ext/Roundcube/rcube_cache.php
Changed
@@ -242,6 +242,11 @@ } $this->write_index(); + + $this->index = null; + $this->cache = array(); + $this->cache_sums = array(); + $this->cache_changes = array(); } @@ -609,13 +614,15 @@ $this->max_packet = min($value, $this->max_packet) - 2000; } else if ($this->type == 'memcache') { - $stats = $this->db->getStats(); - $remaining = $stats'limit_maxbytes' - $stats'bytes'; - $this->max_packet = min($remaining / 5, $this->max_packet); + if ($stats = $this->db->getStats()) { + $remaining = $stats'limit_maxbytes' - $stats'bytes'; + $this->max_packet = min($remaining / 5, $this->max_packet); + } } else if ($this->type == 'apc' && function_exists('apc_sma_info')) { - $stats = apc_sma_info(); - $this->max_packet = min($stats'avail_mem' / 5, $this->max_packet); + if ($stats = apc_sma_info()) { + $this->max_packet = min($stats'avail_mem' / 5, $this->max_packet); + } } }
View file
kolab-syncroton-2.3.3.tar.gz/lib/ext/Roundcube/rcube_cache_shared.php
Changed
@@ -236,6 +236,11 @@ } $this->write_index(); + + $this->index = null; + $this->cache = array(); + $this->cache_sums = array(); + $this->cache_changes = array(); }
View file
kolab-syncroton-2.3.3.tar.gz/lib/ext/Roundcube/rcube_db.php
Changed
@@ -779,6 +779,20 @@ } /** + * Terminate database connection. + */ + public function closeConnection() + { + $this->db_connected = false; + $this->db_index = 0; + + // release statement and connection resources + $this->last_result = null; + $this->dbh = null; + $this->dbhs = array(); + } + + /** * Formats input so it can be safely used in a query * * @param mixed $input Value to quote
View file
kolab-syncroton-2.3.3.tar.gz/lib/ext/Roundcube/rcube_db_oracle.php
Changed
@@ -596,4 +596,18 @@ return $this->last_result = $this->dbh->rollBack(); } + + /** + * Terminate database connection. + */ + public function closeConnection() + { + // release statement and close connection(s) + $this->last_result = null; + foreach ($this->dbhs as $dbh) { + oci_close($dbh); + } + + parent::closeConnection(); + } }
View file
kolab-syncroton-2.3.3.tar.gz/lib/ext/Roundcube/rcube_imap.php
Changed
@@ -210,7 +210,9 @@ */ public function close() { + $this->connect_done = false; $this->conn->closeConnection(); + if ($this->mcache) { $this->mcache->close(); }
View file
kolab-syncroton-2.3.3.tar.gz/lib/ext/Syncroton/Command/Ping.php
Changed
@@ -115,10 +115,24 @@ $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " Folders to monitor($lifeTime / $intervalStart / $intervalEnd / $status): " . print_r($folders, true)); if ($status === self::STATUS_NO_CHANGES_FOUND) { + $sleepCallback = Syncroton_Registry::getSleepCallback(); + $wakeupCallback = Syncroton_Registry::getWakeupCallback(); + do { // take a break to save battery lifetime + call_user_func($sleepCallback); sleep(Syncroton_Registry::getPingTimeout()); + // make sure the connection is still alive, abort otherwise + if (connection_aborted()) { + if ($this->_logger instanceof Zend_Log) + $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " Exiting on aborted connection"); + exit; + } + + // reconnect external connections, etc. + call_user_func($wakeupCallback); + try { $device = $this->_deviceBackend->get($this->_device->id); } catch (Syncroton_Exception_NotFound $e) {
View file
kolab-syncroton-2.3.3.tar.gz/lib/ext/Syncroton/Command/Sync.php
Changed
@@ -437,11 +437,23 @@ // continue only if there are changes or no time is left if ($this->_heartbeatInterval > 0) { - $intervalStart = time(); + $intervalStart = time(); + $sleepCallback = Syncroton_Registry::getSleepCallback(); + $wakeupCallback = Syncroton_Registry::getWakeupCallback(); do { // take a break to save battery lifetime + $sleepCallback(); sleep(Syncroton_Registry::getPingTimeout()); + + // make sure the connection is still alive, abort otherwise + if (connection_aborted()) { + if ($this->_logger instanceof Zend_Log) + $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " Exiting on aborted connection"); + exit; + } + + $wakeupCallback(); $now = new DateTime(null, new DateTimeZone('utc'));
View file
kolab-syncroton-2.3.3.tar.gz/lib/ext/Syncroton/Registry.php
Changed
@@ -49,6 +49,9 @@ const POLICYBACKEND = 'policybackend'; const SYNCSTATEBACKEND = 'syncstatebackend'; const LOGGERBACKEND = 'loggerBackend'; + + const SLEEP_CALLBACK = 'sleep_callback'; + const WAKEUP_CALLBACK = 'wakeup_callback'; /** * Class name of the singleton registry object. @@ -321,6 +324,43 @@ return self::get(self::QUIET_TIME); } + + /** + * Returns sleep callback function + * + * This function is used in long running requests like ping & sync to + * close connections to external sources (e.g. database) before we + * call sleep() to wait some time for next iteration. + * Callback should throw exceptions on errors. + * + * @return callable + */ + public static function getSleepCallback() + { + if (!self::isRegistered(self::SLEEP_CALLBACK)) { + self::set(self::SLEEP_CALLBACK, function() {}); + } + + return self::get(self::SLEEP_CALLBACK); + } + + /** + * Returns wakeup callback function + * + * This function is used in long running requests like ping & sync to + * re-connect to external sources (e.g. database) closed by sleep callback. + * Callback should throw exceptions on errors. + * + * @return callable + */ + public static function getWakeupCallback() + { + if (!self::isRegistered(self::WAKEUP_CALLBACK)) { + self::set(self::WAKEUP_CALLBACK, function() {}); + } + + return self::get(self::WAKEUP_CALLBACK); + } /** * return session validation function
View file
kolab-syncroton-2.3.3.tar.gz/lib/kolab_sync.php
Changed
@@ -142,7 +142,7 @@ // Save user password for Roundcube Framework $this->password = $_SERVER'PHP_AUTH_PW'; - // Register Syncroton backends + // Register Syncroton backends/callbacks Syncroton_Registry::set('loggerBackend', $this->logger); Syncroton_Registry::set(Syncroton_Registry::DATABASE, $this->get_dbh()); Syncroton_Registry::set(Syncroton_Registry::TRANSACTIONMANAGER, kolab_sync_transaction_manager::getInstance()); @@ -151,6 +151,7 @@ Syncroton_Registry::set(Syncroton_Registry::SYNCSTATEBACKEND, new kolab_sync_backend_state); Syncroton_Registry::set(Syncroton_Registry::CONTENTSTATEBACKEND, new kolab_sync_backend_content); Syncroton_Registry::set(Syncroton_Registry::POLICYBACKEND, new kolab_sync_backend_policy); + Syncroton_Registry::set(Syncroton_Registry::SLEEP_CALLBACK, array($this, 'sleep')); Syncroton_Registry::setContactsDataClass('kolab_sync_data_contacts'); Syncroton_Registry::setCalendarDataClass('kolab_sync_data_calendar'); @@ -203,6 +204,11 @@ if ($auth'kolab_ldap_error') { self::server_error(); } + + // Close LDAP connection from kolab_auth plugin + if (class_exists('kolab_auth', false)) { + kolab_auth::ldap_close(); + } } else { $auth'pass' = $password;
View file
kolab-syncroton-2.3.3.tar.gz/lib/plugins/kolab_auth/kolab_auth.php
Changed
@@ -770,6 +770,17 @@ } /** + * Close LDAP connection + */ + public static function ldap_close() + { + if (self::$ldap) { + self::$ldap->close(); + self::$ldap = null; + } + } + + /** * Parses LDAP DN string with replacing supported variables. * See kolab_auth_ldap::parse_vars() *
View file
kolab-syncroton.dsc
Changed
@@ -2,7 +2,7 @@ Source: kolab-syncroton Binary: kolab-syncroton Architecture: all -Version: 2.3.3~dev20160605-0~kolab1 +Version: 2.3.3~dev20160921-0~kolab1 Maintainer: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> Uploaders: Paul Klos <kolab@klos2day.nl> Homepage: http://www.kolab.org/
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.