I'm trying to add my new function, register_offline_function, and have it
pretty much finished, but need a few pointers.

The php_request_function in main/main.c is where I'm working currently.

I've set up the function very similarly to the current
register_shutdown_function mechanism, and I've changed the
php_request_shutdown function to:
void php_request_shutdown(void *dummy)
{
        TSRMLS_FETCH();

        zend_try {

php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1
) TSRMLS_CC);
        } zend_end_try();

        zend_try {
                sapi_send_headers(TSRMLS_C);
        } zend_end_try();

        if (PG(modules_activated)) zend_try {
                php_call_shutdown_functions();
        } zend_end_try();

        if (PG(modules_activated)) {
                zend_deactivate_modules(TSRMLS_C);
        }

        /* Need to call something to close the http connection. */

        if (PG(modules_activated)) zend_try {
                fprintf(stderr, "Calling Offline Functions.\n");
                php_call_offline_functions();
        } zend_end_try();

        zend_try {
                int i;

                for (i=0; i<NUM_TRACK_VARS; i++) {
                        if (PG(http_globals)[i]) {
                                zval_ptr_dtor(&PG(http_globals)[i]);
                        }
                }
        } zend_end_try();

        zend_deactivate(TSRMLS_C);

        zend_try {
                sapi_deactivate(TSRMLS_C);
        } zend_end_try();

        zend_try {
                shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC);
        } zend_end_try();

        zend_try {
                zend_unset_timeout(TSRMLS_C);
        } zend_end_try();
}

I've tried moving the php_call_offline_functions() further down the
execution chain, but I can't put it after the zval_ptr_dtor loop, or move
the zend_deactivate() call up to be before it because these calls toast the
hashtable that stores the functions.  What I'd really like to do is extract
the call that shuts down the http connection from the shutdown procedure and
move it into main.c if possible.  Problem is that I can't figure out where
that happens.  Is there a better way to do this?

Joseph


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to