Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uc] Prevent PHP request to get killed when using fclose callback (#26775) #3157

Merged
merged 1 commit into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/dav/appinfo/v1/webdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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();
Expand Down
1 change: 1 addition & 0 deletions apps/dav/appinfo/v2/remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo this later on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think there is a reliable way to do that, since multiple streams can be opened at the same time and there is no clean way to tell when all of them are closed

$result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) {
if (in_array('write', $hooks)) {
$this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE);
Expand Down
1 change: 1 addition & 0 deletions lib/private/legacy/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,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;
Expand Down