From c7c493f20e73855fcc24228198ffe23ce6e86c84 Mon Sep 17 00:00:00 2001 From: V2Ray Date: Sun, 11 Oct 2015 16:06:27 +0200 Subject: [PATCH] Don't block main thread when writing access log. --- common/log/access.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/log/access.go b/common/log/access.go index 73b812bbc..516692fac 100644 --- a/common/log/access.go +++ b/common/log/access.go @@ -42,11 +42,15 @@ func (logger *fileAccessLogger) close() { } func (logger *fileAccessLogger) Log(from, to string, status AccessStatus, reason string) { - logger.queue <- &accessLog{ + select { + case logger.queue <- &accessLog{ From: from, To: to, Status: status, Reason: reason, + }: + default: + // We don't expect this to happen, but don't want to block main thread as well. } }