소스 검색

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) {
-	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.
 	}
 }