From 944ad7de807ce788d38702f975e9c8d5ac303b97 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 2 Dec 2016 14:55:25 +0100 Subject: [PATCH 1/2] Prevent PHP request to get killed when using fclose callback --- lib/private/Files/View.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 0f7b6a124528..87acb948ac8b 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1143,6 +1143,8 @@ private function basicOperation($operation, $path, $hooks = [], $extraParam = nu $unlockLater = false; if ($this->lockingEnabled && $operation === 'fopen' && is_resource($result)) { $unlockLater = true; + // make sure our unlocking callback will still be called if connection is aborted + ignore_user_abort(true); $result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) { if (in_array('write', $hooks)) { $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE); From 5a414b628e35ececdbed2ba9a5a84a89bf102582 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 7 Dec 2016 11:15:12 +0100 Subject: [PATCH 2/2] Add ignore_user_abort everywhere where the time limit is set to 0 --- apps/dav/appinfo/v1/webdav.php | 1 + apps/dav/appinfo/v2/remote.php | 1 + lib/private/legacy/files.php | 1 + 3 files changed, 3 insertions(+) diff --git a/apps/dav/appinfo/v1/webdav.php b/apps/dav/appinfo/v1/webdav.php index 2475451614af..6c198ce4ff11 100644 --- a/apps/dav/appinfo/v1/webdav.php +++ b/apps/dav/appinfo/v1/webdav.php @@ -24,6 +24,7 @@ // no php execution timeout for webdav set_time_limit(0); +ignore_user_abort(true); // Turn off output buffering to prevent memory problems \OC_Util::obEnd(); diff --git a/apps/dav/appinfo/v2/remote.php b/apps/dav/appinfo/v2/remote.php index 5f1f0d03e4f7..8e4f003875bd 100644 --- a/apps/dav/appinfo/v2/remote.php +++ b/apps/dav/appinfo/v2/remote.php @@ -21,6 +21,7 @@ */ // no php execution timeout for webdav set_time_limit(0); +ignore_user_abort(true); // Turn off output buffering to prevent memory problems \OC_Util::obEnd(); diff --git a/lib/private/legacy/files.php b/lib/private/legacy/files.php index 728833803155..d9fd41f0683c 100644 --- a/lib/private/legacy/files.php +++ b/lib/private/legacy/files.php @@ -147,6 +147,7 @@ public static function get($dir, $files, $params = null) { $streamer->sendHeaders($name); $executionTime = intval(OC::$server->getIniWrapper()->getNumeric('max_execution_time')); set_time_limit(0); + ignore_user_abort(true); if ($getType === self::ZIP_FILES) { foreach ($files as $file) { $file = $dir . '/' . $file;