lytboris Thu, 17 Feb 2011 12:02:16 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=308427
Log:
* Fix memory leak on concurrent new, open
* change comments to ANSI-C style
* added compatibility with net-snmp prior 5.4
Changed paths:
U php/php-src/trunk/ext/snmp/config.m4
U php/php-src/trunk/ext/snmp/snmp.c
Modified: php/php-src/trunk/ext/snmp/config.m4
===================================================================
--- php/php-src/trunk/ext/snmp/config.m4 2011-02-17 11:55:01 UTC (rev
308426)
+++ php/php-src/trunk/ext/snmp/config.m4 2011-02-17 12:02:16 UTC (rev
308427)
@@ -112,6 +112,14 @@
$SNMP_SHARED_LIBADD
])
+ dnl Check whether shutdown_snmp_logging() exists.
+ PHP_CHECK_LIBRARY($SNMP_LIBNAME, shutdown_snmp_logging,
+ [
+ AC_DEFINE(HAVE_SHUTDOWN_SNMP_LOGGING, 1, [ ])
+ ], [], [
+ $SNMP_SHARED_LIBADD
+ ])
+
dnl Test build.
PHP_CHECK_LIBRARY($SNMP_LIBNAME, init_snmp,
[
Modified: php/php-src/trunk/ext/snmp/snmp.c
===================================================================
--- php/php-src/trunk/ext/snmp/snmp.c 2011-02-17 11:55:01 UTC (rev 308426)
+++ php/php-src/trunk/ext/snmp/snmp.c 2011-02-17 12:02:16 UTC (rev 308427)
@@ -117,6 +117,17 @@
#define zend_parse_parameters_none() zend_parse_parameters(ZEND_NUM_ARGS()
TSRMLS_CC, "")
#endif
+/* For net-snmp prior to 5.4 */
+//#ifndef HAVE_SHUTDOWN_SNMP_LOGGING
+extern netsnmp_log_handler *logh_head;
+#define shutdown_snmp_logging() \
+ { \
+ snmp_disable_log(); \
+ while(NULL != logh_head) \
+ netsnmp_remove_loghandler( logh_head ); \
+ }
+//#endif
+
/* For really old ucd-snmp versions.. */
#ifndef HAVE_SNMP_PARSE_OID
#define snmp_parse_oid read_objid
@@ -960,7 +971,7 @@
}
}
objid_set->count++;
- } else if (Z_TYPE_PP(oid) == IS_ARRAY) { // we got objid array
+ } else if (Z_TYPE_PP(oid) == IS_ARRAY) { /* we got objid array */
if (zend_hash_num_elements(Z_ARRVAL_PP(oid)) == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Got empty
OID array");
return FALSE;
@@ -1366,7 +1377,7 @@
snmp_object = (php_snmp_object
*)zend_object_store_get_object(object TSRMLS_CC);
if (snmp_object->max_oids > 0) {
objid_set.step = snmp_object->max_oids;
- if (max_repetitions < 0) { // unspecified in function
call, use session-wise
+ if (max_repetitions < 0) { /* unspecified in function
call, use session-wise */
max_repetitions = snmp_object->max_oids;
}
}
@@ -1385,7 +1396,7 @@
}
if (max_repetitions < 0) {
- max_repetitions = 20; // provide correct default value
+ max_repetitions = 20; /* provide correct default value */
}
php_snmp_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU, st, session,
&objid_set, non_repeaters, max_repetitions, valueretrieval);
@@ -1706,6 +1717,11 @@
return;
}
+ /* handle re-open of snmp session */
+ if (snmp_object->session) {
+ netsnmp_session_free(&(snmp_object->session));
+ }
+
if (netsnmp_session_init(&(snmp_object->session), version, a1, a2,
timeout, retries TSRMLS_CC)) {
return;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php