From 9a249a92e99ffaab4b0e43ee1c3da4aa3756a350 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Fri, 22 Feb 2019 14:10:41 +0100 Subject: [PATCH] fix tile glitch --- server/.gitignore | 1 + server/tiledb/logger.go | 11 +++++++++++ server/tiledb/tiledb.go | 12 ++++++++++++ server/tilerendererjob/common.go | 5 ++++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 server/tiledb/logger.go diff --git a/server/.gitignore b/server/.gitignore index 734d68b..31cfd9e 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -6,3 +6,4 @@ mapserver.tiles mapserver.sqlite mapserver.sqlite-journal mapserver.json +debug.txt diff --git a/server/tiledb/logger.go b/server/tiledb/logger.go new file mode 100644 index 0000000..1f24934 --- /dev/null +++ b/server/tiledb/logger.go @@ -0,0 +1,11 @@ +package tiledb + +import ( + "github.com/sirupsen/logrus" +) + +var log *logrus.Entry + +func init() { + log = logrus.WithFields(logrus.Fields{"prefix": "tiledb"}) +} diff --git a/server/tiledb/tiledb.go b/server/tiledb/tiledb.go index e0de68d..8709594 100644 --- a/server/tiledb/tiledb.go +++ b/server/tiledb/tiledb.go @@ -6,6 +6,7 @@ import ( "os" "strconv" "sync" + "github.com/sirupsen/logrus" ) var mutex = &sync.RWMutex{} @@ -38,6 +39,11 @@ func (this *TileDB) GetTile(pos *coords.TileCoords) ([]byte, error) { mutex.RLock() defer mutex.RUnlock() + fields := logrus.Fields{ + "pos": pos, + } + log.WithFields(fields).Debug("GetTile") + _, file := this.getDirAndFile(pos) info, _ := os.Stat(file) if info != nil { @@ -56,6 +62,12 @@ func (this *TileDB) SetTile(pos *coords.TileCoords, tile []byte) error { mutex.Lock() defer mutex.Unlock() + fields := logrus.Fields{ + "pos": pos, + "size": len(tile), + } + log.WithFields(fields).Debug("SetTile") + dir, file := this.getDirAndFile(pos) os.MkdirAll(dir, 0700) diff --git a/server/tilerendererjob/common.go b/server/tilerendererjob/common.go index 673175a..3b914c7 100644 --- a/server/tilerendererjob/common.go +++ b/server/tilerendererjob/common.go @@ -72,7 +72,10 @@ func renderMapblocks(ctx *app.App, mblist []*mapblockparser.MapBlock) int { //spin down worker pool close(jobs) - <-done + + for j := 0; j < ctx.Config.RenderingJobs; j++ { + <-done + } } return tilecount