Fastcgi disconnect - anyone know if this is 'good'?
Posted: Thu Apr 24, 2008 2:18 pm
I've been looking for a way to 'really, really' disconnect from a webserver during a query (to start a slow-running process and send the browser elsewhere).
Reading through sapi/cgi/cgi_main.c - I think this works, does anyone know if it's going to cause any problems?
Usage would be:
echo "hiya";
fastcgi_disconnect();
// webserver is no longer listening, client's browser terminates the connection
do_something_really_slow();
Reading through sapi/cgi/cgi_main.c - I think this works, does anyone know if it's going to cause any problems?
Usage would be:
echo "hiya";
fastcgi_disconnect();
// webserver is no longer listening, client's browser terminates the connection
do_something_really_slow();
Code: Select all
1232a1233,1257
> PHP_FUNCTION(fastcgi_disconnect)
> {
> if(!fcgi_is_fastcgi()) RETURN_FALSE;
>
> zend_try {
> php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1) TSRMLS_CC);
> } zend_end_try();
>
> /* 4. Send the set HTTP headers (note: This must be done AFTER php_end_ob_buffers() !!) */
> zend_try {
> sapi_send_headers(TSRMLS_C);
> } zend_end_try();
>
> fcgi_request *request = (fcgi_request*) SG(server_context);
> fcgi_finish_request(request);
> RETURN_TRUE;
> }
>
> static zend_function_entry fastcgi_functions[] = {
> PHP_FE(fastcgi_disconnect, NULL)
> {NULL, NULL, NULL}
> };
>
>
>
1240c1265,1269
< NULL,
---
> #if PHP_FASTCGI
> fastcgi_functions,
> #else
> NULL,
> #endif