0
0
mirror of https://github.com/phpv8/v8js.git synced 2025-01-03 10:21:51 +00:00

- Fixed crash bug in setting v8js.flags directive using php -d..

This commit is contained in:
Jani Taskinen 2010-12-31 11:46:09 +00:00
parent 2568591d66
commit e1b8b8c1f5
4 changed files with 84 additions and 118 deletions

View File

@ -1,41 +1,77 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package packagerversion="1.4.11" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
<package version="1.0" packagerversion="1.9.1"> http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd">
<name>v8js</name> <name>v8js</name>
<channel>pecl.php.net</channel>
<summary>V8 Javascript Engine for PHP</summary> <summary>V8 Javascript Engine for PHP</summary>
<description>This extension embeds the Google&apos;s V8 Javascript Engine into PHP. <description>
This extension embeds the Google&apos;s V8 Javascript Engine into PHP.
</description> </description>
<maintainers> <lead>
<maintainer>
<user>jani</user>
<name>Jani Taskinen</name> <name>Jani Taskinen</name>
<user>jani</user>
<email>jani@php.net</email> <email>jani@php.net</email>
<role>lead</role> <active>yes</active>
</maintainer> </lead>
</maintainers>
<release>
<version>0.1.0</version>
<date>2010-12-30</date> <date>2010-12-30</date>
<license>PHP</license> <time>12:12:12</time>
<state>beta</state> <version>
<release>0.1.0</release>
<api>0.1.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>- Initial PECL release <notes>- Initial PECL release
</notes> </notes>
<deps> <contents>
<dep type="php" rel="ge" version="5.3.3"/> <dir name="/">
</deps> <file name="CREDITS" role="doc" />
<configureoptions> <file name="config.m4" role="src" />
<configureoption name="with-v8js" default="autodetect" prompt="Please provide the installation prefix of libv8"/> <file name="Makefile.frag" role="src" />
</configureoptions> <file name="v8js.cc" role="src" />
<filelist> <file name="v8js_convert.cc" role="src" />
<file role="src" name="config.m4"/> <file name="v8js_methods.cc" role="src" />
<file role="doc" name="CREDITS"/> <file name="v8js_variables.cc" role="src" />
<file role="src" name="Makefile.frag"/> <file name="php_v8js.h" role="src" />
<file role="src" name="php_v8js.h"/> <file name="php_v8js_macros.h" role="src" />
<file role="src" name="php_v8js_macros.h"/> </dir> <!-- / -->
<file role="src" name="v8js.cc"/> </contents>
<file role="src" name="v8js_convert.cc"/> <dependencies>
<file role="src" name="v8js_methods.cc"/> <required>
<file role="src" name="v8js_variables.cc"/> <php>
</filelist> <min>5.3.3</min>
</php>
<pearinstaller>
<min>1.4.0</min>
</pearinstaller>
</required>
</dependencies>
<providesextension>v8js</providesextension>
<extsrcrelease>
<configureoption default="autodetect" name="with-v8js" prompt="Please provide the installation prefix of libv8" />
</extsrcrelease>
<changelog>
<release>
<version><release>0.1.1</release><api>0.1.1</api></version>
<stability><release>beta</release><api>beta</api></stability>
<date>2010-12-31</date>
<notes>
- Fixed crash bug in setting v8.flags ini directive.
- Added notice to registerExtension() if trying to use it when V8 is already initialized.
</notes>
</release> </release>
<release>
<version><release>0.1.0</release><api>0.1.0</api></version>
<stability><release>beta</release><api>beta</api></stability>
<date>2010-12-30</date>
<notes>
- Initial PECL release.
</notes>
</release>
</changelog>
</package> </package>

View File

@ -1,73 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<package packagerversion="1.4.11" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.0
http://pear.php.net/dtd/package-2.0.xsd">
<name>v8js</name>
<channel>pecl.php.net</channel>
<summary>V8 Javascript Engine for PHP</summary>
<description>
This extension embeds the Google&apos;s V8 Javascript Engine into PHP.
</description>
<lead>
<name>Jani Taskinen</name>
<user>jani</user>
<email>jani@php.net</email>
<active>yes</active>
</lead>
<date>2010-12-30</date>
<time>12:12:12</time>
<version>
<release>0.1.0</release>
<api>0.1.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>- Initial PECL release
</notes>
<contents>
<dir name="/">
<file name="CREDITS" role="doc" />
<file name="config.m4" role="src" />
<file name="Makefile.frag" role="src" />
<file name="v8js.cc" role="src" />
<file name="v8js_convert.cc" role="src" />
<file name="v8js_methods.cc" role="src" />
<file name="v8js_variables.cc" role="src" />
<file name="php_v8js.h" role="src" />
<file name="php_v8js_macros.h" role="src" />
</dir> <!-- / -->
</contents>
<dependencies>
<required>
<php>
<min>5.3.3</min>
</php>
<pearinstaller>
<min>1.4.0</min>
</pearinstaller>
</required>
</dependencies>
<providesextension>v8js</providesextension>
<extsrcrelease>
<configureoption default="autodetect" name="with-v8js" prompt="Please provide the installation prefix of libv8" />
</extsrcrelease>
<changelog>
<release>
<version>
<release>0.1.0</release>
<api>0.1.0</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<date>2010-12-30</date>
<notes>- Initial PECL release.
</notes>
</release>
</changelog>
</package>

