Method
Close
()
Source from the content-addressed store, hash-verified
| 124 | } |
| 125 | |
| 126 | func (l *LogWriter) Close() error { |
| 127 | if l == nil { |
| 128 | return nil |
| 129 | } |
| 130 | // close all go routines first before acquiring the lock to avoid contention |
| 131 | l.closer.SignalAndWait() |
| 132 | |
| 133 | l.mu.Lock() |
| 134 | defer l.mu.Unlock() |
| 135 | if l.file == nil { |
| 136 | return nil |
| 137 | } |
| 138 | l.flush() |
| 139 | close(l.manageChannel) |
| 140 | _ = l.file.Close() |
| 141 | l.writer = nil |
| 142 | l.file = nil |
| 143 | return nil |
| 144 | } |
| 145 | |
| 146 | // flushPeriodic periodically flushes the log file buffers. |
| 147 | func (l *LogWriter) flushPeriodic() { |