Johannes Schlueter wrote:
> Not without code, backtrace, etc.
> 
> johannes
> 
> Brian Fertig wrote:
>> I wrote an embedded application that can execute php scripts.
>> When the script exits and I call the php_embed_shutdown() function
>> it crashes.  Can someone explain to me how I can keep this from
>> happening?
>>
>>
>> Brian
>>
>>   


this is the code
----------------
> static void php_function(switch_core_session_t *session, char *data)
> {
>         char *uuid = switch_core_session_get_uuid(session);
>         uint32_t ulen = strlen(uuid);
>         uint32_t len = strlen((char *) data) + ulen + 2;
>         char *mydata = switch_core_session_alloc(session, len);
>         int argc, retval;
>         char *argv[5];
>         char php_code[1024];
>         void*** tsrm_ls = NULL;
> 
>         snprintf(mydata, len, "%s %s", uuid, data);
> 
>         argc = switch_separate_string(mydata, ' ',argv,(sizeof(argv) / 
> sizeof(argv[0])));
> 
>         sprintf(php_code, "uuid=\"%s\"; include(\"%s\");\n", argv[0], 
> argv[1]);
>         //sprintf(php_code, "include('%s');", argv[1]);
> 
>         sprintf(php_code, "%s %s", data, uuid);
> 
>         zend_file_handle script;
>         script.type = ZEND_HANDLE_FP;
>         script.filename = data;
>         script.opened_path = NULL;
>         script.free_filename = 0;
>         script.handle.fp = fopen(script.filename, "rb");
> 
>         // Initialize PHPs CORE
>         php_embed_init(argc, argv, &tsrm_ls);
> 
>         // Return All of the DEBUG crap to the console and/or a log file
>         php_embed_module.ub_write = sapi_mod_php_ub_write;
>         php_embed_module.log_message = mod_php_log_message;
>         php_embed_module.sapi_error = 
> (sapi_error_function_t)mod_php_error_handler;
> 
>         // Let the nice people know we are about to start their script
>         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Starting 
> Script %s\n",data);
> 
>         // Force $uuid and $session to exist in PHPs memory space
>         zval *php_uuid;
>         MAKE_STD_ZVAL(php_uuid);
>         //MAKE_STD_ZVAL(php_session);
>         //php_uuid->type = IS_STRING;
>         //php_uuid->value.str.len = strlen(uuid);
>         //php_uuid->value.str.val = estrdup(uuid);
>         ZVAL_STRING(php_uuid, uuid , 1);
>         //ZVAL_STRING(php_session, session , 1);
>         ZEND_SET_SYMBOL(&EG(symbol_table), "uuid", php_uuid);
>         //ZEND_SET_SYMBOL(&EG(active_symbol_table), "session", php_session);
> 
>         // Force Some INI entries weather the user likes it or not
>         
> zend_alter_ini_entry("register_globals",sizeof("register_globals"),"1", 
> sizeof("1") - 1, PHP_INI_SYSTEM, PHP_INI_STAGE_RUNTIME);
> 
>         // Execute the bloody script
>         retval = php_execute_script(&script TSRMLS_CC);
> 
>         // Clean up after PHP and such
>         php_embed_shutdown(tsrm_ls);  It freaks out down here when it calls 
> tsrm_shutdown() it just stops the whole server.
> 
> 
> 
>         // Return back to the Dialplan
> 
> // Buh bye now!
> }

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

Reply via email to