View File

@ -24,7 +24,7 @@
#include <v8.h> #include <v8.h>
/* V8Js Version */ /* V8Js Version */
#define V8JS_VERSION "0.1.0" #define V8JS_VERSION "0.1.1"
/* Helper macros */ /* Helper macros */
#define V8JS_SYM(v) v8::String::NewSymbol(v, sizeof(v) - 1) #define V8JS_SYM(v) v8::String::NewSymbol(v, sizeof(v) - 1)

17
v8js.cc
View File

@ -49,7 +49,7 @@ ZEND_BEGIN_MODULE_GLOBALS(v8js)
int disposed_contexts; /* Disposed contexts since last time V8 did GC */ int disposed_contexts; /* Disposed contexts since last time V8 did GC */
/* Ini globals */ /* Ini globals */
zval *v8_flags; /* V8 command line flags */ char *v8_flags; /* V8 command line flags */
int max_disposed_contexts; /* Max disposed context allowed before forcing V8 GC */ int max_disposed_contexts; /* Max disposed context allowed before forcing V8 GC */
ZEND_END_MODULE_GLOBALS(v8js) ZEND_END_MODULE_GLOBALS(v8js)
@ -81,24 +81,22 @@ static ZEND_INI_MH(v8js_OnUpdateV8Flags) /* {{{ */
{ {
if (new_value) { if (new_value) {
if (V8JSG(v8_flags)) { if (V8JSG(v8_flags)) {
zval_ptr_dtor(&V8JSG(v8_flags)); free(V8JSG(v8_flags));
V8JSG(v8_flags) = NULL; V8JSG(v8_flags) = NULL;
} }
if (!new_value[0]) { if (!new_value[0]) {
return FAILURE; return FAILURE;
} }
V8JSG(v8_flags) = zend_strndup(new_value, new_value_length);
} }
MAKE_STD_ZVAL(V8JSG(v8_flags));
ZVAL_STRINGL(V8JSG(v8_flags), new_value, new_value_length, 1);
return SUCCESS; return SUCCESS;
} }
/* }}} */ /* }}} */
ZEND_INI_BEGIN() /* {{{ */ ZEND_INI_BEGIN() /* {{{ */
ZEND_INI_ENTRY("v8js.max_disposed_contexts", "25", ZEND_INI_ALL, v8js_OnUpdateMaxDisposedContexts) ZEND_INI_ENTRY("v8js.max_disposed_contexts", "25", ZEND_INI_ALL, v8js_OnUpdateMaxDisposedContexts)
ZEND_INI_ENTRY("v8js.flags", "", ZEND_INI_ALL, v8js_OnUpdateV8Flags) ZEND_INI_ENTRY("v8js.flags", NULL, ZEND_INI_ALL, v8js_OnUpdateV8Flags)
ZEND_INI_END() ZEND_INI_END()
/* }}} */ /* }}} */
@ -535,7 +533,7 @@ static void php_v8js_init(TSRMLS_D) /* {{{ */
/* Set V8 command line flags (must be done before V8::Initialize()!) */ /* Set V8 command line flags (must be done before V8::Initialize()!) */
if (V8JSG(v8_flags)) { if (V8JSG(v8_flags)) {
v8::V8::SetFlagsFromString(Z_STRVAL_P(V8JSG(v8_flags)), Z_STRLEN_P(V8JSG(v8_flags))); v8::V8::SetFlagsFromString(V8JSG(v8_flags), strlen(V8JSG(v8_flags)));
} }
/* Initialize V8 */ /* Initialize V8 */
@ -1195,6 +1193,11 @@ static PHP_MSHUTDOWN_FUNCTION(v8js)
V8JSG(extensions) = NULL; V8JSG(extensions) = NULL;
} }
if (V8JSG(v8_flags)) {
free(V8JSG(v8_flags));
V8JSG(v8_flags) = NULL;
}
return SUCCESS; return SUCCESS;
} }
/* }}} */ /* }}} */