summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2018-01-26 11:14:33 +0100
committerRemi Collet <remi@remirepo.net>2018-01-26 11:14:33 +0100
commitc4521c64e148640fa9ad840e9ea3cb45293204dd (patch)
treef511667363552283ab2c6c8db6a04b92e3a4a014
parent2e773e19b01012e45182b725cae71efeb1449415 (diff)
fix segfault in ZTS mode
-rw-r--r--php_rpminfo.h4
-rw-r--r--rpminfo.c27
2 files changed, 17 insertions, 14 deletions
diff --git a/php_rpminfo.h b/php_rpminfo.h
index 2caee6b..b87b9f0 100644
--- a/php_rpminfo.h
+++ b/php_rpminfo.h
@@ -40,10 +40,6 @@ ZEND_BEGIN_MODULE_GLOBALS(rpminfo)
rpmts ts;
ZEND_END_MODULE_GLOBALS(rpminfo)
-/* Always refer to the globals in your function as RPMINFO_G(variable).
- You are encouraged to rename these macros something shorter, see
- examples in any other php module directory.
-*/
#define RPMINFO_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(rpminfo, v)
#if defined(ZTS) && defined(COMPILE_DL_RPMINFO)
diff --git a/rpminfo.c b/rpminfo.c
index eeb1f6e..169ef96 100644
--- a/rpminfo.c
+++ b/rpminfo.c
@@ -42,13 +42,6 @@ static rpmts rpminfo_getts(rpmVSFlags flags) {
return RPMINFO_G(ts);
}
-static void rpminfo_freets(void) {
- if (RPMINFO_G(ts)) {
- rpmtsFree(RPMINFO_G(ts));
- RPMINFO_G(ts) = NULL;
- }
-}
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_rpminfo, 0, 0, 1)
ZEND_ARG_INFO(0, path)
ZEND_ARG_INFO(0, full)
@@ -170,6 +163,18 @@ PHP_FUNCTION(rpmvercmp)
}
/* }}} */
+/* Remove if there's nothing to do at request start */
+/* {{{ PHP_RINIT_FUNCTION
+ */
+PHP_RINIT_FUNCTION(rpminfo)
+{
+#if defined(COMPILE_DL_RPMINFO) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
+ return SUCCESS;
+}
+/* }}} */
+
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(rpminfo)
@@ -193,7 +198,6 @@ static PHP_GINIT_FUNCTION(rpminfo) /* {{{ */
#if defined(COMPILE_DL_SESSION) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
-
rpminfo_globals->ts = NULL;
}
/* }}} */
@@ -202,7 +206,10 @@ static PHP_GINIT_FUNCTION(rpminfo) /* {{{ */
*/
PHP_GSHUTDOWN_FUNCTION(rpminfo)
{
- rpminfo_freets();
+ if (rpminfo_globals->ts) {
+ rpmtsFree(rpminfo_globals->ts);
+ rpminfo_globals->ts = NULL;
+ }
}
/* }}} */
@@ -227,7 +234,7 @@ zend_module_entry rpminfo_module_entry = {
rpminfo_functions,
NULL,
NULL,
- NULL,
+ PHP_RINIT(rpminfo),
NULL,
PHP_MINFO(rpminfo),
PHP_RPMINFO_VERSION,