Explorar o código

safer for loop

v2ray %!s(int64=9) %!d(string=hai) anos
pai
achega
3df7634570
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      common/log/log_writer.go

+ 3 - 1
common/log/log_writer.go

@@ -54,9 +54,11 @@ func (this *fileLogWriter) Log(log LogEntry) {
 }
 
 func (this *fileLogWriter) run() {
-	for entry := range this.queue {
+	for {
+		entry := <-this.queue
 		this.logger.Print(entry.String() + platform.LineSeparator())
 		entry.Release()
+		entry = nil
 	}
 }