summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-13 20:18:05 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-13 20:18:10 -0400
commit9c90526a24f32a00ad35073a09839189eb8aa007 (patch)
treecd8aa746d88512bb44a1c8e69f73a4e63e7af772
parent88dbd876a9635fa515ed29875816d05975272597 (diff)
downloadgetwtxt-9c90526a24f32a00ad35073a09839189eb8aa007.tar.gz
removed mutex from remoteRegistries
slices are safe to use concurrently already.
leaving as a struct for possible expansion later.
-rw-r--r--svc/cache.go3
-rw-r--r--svc/db_test.go2
-rw-r--r--svc/init.go2
-rw-r--r--svc/leveldb.go6
-rw-r--r--svc/post.go2
-rw-r--r--svc/sqlite.go6
6 files changed, 0 insertions, 21 deletions
diff --git a/svc/cache.go b/svc/cache.go
index 7bad078..c51478b 100644
--- a/svc/cache.go
+++ b/svc/cache.go
@@ -20,7 +20,6 @@ import (
 // periodically scrape for new users. The remote registries
 // must have been added via POST like a user.
 type RemoteRegistries struct {
-	Mu   sync.RWMutex
 	List []string
 }
 
@@ -59,11 +58,9 @@ func cacheUpdate() {
 	}
 	twtxtCache.Mu.RUnlock()
 
-	remoteRegistries.Mu.RLock()
 	for _, v := range remoteRegistries.List {
 		errLog("Error refreshing local copy of remote registry data: ", twtxtCache.CrawlRemoteRegistry(v))
 	}
-	remoteRegistries.Mu.RUnlock()
 }
 
 // pingAssets checks if the local static assets
