From e59cd11370e94b34ad2566b13488783a99fcd231 Mon Sep 17 00:00:00 2001 From: drigato Date: Thu, 27 Nov 2014 13:48:34 -0500 Subject: [PATCH] Close the session when a track is previewed or downloaded. Close the file pointer when we are down with it. --- airtime_mvc/application/controllers/ApiController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index e6a3e982e..f8887d355 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -78,6 +78,10 @@ class ApiController extends Zend_Controller_Action */ public function getMediaAction() { + // Close the session so other HTTP requests can be completed while + // tracks are read for previewing or downloading. + session_write_close(); + $fileId = $this->_getParam("file"); $media = Application_Model_StoredFile::RecallById($fileId); @@ -168,10 +172,11 @@ class ApiController extends Zend_Controller_Action while (@ob_end_flush()); // NOTE: We can't use fseek here because it does not work with streams - // (a.k.a. Files stored on Amazon S3) + // (a.k.a. Files stored in the cloud) while(!feof($fm) && (connection_status() == 0)) { echo fread($fm, 1024 * 8); } + fclose($fm); } //Used by the SaaS monitoring