Separate SAPI deactivating and destroying resources #8876
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 might bail out on deactivation. One of those SAPI 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 erorrs 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.
This targets master only for now as it changes in some way SAPI API so if there is some external SAPI, it could potentially cause issue there if it calls sapi_deactivate like some other SAPIs. To fix #77780 bug in lower branches, we can potentially also ignore ECONNABORTED but not sure if it's worth the effort if this gets to master. I plan to look to the test for #77780 a bit later as it's slightly tricky but should be added too.