Gets the logFile and acquires and RLock() for the mmap. You must call RUnlock on the file (if non-nil)
(vp valuePointer)
| 1509 | // Gets the logFile and acquires and RLock() for the mmap. You must call RUnlock on the file |
| 1510 | // (if non-nil) |
| 1511 | func (vlog *valueLog) getFileRLocked(vp valuePointer) (*logFile, error) { |
| 1512 | vlog.filesLock.RLock() |
| 1513 | defer vlog.filesLock.RUnlock() |
| 1514 | ret, ok := vlog.filesMap[vp.Fid] |
| 1515 | if !ok { |
| 1516 | // log file has gone away, will need to retry the operation. |
| 1517 | return nil, ErrRetry |
| 1518 | } |
| 1519 | |
| 1520 | // Check for valid offset if we are reading from writable log. |
| 1521 | maxFid := vlog.maxFid |
| 1522 | if vp.Fid == maxFid { |
| 1523 | currentOffset := vlog.woffset() |
| 1524 | if vp.Offset >= currentOffset { |
| 1525 | return nil, errors.Errorf( |
| 1526 | "Invalid value pointer offset: %d greater than current offset: %d", |
| 1527 | vp.Offset, currentOffset) |
| 1528 | } |
| 1529 | } |
| 1530 | |
| 1531 | ret.lock.RLock() |
| 1532 | return ret, nil |
| 1533 | } |
| 1534 | |
| 1535 | // Read reads the value log at a given location. |
| 1536 | // TODO: Make this read private. |
no test coverage detected