From f3cfd70e2a8fff7439dfaf6dbb588d79725ac8d4 Mon Sep 17 00:00:00 2001 From: markus Date: Fri, 27 Jul 2018 12:03:17 +0000 Subject: [PATCH] avoid expensive channel_open_message() calls; ok djm@ --- usr.bin/ssh/channels.c | 10 ++++++---- usr.bin/ssh/log.c | 8 +++++++- usr.bin/ssh/log.h | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c index 4b22e179a85..9482e9e4512 100644 --- a/usr.bin/ssh/channels.c +++ b/usr.bin/ssh/channels.c @@ -1,4 +1,4 @@ -/* $OpenBSD: channels.c,v 1.383 2018/07/11 18:53:29 markus Exp $ */ +/* $OpenBSD: channels.c,v 1.384 2018/07/27 12:03:17 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -598,9 +598,11 @@ channel_free(struct ssh *ssh, Channel *c) if (c->type == SSH_CHANNEL_MUX_CLIENT) mux_remove_remote_forwardings(ssh, c); - s = channel_open_message(ssh); - debug3("channel %d: status: %s", c->self, s); - free(s); + if (log_level_get() >= SYSLOG_LEVEL_DEBUG3) { + s = channel_open_message(ssh); + debug3("channel %d: status: %s", c->self, s); + free(s); + } channel_close_fds(ssh, c); sshbuf_free(c->input); diff --git a/usr.bin/ssh/log.c b/usr.bin/ssh/log.c index 36a4659f729..8456bd76d88 100644 --- a/usr.bin/ssh/log.c +++ b/usr.bin/ssh/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.50 2017/05/17 01:24:17 djm Exp $ */ +/* $OpenBSD: log.c,v 1.51 2018/07/27 12:03:17 markus Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -95,6 +95,12 @@ static struct { { NULL, SYSLOG_LEVEL_NOT_SET } }; +LogLevel +log_level_get(void) +{ + return log_level; +} + SyslogFacility log_facility_number(char *name) { diff --git a/usr.bin/ssh/log.h b/usr.bin/ssh/log.h index 7d74927e013..99031b6b6e4 100644 --- a/usr.bin/ssh/log.h +++ b/usr.bin/ssh/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.22 2017/05/17 01:24:17 djm Exp $ */ +/* $OpenBSD: log.h,v 1.23 2018/07/27 12:03:17 markus Exp $ */ /* * Author: Tatu Ylonen @@ -46,6 +46,7 @@ typedef enum { typedef void (log_handler_fn)(LogLevel, const char *, void *); void log_init(char *, LogLevel, SyslogFacility, int); +LogLevel log_level_get(void); int log_change_level(LogLevel); int log_is_on_stderr(void); void log_redirect_stderr_to(const char *); -- 2.20.1