diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-04-17 22:52:02 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-04-17 22:52:02 +0000 |
commit | ce9995a57949a447f2f5b6f63b8b058fd1e08931 (patch) | |
tree | b87a6ae7ee77c39ff1db6555d137286428fa0562 | |
parent | cf84759b4b51bfc42ef9b6b968e9704d9f3ddb6c (diff) | |
download | tor-ce9995a57949a447f2f5b6f63b8b058fd1e08931.tar.gz tor-ce9995a57949a447f2f5b6f63b8b058fd1e08931.zip |
Replace an infinite-stack-recursion bug with a generate-infinite-debug-messages bug. Maybe it isnt such a good idea to send LOG_DEBUG messages to the controller after all?
svn:r4082
-rw-r--r-- | src/or/control.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/or/control.c b/src/or/control.c index d5d0cf7eb1..59dc68a026 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -319,6 +319,8 @@ send_control_event(uint16_t event, uint32_t len, const char *body) size_t buflen; char *buf; + tor_assert(event >= _EVENT_MIN && event <= _EVENT_MAX); + buflen = len + 2; buf = tor_malloc_zero(buflen); set_uint16(buf, htons(event)); @@ -1159,19 +1161,27 @@ control_event_bandwidth_used(uint32_t n_read, uint32_t n_written) void control_event_logmsg(int severity, const char *msg) { - int oldlog = EVENT_IS_INTERESTING(EVENT_LOG_OBSOLETE) && + static int sending_logmsg=0; + int oldlog, event; + + if (sending_logmsg) + return; + + oldlog = EVENT_IS_INTERESTING(EVENT_LOG_OBSOLETE) && (severity == LOG_NOTICE || severity == LOG_WARN || severity == LOG_ERR); - int event = log_severity_to_event(severity); + event = log_severity_to_event(severity); if (event<0 || !EVENT_IS_INTERESTING(event)) event = 0; if (oldlog || event) { size_t len = strlen(msg); + sending_logmsg = 1; if (event) send_control_event(event, (uint32_t)(len+1), msg); if (oldlog) send_control_event(EVENT_LOG_OBSOLETE, (uint32_t)(len+1), msg); + sending_logmsg = 0; } } @@ -1228,4 +1238,3 @@ init_cookie_authentication(int enabled) return 0; } - |