lightningd: fix logging of peer death.

We used level -1 to mean "append to log", but that doesn't actually
work, and results in an assert if we try to prune the logs:

	lightningd: daemon/pseudorand.c:36: pseudorand: Assertion `max' failed.

Expose logv_add and use that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-06-20 10:09:17 +09:30
parent 5b1d60839a
commit 9327aa1df4
3 changed files with 4 additions and 3 deletions

View File

@ -235,7 +235,7 @@ void log_io(struct log *log, bool in, const void *data, size_t len)
errno = save_errno;
}
static void do_log_add(struct log *log, const char *fmt, va_list ap)
void logv_add(struct log *log, const char *fmt, va_list ap)
{
struct log_entry *l = list_tail(&log->lr->log, struct log_entry, list);
size_t oldlen = strlen(l->log);
@ -266,7 +266,7 @@ void log_add(struct log *log, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
do_log_add(log, fmt, ap);
logv_add(log, fmt, ap);
va_end(ap);
}

View File

@ -42,6 +42,7 @@ void log_(struct log *log, enum log_level level, const char *fmt, ...)
PRINTF_FMT(3,4);
void log_add(struct log *log, const char *fmt, ...) PRINTF_FMT(2,3);
void logv(struct log *log, enum log_level level, const char *fmt, va_list ap);
void logv_add(struct log *log, const char *fmt, va_list ap);
void log_blob_(struct log *log, int level, const char *fmt,
size_t len, ...)

View File

@ -112,7 +112,7 @@ void peer_fail(struct peer *peer, const char *fmt, ...)
va_start(ap, fmt);
log_info(peer->log, "Peer failure in %s: ",
peer_state_name(peer->state));
logv(peer->log, -1, fmt, ap);
logv_add(peer->log, fmt, ap);
va_end(ap);
/* If we haven't reached awaiting locked, we don't need to reconnect */