Skip to content

Commit 1d0eb0a

Browse files
committed
Add a mutex to avoid map concurrent access
1 parent 2aedad1 commit 1d0eb0a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

builder_utils/utils.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ func compileFilesWithRecipe(ctx *types.Context, objectFiles []string, sourcePath
207207
}
208208
}
209209

210+
var warningCacheMutex sync.Mutex
211+
210212
func compileFileWithRecipe(ctx *types.Context, sourcePath string, source string, buildPath string, buildProperties properties.Map, includes []string, recipe string) (string, error) {
211213
logger := ctx.GetLogger()
212214
properties := buildProperties.Clone()
@@ -234,7 +236,9 @@ func compileFileWithRecipe(ctx *types.Context, sourcePath string, source string,
234236
if err != nil {
235237
return "", i18n.WrapError(err)
236238
}
239+
warningCacheMutex.Lock()
237240
ctx.WarningsCache[source] = string(stderrCache)
241+
warningCacheMutex.Unlock()
238242
} else {
239243
if ctx.Verbose {
240244
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_USING_PREVIOUS_COMPILED_FILE, properties[constants.BUILD_PROPERTIES_OBJECT_FILE])

0 commit comments

Comments
 (0)