commit e34e7bd7151fabcdcef72ace3c0dd8754e265b75
parent 9106fd2c51dcec175b04e44611d88921f9b6369c
Author: Matsuda Kenji <info@mtkn.jp>
Date: Fri, 29 Dec 2023 09:44:55 +0900
unexport FidPool
Diffstat:
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/export_test.go b/export_test.go
@@ -74,6 +74,7 @@ func (fid *Fid) File() File { return fid.file }
func (fid *Fid) SetFile(f File) { fid.file = f }
func (fid *Fid) SetOmode(m OpenMode) { fid.omode = m }
+type FidPool = fidPool
func (fp *FidPool) Lookup(fid uint32) (*Fid, bool) { return fp.lookup(fid) }
func (fp *FidPool) Add(fid uint32) (*Fid, error) { return fp.add(fid) }
func (fp *FidPool) Delete(fid uint32) { fp.delete(fid) }
diff --git a/fid.go b/fid.go
@@ -46,29 +46,29 @@ func (f *fid) String() string {
return fmt.Sprintf("%d", fid)
}
-// FidPool is a pool of fid.
+// fidPool is a pool of fid.
// It is used to track the fid in the file system the server is exporting.
-type FidPool struct {
+type fidPool struct {
m map[uint32]*fid
lock *sync.Mutex
}
-// newFidPool allocates an FidPool.
-func newFidPool() *FidPool {
- return &FidPool{
+// newFidPool allocates an fidPool.
+func newFidPool() *fidPool {
+ return &fidPool{
m: make(map[uint32]*fid),
lock: new(sync.Mutex),
}
}
-func (pool *FidPool) lookup(id uint32) (*fid, bool) {
+func (pool *fidPool) lookup(id uint32) (*fid, bool) {
pool.lock.Lock()
defer pool.lock.Unlock()
f, ok := pool.m[id]
return f, ok
}
-func (pool *FidPool) add(id uint32) (*fid, error) {
+func (pool *fidPool) add(id uint32) (*fid, error) {
pool.lock.Lock()
defer pool.lock.Unlock()
if _, ok := pool.m[id]; ok {
@@ -79,15 +79,15 @@ func (pool *FidPool) add(id uint32) (*fid, error) {
return f, nil
}
-func (pool *FidPool) delete(id uint32) {
+func (pool *fidPool) delete(id uint32) {
pool.lock.Lock()
defer pool.lock.Unlock()
delete(pool.m, id)
}
-func (pool *FidPool) String() string {
- s := "&FidPool{\n"
+func (pool *fidPool) String() string {
+ s := "&fidPool{\n"
for fnum, fstruct := range pool.m {
if fstruct.file == nil {
s += fmt.Sprintf(" %d: <nil>\n", fnum)
diff --git a/server.go b/server.go
@@ -43,7 +43,7 @@ type Server struct {
mSizeLock *sync.Mutex
// FidPool of the Server.
- fPool *FidPool
+ fPool *fidPool
// Pending Requests the server is dealing with.
rPool *reqPool