Split SAPI deactivation to module and destroy parts #8877
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently some SAPI's might bail out on deactivation. One of those SAPI's is PHP-FPM that can bail out on request end if for example the connection is closed by the client (web sever). The problem is that in such case the resources are not freed and some values reset. The most visible impact can have not resetting the
PG(headers_sent)which can cause errors in the next request. One such issue is described in #77780 bug which this PR fixes. It seems reasonable to separate deactivation and destroying the resource which means that the bail out will not impact it.Alternatively to fix the mentioned bug we could just disable the bail out completely in deactivation. It is not clear to me what the purpose of that is in deactivation as this is happening after the script execution but I'm not 100% about it so this might be slightly safer and mainly applicable to all SAPI's.
This is iteration of #8876 that should be backportable to PHP-8.0 as it doesn't change the behavior of
sapi_deactivate.