Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into patch
diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php
index f6b634d..39027e8 100755
--- a/system/core/Benchmark.php
+++ b/system/core/Benchmark.php
@@ -61,7 +61,7 @@
 	 */
 	public function mark($name)
 	{
-		$this->marker[$name] = microtime();
+		$this->marker[$name] = microtime(TRUE);
 	}
 
 	// --------------------------------------------------------------------
@@ -93,13 +93,10 @@
 
 		if ( ! isset($this->marker[$point2]))
 		{
-			$this->marker[$point2] = microtime();
+			$this->marker[$point2] = microtime(TRUE);
 		}
 
-		list($sm, $ss) = explode(' ', $this->marker[$point1]);
-		list($em, $es) = explode(' ', $this->marker[$point2]);
-
-		return number_format(($em + $es) - ($sm + $ss), $decimals);
+		return number_format($this->marker[$point2] - $this->marker[$point1], $decimals);
 	}
 
 	// --------------------------------------------------------------------
@@ -122,4 +119,4 @@
 }
 
 /* End of file Benchmark.php */
-/* Location: ./system/core/Benchmark.php */
+/* Location: ./system/core/Benchmark.php */
\ No newline at end of file
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 7deccd0..2935822 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -280,12 +280,12 @@
 		{
 			$x = explode('/', $RTR->routes['404_override'], 2);
 			$class = $x[0];
-			$method = (isset($x[1]) ? $x[1] : 'index');
+			$method = isset($x[1]) ? $x[1] : 'index';
 			if ( ! class_exists($class))
 			{
 				if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
 				{
-					show_404("{$class}/{$method}");
+					show_404($class.'/'.$method);
 				}
 
 				include_once(APPPATH.'controllers/'.$class.'.php');
@@ -293,7 +293,7 @@
 		}
 		else
 		{
-			show_404("{$class}/{$method}");
+			show_404($class.'/'.$method);
 		}
 	}
 
@@ -342,12 +342,12 @@
 			{
 				$x = explode('/', $RTR->routes['404_override'], 2);
 				$class = $x[0];
-				$method = (isset($x[1]) ? $x[1] : 'index');
+				$method = isset($x[1]) ? $x[1] : 'index';
 				if ( ! class_exists($class))
 				{
 					if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
 					{
-						show_404("{$class}/{$method}");
+						show_404($class.'/'.$method);
 					}
 
 					include_once(APPPATH.'controllers/'.$class.'.php');
@@ -357,7 +357,7 @@
 			}
 			else
 			{
-				show_404("{$class}/{$method}");
+				show_404($class.'/'.$method);
 			}
 		}
 
@@ -398,7 +398,7 @@
  *  Close the DB connection if one exists
  * ------------------------------------------------------
  */
-	if (class_exists('CI_DB') && isset($CI->db))
+	if (class_exists('CI_DB') && isset($CI->db) && ! $CI->db->pconnect)
 	{
 		$CI->db->close();
 	}
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 61b05d5..cb04c71 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -335,7 +335,7 @@
 		}
 
 		// Start the Query Timer
-		$time_start = list($sm, $ss) = explode(' ', microtime());
+		$time_start = microtime(TRUE);
 
 		// Run the Query
 		if (FALSE === ($this->result_id = $this->simple_query($sql)))
@@ -370,12 +370,12 @@
 		}
 
 		// Stop and aggregate the query time results
-		$time_end = list($em, $es) = explode(' ', microtime());
-		$this->benchmark += ($em + $es) - ($sm + $ss);
+		$time_end = microtime(TRUE);
+		$this->benchmark += $time_end - $time_start;
 
 		if ($this->save_queries == TRUE)
 		{
-			$this->query_times[] = ($em + $es) - ($sm + $ss);
+			$this->query_times[] = $time_end - $time_start;
 		}
 
 		// Increment the query counter
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 19192a1..8b87f81 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -100,6 +100,9 @@
 			$x[count($x) - 1] = strtoupper($extension);
 			$filename = implode('.', $x);
 		}
+		
+		// Clean output buffer
+		ob_clean();
 
 		// Generate the server headers
 		header('Content-Type: '.$mime);
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 48c3bf3..103c3cb 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1891,6 +1891,7 @@
 						'tiff'	=>	'image/tiff',
 						'tif'	=>	'image/tiff',
 						'css'	=>	'text/css',
+						'ics'	=>	'text/calendar',
 						'html'	=>	'text/html',
 						'htm'	=>	'text/html',
 						'shtml'	=>	'text/html',
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 0cac8ae..f9b087e 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -207,6 +207,7 @@
 -  Fixed a bug (#798) - update() used to ignore LIKE conditions that were set with like().
 -  Fixed a bug in Oracle's and MSSQL's delete() methods where an erroneous SQL statement was generated when used with limit().
 -  Fixed a bug in SQLSRV's delete() method where like() and limit() conditions were ignored.
+-  Fixed a bug (#1265) - Database connections were always closed, regardless of the 'pconnect' option value.
 
 Version 2.1.1
 =============