Commit Graph

15 Commits

Author SHA1 Message Date
Brian Tiger Chow e151fe9493 fix ReadAt 2018-11-20 13:34:41 -05:00
Bjørn Erik Pedersen 787d034dfe Return error in Readdir on regular mem file
Fixes #169
2018-05-31 11:51:01 +02:00
Bjørn Erik Pedersen ec3a3111d1
mem: Make the File return io.ErrUnexpectedEOF
Instead of panic when reading beyond its borders.

This is in line with how the OS File works.

Fixes #152
2017-12-28 12:02:27 +01:00
Corentin Debains d29940f63d mem/file.go - Fix some races in accessing fields of FileData
* Splitting SetModeTime to avoid double locking
* Adding locks all over the place.
2017-09-30 22:59:59 -07:00
Sotirios Mantziaris 72b3142684 Eliminate go vet warnings 2017-01-09 23:53:20 +01:00
Jamie Wilkinson 52e4a6cfac Fixes a pass-by-value error in FileData.Name()
Fixes a pass-by-value error in FileData.Name() which causes the mutex to be copied, and use that method to retrieve the name of the file from a mem.File.  This really fixes the data race that motivated PR #95. (#96)

I can't explain why moving the lock improves the situation, nor why calling through the accessor Name() instead of locking and reading f.fileData.name is not the same, but go vet indicates that the mutex in fileData was being copied, not preserved.

The reproducing test case upstream is:
check out github.com/google/mtail
make install_deps
go test -race -timeout 1m -v -run TestProcessEvents --count=10000 ./vm

Prior to this change, the test reports a data race 3 times out of 10000, after, 0 times consistently.
2016-09-19 23:01:14 +02:00
Jamie Wilkinson 40ffa2c25c Fixes a data race caused by not locking the mem.FileData for read access. 2016-08-20 23:27:14 +10:00
Hanno Hecker bb3fe39966 set modtime on any write 2016-01-04 19:34:24 +01:00
Martin Bertschler f0b9fc1bdb Implement and test read only MemMapFs file handles
Fixes #53
2016-01-04 01:54:48 +01:00
Martin Bertschler a5f01f1106 replace mem.File handles with mem.FileData when mem.FileData is all we need 2016-01-04 00:36:01 +01:00
Martin Bertschler 0321b04b21 fix mem.DirMap and mem.Dir to only use *FileData and not *File handles 2016-01-04 00:18:26 +01:00
Martin Bertschler 7096d68458 mem.File is now mem.FileData and mem.File is a file handle with a pointer to a mem.FileData 2016-01-03 23:59:42 +01:00
Steve Francia 12f79b29b2 Update mem to keep things private 2015-12-10 15:13:36 -05:00
Martin Bertschler 37f7afc8d7 Fix artefacts from moving MemMapFs types into subpackage mem 2015-12-10 18:55:43 +01:00
Steve Francia 965d098e7c Moving memory structures and interfaces into sub package 2015-12-10 12:26:38 -05:00