diff --git a/cache/cache_profiles.go b/cache/cache_profiles.go index e227779..2d09aa4 100644 --- a/cache/cache_profiles.go +++ b/cache/cache_profiles.go @@ -40,9 +40,7 @@ func (c *Cache) deleteProfile(data map[string]string) { _, ok1 := c.Profiles[data["profile_name"]] if !ok1 { fmt.Println("Profile deleted") - Database.Unlock() Database.Db.MustExec(Database.Db.Rebind("DELETE FROM urt_profiles WHERE name=?"), data["profile_name"]) - Database.Lock() } else { fmt.Println("Something goes wrong! Profile is still here!") } @@ -77,7 +75,6 @@ func (c *Cache) FlushProfiles(data map[string]string) { } } - Database.Unlock() tx := Database.Db.MustBegin() fmt.Println("Adding new profiles...") for _, profile := range new_profiles { @@ -88,7 +85,6 @@ 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.Commit() - Database.Lock() fmt.Println("Done") } diff --git a/cache/cache_servers.go b/cache/cache_servers.go index 954bbb8..1c022a7 100644 --- a/cache/cache_servers.go +++ b/cache/cache_servers.go @@ -85,7 +85,6 @@ func (c *Cache) FlushServers(data map[string]string) { } } - Database.Unlock() tx := Database.Db.MustBegin() fmt.Println("Adding new servers...") if len(new_servers) > 0 { @@ -102,7 +101,6 @@ func (c *Cache) FlushServers(data map[string]string) { } tx.Commit() - Database.Lock() fmt.Println("Done") } diff --git a/database/database_object.go b/database/database_object.go index 466064d..bb9e0a3 100644 --- a/database/database_object.go +++ b/database/database_object.go @@ -14,7 +14,6 @@ import ( //"database/sql" "fmt" "path" - "runtime" "strconv" // local @@ -49,12 +48,10 @@ func (d *Database) Close() { tx.Commit() d.Db.Close() - runtime.UnlockOSThread() } func (d *Database) Initialize(cfg *configuration.Config) { fmt.Println("Initializing database...") - runtime.LockOSThread() // Connect to database. db_path := path.Join(cfg.TEMP["DATA"], "database.sqlite3") @@ -75,10 +72,6 @@ func (d *Database) Initialize(cfg *configuration.Config) { } } -func (d *Database) Lock() { - runtime.LockOSThread() -} - func (d *Database) Migrate() { // Getting current database version. dbver := 0 @@ -94,7 +87,3 @@ func (d *Database) Migrate() { migrate_full(d, dbver) } - -func (d *Database) Unlock() { - runtime.UnlockOSThread() -} diff --git a/urtrator.go b/urtrator.go index b0f1d36..0b0fd13 100644 --- a/urtrator.go +++ b/urtrator.go @@ -25,6 +25,7 @@ func main() { numCPUs := runtime.NumCPU() runtime.GOMAXPROCS(numCPUs) + runtime.LockOSThread() ctx := context.New() ctx.Initialize()