mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-29 11:40:24 +08:00
优化并发读写限制
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
package fsutils
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func Remove(filename string) (err error) {
|
||||
WriterLimiter.Ack()
|
||||
@@ -31,3 +33,24 @@ func WriteFile(filename string, data []byte, perm os.FileMode) (err error) {
|
||||
WriterLimiter.Release()
|
||||
return
|
||||
}
|
||||
|
||||
func OpenFile(name string, flag int, perm os.FileMode) (f *os.File, err error) {
|
||||
if flag&os.O_RDONLY == os.O_RDONLY {
|
||||
ReaderLimiter.Ack()
|
||||
}
|
||||
|
||||
f, err = os.OpenFile(name, flag, perm)
|
||||
|
||||
if flag&os.O_RDONLY == os.O_RDONLY {
|
||||
ReaderLimiter.Release()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func Open(name string) (f *os.File, err error) {
|
||||
ReaderLimiter.Ack()
|
||||
f, err = os.Open(name)
|
||||
ReaderLimiter.Release()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user