瀏覽代碼

Don't block main thread when writing access log.

V2Ray 10 年之前
父節點
當前提交
c7c493f20e
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      common/log/access.go

+ 5 - 1
common/log/access.go

@@ -42,11 +42,15 @@ func (logger *fileAccessLogger) close() {
 }
 }
 
 
 func (logger *fileAccessLogger) Log(from, to string, status AccessStatus, reason string) {
 func (logger *fileAccessLogger) Log(from, to string, status AccessStatus, reason string) {
-	logger.queue <- &accessLog{
+	select {
+	case logger.queue <- &accessLog{
 		From:   from,
 		From:   from,
 		To:     to,
 		To:     to,
 		Status: status,
 		Status: status,
 		Reason: reason,
 		Reason: reason,
+	}:
+	default:
+		// We don't expect this to happen, but don't want to block main thread as well.
 	}
 	}
 }
 }