graph-gophers / dataloader

Implementation of Facebook's DataLoader in Golang
MIT License
1.21k stars 75 forks source link

Fix Race Condition in Thunks #16

Closed telrikk closed 7 years ago

telrikk commented 7 years ago

A race condition occurs if one goroutine writes to result.value while another is attempting to read it. This patch forces the acquisition of the result's RWMutex read lock before it reads the value.

Let me know if that makes sense!


This change is Reviewable

codecov[bot] commented 7 years ago

Codecov Report

Merging #16 into master will increase coverage by 0.1%. The diff coverage is 100%.

@@            Coverage Diff            @@
##           master      #16     +/-   ##
=========================================
+ Coverage   96.42%   96.53%   +0.1%     
=========================================
  Files           2        2             
  Lines         196      202      +6     
=========================================
+ Hits          189      195      +6     
  Misses          7        7

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2434ed4...07d84bb. Read the comment docs.