/** * Function to be executed in script shutdown * Registered with register_shutdown_function() */ public function shutdown() { foreach ($this->shutdown_functions as $function) { call_user_func($function); } if (is_object($this->smtp)) { $this->smtp->disconnect(); } foreach ($this->address_books as $book) { if (is_object($book) && is_a($book, 'rcube_addressbook')) { $book->close(); } } foreach ($this->caches as $cache) { if (is_object($cache)) { $cache->close(); } } if (is_object($this->storage)) { if ($this->expunge_cache) { $this->storage->expunge_cache(); } $this->storage->close(); } // before closing the database connection, write session data if ($_SERVER['REMOTE_ADDR'] && is_object($this->session)) { session_write_close(); } // write performance stats to logs/console if ($this->config->get('devel_mode')) { if (function_exists('memory_get_usage')) { $mem = show_bytes(memory_get_usage()); } if (function_exists('memory_get_peak_usage')) { $mem .= '/' . show_bytes(memory_get_peak_usage()); } $log = $this->task . ($this->action ? '/' . $this->action : '') . ($mem ? " [{$mem}]" : ''); if (defined('RCMAIL_START')) { rcube_print_time(RCMAIL_START, $log); } else { console($log); } } }
/** * Function to be executed in script shutdown * Registered with register_shutdown_function() */ public function shutdown() { foreach ($this->shutdown_functions as $function) { call_user_func($function); } if (is_object($this->smtp)) { $this->smtp->disconnect(); } foreach ($this->caches as $cache) { if (is_object($cache)) { $cache->close(); } } if (is_object($this->storage)) { if ($this->expunge_cache) { $this->storage->expunge_cache(); } $this->storage->close(); } }
/** * 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(); } }
/** * Function to be executed in script shutdown * Registered with register_shutdown_function() */ public function shutdown() { foreach ($this->shutdown_functions as $function) { call_user_func($function); } // write session data as soon as possible and before // closing database connection, don't do this before // registered shutdown functions, they may need the session // Note: this will run registered gc handlers (ie. cache gc) if ($_SERVER['REMOTE_ADDR'] && is_object($this->session)) { $this->session->write_close(); } if (is_object($this->smtp)) { $this->smtp->disconnect(); } foreach ($this->caches as $cache) { if (is_object($cache)) { $cache->close(); } } if (is_object($this->storage)) { $this->storage->close(); } }