mirror of
				https://github.com/taigrr/bitcask
				synced 2025-01-18 04:03:17 -08:00 
			
		
		
		
	Fix a data race in Datafile.ReadAt()
This commit is contained in:
		
							parent
							
								
									f4cc0fb434
								
							
						
					
					
						commit
						40425394d7
					
				| @ -6,9 +6,9 @@ import ( | ||||
| 	"path/filepath" | ||||
| 	"sync" | ||||
| 
 | ||||
| 	"github.com/pkg/errors" | ||||
| 	"git.mills.io/prologic/bitcask/internal" | ||||
| 	"git.mills.io/prologic/bitcask/internal/data/codec" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"golang.org/x/exp/mmap" | ||||
| ) | ||||
| 
 | ||||
| @ -159,6 +159,9 @@ func (df *datafile) ReadAt(index, size int64) (e internal.Entry, err error) { | ||||
| 
 | ||||
| 	b := make([]byte, size) | ||||
| 
 | ||||
| 	df.RLock() | ||||
| 	defer df.RUnlock() | ||||
| 
 | ||||
| 	if df.ra != nil { | ||||
| 		n, err = df.ra.ReadAt(b, index) | ||||
| 	} else { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user