Index: trunk/php/wmerrors/wmerrors.c |
— | — | @@ -53,6 +53,7 @@ |
54 | 54 | STD_PHP_INI_ENTRY("wmerrors.message_file", "", PHP_INI_ALL, OnUpdateString, message_file, zend_wmerrors_globals, wmerrors_globals) |
55 | 55 | STD_PHP_INI_ENTRY("wmerrors.logging_file", "", PHP_INI_ALL, OnUpdateString, logging_file, zend_wmerrors_globals, wmerrors_globals) |
56 | 56 | STD_PHP_INI_ENTRY("wmerrors.log_level", "0", PHP_INI_ALL, OnUpdateLong, log_level, zend_wmerrors_globals, wmerrors_globals) |
| 57 | + STD_PHP_INI_BOOLEAN("wmerrors.ignore_logging_errors", "0", PHP_INI_ALL, OnUpdateBool, ignore_logging_errors, zend_wmerrors_globals, wmerrors_globals) |
57 | 58 | PHP_INI_END() |
58 | 59 | |
59 | 60 | void (*old_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args); |
— | — | @@ -131,7 +132,11 @@ |
132 | 133 | && type != E_USER_ERROR && type != E_RECOVERABLE_ERROR) |
133 | 134 | || WMERRORS_G(recursion_guard)) |
134 | 135 | { |
135 | | - old_error_cb(type, error_filename, error_lineno, format, args); |
| 136 | + /* recursion_guard != 1 means this is an error in writing to the log file. |
| 137 | + * Ignore it if configured to do so. |
| 138 | + */ |
| 139 | + if (WMERRORS_G(recursion_guard) == 1 || !WMERRORS_G(ignore_logging_errors)) |
| 140 | + old_error_cb(type, error_filename, error_lineno, format, args); |
136 | 141 | return; |
137 | 142 | } |
138 | 143 | WMERRORS_G(recursion_guard) = 1; |
— | — | @@ -160,10 +165,14 @@ |
161 | 166 | php_stream * stream; |
162 | 167 | int err; char *errstr = NULL; |
163 | 168 | struct timeval tv; |
| 169 | + int flags = ENFORCE_SAFE_MODE; |
164 | 170 | |
| 171 | + if (!WMERRORS_G(ignore_logging_errors)) |
| 172 | + flags |= REPORT_ERRORS; |
| 173 | + |
165 | 174 | if ( strncmp( stream_name, "tcp://", 6 ) && strncmp( stream_name, "udp://", 6 ) ) { |
166 | 175 | /* Is it a wrapper? */ |
167 | | - stream = php_stream_open_wrapper(stream_name, "ab", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL); |
| 176 | + stream = php_stream_open_wrapper(stream_name, "ab", flags, NULL); |
168 | 177 | } else { |
169 | 178 | /* Maybe it's a transport? */ |
170 | 179 | double timeout = FG(default_socket_timeout); |
— | — | @@ -172,7 +181,7 @@ |
173 | 182 | tv.tv_sec = conv / 1000000; |
174 | 183 | tv.tv_usec = conv % 1000000; |
175 | 184 | |
176 | | - stream = php_stream_xport_create(stream_name, strlen(stream_name), ENFORCE_SAFE_MODE | REPORT_ERRORS, |
| 185 | + stream = php_stream_xport_create(stream_name, strlen(stream_name), flags, |
177 | 186 | STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, NULL, &tv, NULL, &errstr, &err); |
178 | 187 | } |
179 | 188 | |
— | — | @@ -204,7 +213,10 @@ |
205 | 214 | } |
206 | 215 | |
207 | 216 | /* Try opening the logging file */ |
| 217 | + /* Set recursion_guard==2 whenever we're doing something to the log file */ |
| 218 | + WMERRORS_G(recursion_guard) = 2; |
208 | 219 | logfile_stream = open_logging_file( WMERRORS_G(logging_file) ); |
| 220 | + WMERRORS_G(recursion_guard) = 1; |
209 | 221 | if ( !logfile_stream ) { |
210 | 222 | return; |
211 | 223 | } |
— | — | @@ -226,7 +238,10 @@ |
227 | 239 | zend_fetch_debug_backtrace(trace, 0, 0 TSRMLS_CC); |
228 | 240 | zend_print_zval_r_ex(wmerrors_write_trace, trace, 4 TSRMLS_CC); |
229 | 241 | FREE_ZVAL(trace); |
| 242 | + |
| 243 | + WMERRORS_G(recursion_guard) = 2; |
230 | 244 | php_stream_write(logfile_stream, WMERRORS_G(log_buffer).c, WMERRORS_G(log_buffer).len TSRMLS_CC); |
| 245 | + WMERRORS_G(recursion_guard) = 1; |
231 | 246 | } |
232 | 247 | |
233 | 248 | php_stream_close( logfile_stream ); |
Index: trunk/php/wmerrors/php_wmerrors.h |
— | — | @@ -29,6 +29,7 @@ |
30 | 30 | int recursion_guard; |
31 | 31 | int enabled; |
32 | 32 | long int log_level; |
| 33 | + int ignore_logging_errors; |
33 | 34 | smart_str log_buffer; |
34 | 35 | ZEND_END_MODULE_GLOBALS(wmerrors) |
35 | 36 | |