forked from MTSR/mapserver
no deadlock with tiledb r/w mutex
This commit is contained in:
parent
3f3a9da23a
commit
5d87c7ebbe
@ -5,8 +5,11 @@ import (
|
|||||||
"mapserver/coords"
|
"mapserver/coords"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var mutex = &sync.RWMutex{}
|
||||||
|
|
||||||
func New(path string) (*TileDB, error) {
|
func New(path string) (*TileDB, error) {
|
||||||
return &TileDB{
|
return &TileDB{
|
||||||
path: path,
|
path: path,
|
||||||
@ -32,6 +35,9 @@ func (this *TileDB) GC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *TileDB) GetTile(pos *coords.TileCoords) ([]byte, error) {
|
func (this *TileDB) GetTile(pos *coords.TileCoords) ([]byte, error) {
|
||||||
|
mutex.RLock()
|
||||||
|
defer mutex.RUnlock()
|
||||||
|
|
||||||
_, file := this.getDirAndFile(pos)
|
_, file := this.getDirAndFile(pos)
|
||||||
info, _ := os.Stat(file)
|
info, _ := os.Stat(file)
|
||||||
if info != nil {
|
if info != nil {
|
||||||
@ -47,6 +53,9 @@ func (this *TileDB) GetTile(pos *coords.TileCoords) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *TileDB) SetTile(pos *coords.TileCoords, tile []byte) error {
|
func (this *TileDB) SetTile(pos *coords.TileCoords, tile []byte) error {
|
||||||
|
mutex.Lock()
|
||||||
|
defer mutex.Unlock()
|
||||||
|
|
||||||
dir, file := this.getDirAndFile(pos)
|
dir, file := this.getDirAndFile(pos)
|
||||||
os.MkdirAll(dir, 0700)
|
os.MkdirAll(dir, 0700)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user