@@ -380,6 +380,7 @@ func (this *FileStorage) openReader(key string, allowMemory bool, useStale bool,
380380
381381 // 检查文件记录是否已过期
382382 var estimatedSize int64
383+ var existInList bool
383384 if ! useStale {
384385 exists , filesize , err := this .list .Exist (hash )
385386 if err != nil {
@@ -389,6 +390,7 @@ func (this *FileStorage) openReader(key string, allowMemory bool, useStale bool,
389390 return nil , ErrNotFound
390391 }
391392 estimatedSize = filesize
393+ existInList = true
392394 }
393395
394396 // 尝试通过MMAP读取
@@ -412,7 +414,13 @@ func (this *FileStorage) openReader(key string, allowMemory bool, useStale bool,
412414
413415 var err error
414416 if openFile == nil {
417+ if existInList {
418+ fsutils .ReaderLimiter .Ack ()
419+ }
415420 fp , err = os .OpenFile (path , os .O_RDONLY , 0444 )
421+ if existInList {
422+ fsutils .ReaderLimiter .Release ()
423+ }
416424 if err != nil {
417425 if ! os .IsNotExist (err ) {
418426 return nil , err
@@ -583,7 +591,7 @@ func (this *FileStorage) openWriter(key string, expiredAt int64, status int, hea
583591 // 数据库中是否存在
584592 existsCacheItem , _ , _ := this .list .Exist (hash )
585593 if existsCacheItem {
586- readerFp , err := os .OpenFile (tmpPath , os .O_RDONLY , 0444 )
594+ readerFp , err := fsutils .OpenFile (tmpPath , os .O_RDONLY , 0444 )
587595 if err == nil {
588596 var partialReader = NewPartialFileReader (readerFp )
589597 err = partialReader .Init ()
@@ -616,8 +624,10 @@ func (this *FileStorage) openWriter(key string, expiredAt int64, status int, hea
616624 if isNewCreated && existsFile {
617625 flags |= os .O_TRUNC
618626 }
619- if ! isFlushing && ! fsutils .WriterLimiter .TryAck () {
620- return nil , ErrServerIsBusy
627+ if ! isFlushing {
628+ if ! fsutils .WriterLimiter .TryAck () {
629+ return nil , ErrServerIsBusy
630+ }
621631 }
622632 writer , err := os .OpenFile (tmpPath , flags , 0666 )
623633 if ! isFlushing {
0 commit comments