run usercode before ending the request
commit9cb7d5485855d2fa7bd8bd2f0caeac445d24843b
authorDaniel Sloof <goapsychadelic@gmail.com>
Wed, 30 Jul 2014 14:25:24 +0000 (30 07:25 -0700)
committerfacebook-github-bot <githubbot@fb.com>
Wed, 30 Jul 2014 14:30:17 +0000 (30 07:30 -0700)
treef956e40a07de2bdd3d944895d0e8b925d58083a4
parent99da7812f9a42d91cf38df0c54d3b858f2582239
run usercode before ending the request

Summary: Currently, the following happens at the end of a request:
onSendEnd -> run postsend functions -> hphp_context_exit

However, hphp_context_exit can call destructors for objects that are
alive at the end of request. This usercode should be allowed to send
output. This causes a circular reference issue because postsend
functions might need to access those objects.

When we don't have a postsend function, preserve Zend compatibility by
delaying the execution of onSendEnd.

Closes https://github.com/facebook/hhvm/pull/3279

Reviewed By: @markw65

Differential Revision: D1465876

Pulled By: svcscm
hphp/runtime/base/execution-context.cpp
hphp/runtime/base/execution-context.h
hphp/runtime/base/program-functions.cpp
hphp/runtime/base/program-functions.h
hphp/runtime/server/http-request-handler.cpp