mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2025-12-10 05:39:38 +05:00
oh shit concurrent map writes hope this fixes it
This commit is contained in:
8
main.go
8
main.go
@@ -111,14 +111,20 @@ func (pr *pooledReader) Close() error {
|
|||||||
type pooledFs struct {
|
type pooledFs struct {
|
||||||
filesystem fs.FS
|
filesystem fs.FS
|
||||||
pools map[string]*sync.Pool
|
pools map[string]*sync.Pool
|
||||||
|
mut sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pooledFs) Open(name string) (*pooledReader, error) {
|
func (p *pooledFs) Open(name string) (*pooledReader, error) {
|
||||||
|
p.mut.RLock()
|
||||||
pool := p.pools[name]
|
pool := p.pools[name]
|
||||||
|
p.mut.RUnlock()
|
||||||
|
|
||||||
if pool == nil {
|
if pool == nil {
|
||||||
misc.Log("pool is nil for", name)
|
misc.Log("pool is nil for", name)
|
||||||
pool = &sync.Pool{}
|
pool = &sync.Pool{}
|
||||||
|
p.mut.Lock()
|
||||||
p.pools[name] = pool
|
p.pools[name] = pool
|
||||||
|
p.mut.Unlock()
|
||||||
|
|
||||||
goto new
|
goto new
|
||||||
}
|
}
|
||||||
@@ -140,7 +146,7 @@ func ServeFS(r *fiber.App, filesystem fs.FS) {
|
|||||||
cm := parseCompressionMaps(filesystem)
|
cm := parseCompressionMaps(filesystem)
|
||||||
misc.Log(cm)
|
misc.Log(cm)
|
||||||
|
|
||||||
pfs := &pooledFs{filesystem, make(map[string]*sync.Pool)}
|
pfs := &pooledFs{filesystem, make(map[string]*sync.Pool), sync.RWMutex{}}
|
||||||
|
|
||||||
const path = "/_/static/"
|
const path = "/_/static/"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user