diff --git a/svc/db_test.go b/svc/db_test.go
index abf7626..3c0abdf 100644
--- a/svc/db_test.go
+++ b/svc/db_test.go
@@ -23,9 +23,7 @@ func Test_pushpullDatabase(t *testing.T) {
 
 	twtxtCache.AddUser("gbmor", "https://gbmor.dev/twtxt.txt", "", net.ParseIP("127.0.0.1"), statusmap)
 
-	remoteRegistries.Mu.Lock()
 	remoteRegistries.List = append(remoteRegistries.List, "https://twtxt.tilde.institute/api/plain/users")
-	remoteRegistries.Mu.Unlock()
 
 	t.Run("Push to Database", func(t *testing.T) {
 		err := pushDB()
diff --git a/svc/init.go b/svc/init.go
index fe83145..edd081c 100644
--- a/svc/init.go
+++ b/svc/init.go
@@ -5,7 +5,6 @@ import (
 	"log"
 	"os"
 	"os/signal"
-	"sync"
 	"time"
 
 	"github.com/getwtxt/registry"
@@ -47,7 +46,6 @@ var twtxtCache = registry.NewIndex()
 
 // List of other registries submitted to this registry
 var remoteRegistries = &RemoteRegistries{
-	Mu:   sync.RWMutex{},
 	List: make([]string, 0),
 }
 
diff --git a/svc/leveldb.go b/svc/leveldb.go
index 655979a..7446dad 100644
--- a/svc/leveldb.go
+++ b/svc/leveldb.go
@@ -31,11 +31,9 @@ func (lvl *dbLevel) push() error {
 	}
 	twtxtCache.Mu.RUnlock()
 
-	remoteRegistries.Mu.RLock()
 	for k, v := range remoteRegistries.List {
 		dbBasket.Put([]byte("remote*"+string(k)), []byte(v))
 	}
-	remoteRegistries.Mu.RUnlock()
 
 	return lvl.db.Write(dbBasket, nil)
 }
@@ -51,9 +49,7 @@ func (lvl *dbLevel) pull() {
 		field := split[1]
 
 		if urls == "remote" {
-			remoteRegistries.Mu.Lock()
 			remoteRegistries.List = append(remoteRegistries.List, val)
-			remoteRegistries.Mu.Unlock()
 			continue
 		}
 
@@ -90,9 +86,7 @@ func (lvl *dbLevel) pull() {
 		twtxtCache.Mu.Unlock()
 	}
 
-	remoteRegistries.Mu.Lock()
 	remoteRegistries.List = dedupe(remoteRegistries.List)
-	remoteRegistries.Mu.Unlock()
 
 	iter.Release()
 	errLog("Error while pulling DB into registry cache: ", iter.Error())
diff --git a/svc/post.go b/svc/post.go
index 9050859..34ae92f 100644
--- a/svc/post.go
+++ b/svc/post.go
@@ -35,9 +35,7 @@ func apiPostUser(w http.ResponseWriter, r *http.Request) {
 
 	switch remoteRegistry {
 	case true:
-		remoteRegistries.Mu.Lock()
 		remoteRegistries.List = append(remoteRegistries.List, urls)
-		remoteRegistries.Mu.Unlock()
 
 		if err := twtxtCache.CrawlRemoteRegistry(urls); err != nil {
 			errHTTP(w, r, fmt.Errorf("error crawling remote registry: %v", err.Error()), http.StatusInternalServerError)
diff --git a/svc/sqlite.go b/svc/sqlite.go
index dd6d6de..b10e5ae 100644
--- a/svc/sqlite.go
+++ b/svc/sqlite.go
@@ -73,12 +73,10 @@ func (lite *dbSqlite) push() error {
 	}
 	twtxtCache.Mu.RUnlock()
 
-	remoteRegistries.Mu.RLock()
 	for _, e := range remoteRegistries.List {
 		_, err = txst.Exec(e, false, "REMOTE REGISTRY", "NULL")
 		errLog("", err)
 	}
-	remoteRegistries.Mu.RUnlock()
 
 	err = tx.Commit()
 	if err != nil {
@@ -110,9 +108,7 @@ func (lite *dbSqlite) pull() {
 		errLog("", rows.Scan(&uid, &urls, &isUser, &dataKey, &dBlob))
 
 		if !isUser {
-			remoteRegistries.Mu.Lock()
 			remoteRegistries.List = append(remoteRegistries.List, urls)
-			remoteRegistries.Mu.Unlock()
 			continue
 		}
 
@@ -142,7 +138,5 @@ func (lite *dbSqlite) pull() {
 	}
 	twtxtCache.Mu.Unlock()
 
-	remoteRegistries.Mu.Lock()
 	remoteRegistries.List = dedupe(remoteRegistries.List)
-	remoteRegistries.Mu.Unlock()
 }
bel v2-8-2dev_21' href='/ingrix/lynx-snapshots/commit/src/LYexit.c?id=327b7c16889c9d95ec076d695c970da11dc32a2b'>327b7c16 ^
c3ec4181 ^

327b7c16 ^





c3ec4181 ^
327b7c16 ^









e087f6d4
e087f6d4
c3ec4181 ^






e087f6d4
c3ec4181 ^



e4409c40 ^
a2a1ab1e ^





b6d1143c ^
e4409c40 ^
c3ec4181 ^


b6d1143c ^
e4409c40 ^
b6d1143c ^
e4409c40 ^
c3ec4181 ^


e4409c40 ^
c3ec4181 ^
e4409c40 ^
c3ec4181 ^



b6d1143c ^
c3ec4181 ^



e087f6d4

c3ec4181 ^
e087f6d4
c3ec4181 ^
d70fdcf7 ^
c3ec4181 ^


e4409c40 ^
c3ec4181 ^
e4409c40 ^
c3ec4181 ^









e087f6d4
2b52e9e6 ^


e087f6d4
fe769404 ^

e087f6d4
c3ec4181 ^

e087f6d4


b232e99a ^
c3ec4181 ^
b63d287c ^
c3ec4181 ^




d3f9d547 ^
c3ec4181 ^

e087f6d4

d3f9d547 ^







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179