Skip to content

Prevent PHP request to get killed when using fclose callback#26775

Merged
PVince81 merged 2 commits into
masterfrom
fcloseafterkill
Jan 13, 2017
Merged

Prevent PHP request to get killed when using fclose callback#26775
PVince81 merged 2 commits into
masterfrom
fcloseafterkill

Conversation

@PVince81

@PVince81 PVince81 commented Dec 6, 2016

Copy link
Copy Markdown
Contributor

Description

When cancelling a download or closing the connection too quickly after a download, the PHP process might get killed. In these cases the fclose code does not run any more and the locks are not released.
This workaround adds ignore_user_abort(true) to tell PHP to continue working even when the connection was closed. This makes sure that resources get freed properly and no weird GC-induced bugs will appear as reported in #22370

Related Issue

Partial fix for #22370

Motivation and Context

How Has This Been Tested?

See #22370 (comment).
Need to abort download connections.
Also tested with smashbox: owncloud/smashbox#151

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Backports

  • stable9.1 (note: the fix was tested on that version on the reporter's envs)
  • stable9

Please review @jvillafanez @DeepDiver1975 @VicDeo @PhilippSchaffrath @butonic

@PVince81 PVince81 added this to the 9.2 milestone Dec 6, 2016
@mention-bot

Copy link
Copy Markdown

@PVince81, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975, @tanghus and @karakayasemi to be potential reviewers.

@DeepDiver1975

Copy link
Copy Markdown
Member

should we put this call to all entrypoints where we set the execution time to 0?

@PVince81

PVince81 commented Dec 7, 2016

Copy link
Copy Markdown
Contributor Author

Hmm good point. If we set execution time to 0 in these entry points it means we already expect the call to never be killed.

@PVince81

PVince81 commented Dec 7, 2016

Copy link
Copy Markdown
Contributor Author
apps/dav/appinfo/v1/webdav.php|26| set_time_limit(0);
apps/dav/appinfo/v2/remote.php|23| set_time_limit(0);
lib/private/legacy/files.php|149| set_time_limit(0);
lib/private/legacy/files.php|167| set_time_limit($executionTime);
lib/base.php|546| @set_time_limit(3600);

@PVince81

PVince81 commented Dec 7, 2016

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 2a4dffc

@PVince81

PVince81 commented Dec 7, 2016

Copy link
Copy Markdown
Contributor Author

Raised #26790 to look into detecting aborted connections and making shortcuts for faster cleanup

@PVince81

Copy link
Copy Markdown
Contributor Author

Rebased, please review.

@jvillafanez has voiced some objections here #26790 (comment)
Would be good to clarify in this PR here

@PVince81

Copy link
Copy Markdown
Contributor Author

Please re-review @butonic @jvillafanez @DeepDiver1975.

@jvillafanez

Copy link
Copy Markdown
Member

No better alternatives, so let's move with this 👍

@PVince81 PVince81 merged commit 4fcffcf into master Jan 13, 2017
@PVince81

Copy link
Copy Markdown
Contributor Author

stable9.1: #26939

@PVince81

Copy link
Copy Markdown
Contributor Author

stable9: #26962

@lock

lock Bot commented Aug 4, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants