This patch protects an internal map for concurrent use. (*LogFile).Writes() method calls (*LogFile).createMeasurementIfNotExists() which writes to a shared map. (*LogFile).Writes() acquires a read-lock which leaves createMeasurementIfNotExists() open to concurrent writes to its shared map. This commit adds the ExecEntries method to the *LogFile type so that we can properly lock calls to (*LogFile).appendEntry() using defer. (*LogFile).ExecEntries() is used to mostly replace the body of (*LogFile).Writes() and incurs another function call since ExecEntries() can't be inlined. Below is the output of build with "-m -m -m" gcflags: ./log_file.go:1076:6: cannot inline (*LogFile).ExecEntries: unhandled op DEFER The performace impact of the additional function call should be negligable and is outwieghed by the safety and simplicity of using defer. |
||
---|---|---|
.. | ||
inmem | ||
internal | ||
tsi1 | ||
index.go |