Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25610 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31581 invoked by uid 1010); 11 Sep 2006 16:15:13 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 31553 invoked from network); 11 Sep 2006 16:15:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Sep 2006 16:15:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=steph@zend.com; spf=permerror; sender-id=softfail Authentication-Results: pb1.pair.com header.from=steph@zend.com; sender-id=softfail Received-SPF: error (pb1.pair.com: domain zend.com from 192.38.9.232 cause and error) X-PHP-List-Original-Sender: steph@zend.com X-Host-Fingerprint: 192.38.9.232 gw2.emini.dk Linux 2.4/2.6 Received: from [192.38.9.232] ([192.38.9.232:15329] helo=gw2.emini.dk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5F/D8-02095-A8B85054 for ; Mon, 11 Sep 2006 12:15:10 -0400 Received: by gw2.emini.dk (Postfix, from userid 504) id 1D117C4CA2; Mon, 11 Sep 2006 18:15:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on gw2.emini.dk X-Spam-Detected: no X-Spam-Status: No, score=3.3 required=5.0 tests=AWL,BAYES_00, RCVD_IN_NJABL_DUL,RCVD_IN_SORBS_DUL autolearn=no version=3.1.3 X-Spam-Level: *** Received: from foxbox (IGLD-84-228-30-154.inter.net.il [84.228.30.154]) by gw2.emini.dk (Postfix) with ESMTP id 0AC96C4C98; Mon, 11 Sep 2006 18:14:59 +0200 (CEST) Message-ID: <04ad01c6d5bc$ca4e60e0$6602a8c0@foxbox> Reply-To: "Steph Fox" To: , "Brian Fertig" References: <27.89.02095.A8A55054@pb1.pair.com> <45055FF0.4010206@schlueters.de> <70.2C.02095.91365054@pb1.pair.com> Date: Mon, 11 Sep 2006 18:10:23 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Subject: Re: [PHP-DEV] SAPI EMBED Problems From: steph@zend.com ("Steph Fox") Is this crash under Windows perchance? > 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 >