Reverting moving LockOSThread to main module.
This commit is contained in:
parent
0392f510f5
commit
93d2bb7fc1
4
cache/cache_profiles.go
vendored
4
cache/cache_profiles.go
vendored
@ -40,7 +40,9 @@ func (c *Cache) deleteProfile(data map[string]string) {
|
|||||||
_, ok1 := c.Profiles[data["profile_name"]]
|
_, ok1 := c.Profiles[data["profile_name"]]
|
||||||
if !ok1 {
|
if !ok1 {
|
||||||
fmt.Println("Profile deleted")
|
fmt.Println("Profile deleted")
|
||||||
|
Database.Unlock()
|
||||||
Database.Db.MustExec(Database.Db.Rebind("DELETE FROM urt_profiles WHERE name=?"), data["profile_name"])
|
Database.Db.MustExec(Database.Db.Rebind("DELETE FROM urt_profiles WHERE name=?"), data["profile_name"])
|
||||||
|
Database.Lock()
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Something goes wrong! Profile is still here!")
|
fmt.Println("Something goes wrong! Profile is still here!")
|
||||||
}
|
}
|
||||||
@ -75,6 +77,7 @@ func (c *Cache) FlushProfiles(data map[string]string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Database.Unlock()
|
||||||
tx := Database.Db.MustBegin()
|
tx := Database.Db.MustBegin()
|
||||||
fmt.Println("Adding new profiles...")
|
fmt.Println("Adding new profiles...")
|
||||||
for _, profile := range new_profiles {
|
for _, profile := range new_profiles {
|
||||||
@ -85,6 +88,7 @@ func (c *Cache) FlushProfiles(data map[string]string) {
|
|||||||
tx.NamedExec("UPDATE urt_profiles SET name=:name, version=:version, binary=:binary, second_x_session=:second_x_session, additional_parameters=:additional_parameters WHERE name=:name", &profile)
|
tx.NamedExec("UPDATE urt_profiles SET name=:name, version=:version, binary=:binary, second_x_session=:second_x_session, additional_parameters=:additional_parameters WHERE name=:name", &profile)
|
||||||
}
|
}
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
Database.Lock()
|
||||||
fmt.Println("Done")
|
fmt.Println("Done")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
cache/cache_servers.go
vendored
2
cache/cache_servers.go
vendored
@ -85,6 +85,7 @@ func (c *Cache) FlushServers(data map[string]string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Database.Unlock()
|
||||||
tx := Database.Db.MustBegin()
|
tx := Database.Db.MustBegin()
|
||||||
fmt.Println("Adding new servers...")
|
fmt.Println("Adding new servers...")
|
||||||
if len(new_servers) > 0 {
|
if len(new_servers) > 0 {
|
||||||
@ -101,6 +102,7 @@ func (c *Cache) FlushServers(data map[string]string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
Database.Lock()
|
||||||
fmt.Println("Done")
|
fmt.Println("Done")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
//"database/sql"
|
//"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
// local
|
// local
|
||||||
@ -48,10 +49,12 @@ func (d *Database) Close() {
|
|||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
||||||
d.Db.Close()
|
d.Db.Close()
|
||||||
|
runtime.UnlockOSThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Database) Initialize(cfg *configuration.Config) {
|
func (d *Database) Initialize(cfg *configuration.Config) {
|
||||||
fmt.Println("Initializing database...")
|
fmt.Println("Initializing database...")
|
||||||
|
runtime.LockOSThread()
|
||||||
|
|
||||||
// Connect to database.
|
// Connect to database.
|
||||||
db_path := path.Join(cfg.TEMP["DATA"], "database.sqlite3")
|
db_path := path.Join(cfg.TEMP["DATA"], "database.sqlite3")
|
||||||
@ -72,6 +75,10 @@ func (d *Database) Initialize(cfg *configuration.Config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Database) Lock() {
|
||||||
|
runtime.LockOSThread()
|
||||||
|
}
|
||||||
|
|
||||||
func (d *Database) Migrate() {
|
func (d *Database) Migrate() {
|
||||||
// Getting current database version.
|
// Getting current database version.
|
||||||
dbver := 0
|
dbver := 0
|
||||||
@ -87,3 +94,7 @@ func (d *Database) Migrate() {
|
|||||||
|
|
||||||
migrate_full(d, dbver)
|
migrate_full(d, dbver)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Database) Unlock() {
|
||||||
|
runtime.UnlockOSThread()
|
||||||
|
}
|
||||||
|
@ -25,7 +25,6 @@ func main() {
|
|||||||
|
|
||||||
numCPUs := runtime.NumCPU()
|
numCPUs := runtime.NumCPU()
|
||||||
runtime.GOMAXPROCS(numCPUs)
|
runtime.GOMAXPROCS(numCPUs)
|
||||||
runtime.LockOSThread()
|
|
||||||
|
|
||||||
ctx := context.New()
|
ctx := context.New()
|
||||||
ctx.Initialize()
|
ctx.Initialize()
|
||||||
|
Reference in New Issue
Block a user