Bug fix, no lock on actors variable, enabling Pleroma statistics

This commit is contained in:
Farhan Khan 2023-07-19 15:55:16 -04:00
parent e6937f733e
commit f041f0443e
Signed by untrusted user who does not match committer: farhan
GPG Key ID: 45FE45AD7E54F59B
2 changed files with 11 additions and 7 deletions

View File

@ -263,7 +263,9 @@ func check_actor(uri string) *ActorJson {
logWarn("Unable to unmarshal body from ", uri) logWarn("Unable to unmarshal body from ", uri)
return nil // Unable to unmarshal body of message return nil // Unable to unmarshal body of message
} }
o.Recentactors.Mu.Lock()
o.Recentactors.Add(uri, actorjson) o.Recentactors.Add(uri, actorjson)
o.Recentactors.Mu.Unlock()
var bot bool var bot bool
if actorjson.Type == "Service" { if actorjson.Type == "Service" {
@ -278,6 +280,8 @@ func check_actor(uri string) *ActorJson {
return nil // Unable to insert actor return nil // Unable to insert actor
} }
o.Recentactors.Mu.Lock()
o.Recentactors.Add(uri, actorjson) o.Recentactors.Add(uri, actorjson)
o.Recentactors.Mu.Unlock()
return actorjson // Successful return actorjson // Successful
} }

View File

@ -155,12 +155,12 @@ func StreamPleroma(endpoint string) {
return return
} }
// ri_mutex.Lock() ri_mutex.Lock()
// m := runninginstances[endpoint] m := runninginstances[endpoint]
// m.Status = shared.RUNNING m.Status = shared.RUNNING
// m.LastRun = "Streaming" m.LastRun = "Streaming"
// runninginstances[endpoint] = m runninginstances[endpoint] = m
// ri_mutex.Unlock() ri_mutex.Unlock()
for { for {
logDebug("Starting Pleroma Stream loop for ", endpoint) logDebug("Starting Pleroma Stream loop for ", endpoint)
@ -264,7 +264,7 @@ func StreamMastodon(endpoint string, o *shared.RunningInstance) {
s := bufio.NewScanner(resp.Body) s := bufio.NewScanner(resp.Body)
var name string var name string
for s.Scan() { for s.Scan() {
logDebug("Ending Mastodon stream loop for ", endpoint) logDebug("Starting Mastodon stream loop for ", endpoint)
line := s.Text() line := s.Text()
token := strings.SplitN(line, ":", 2) token := strings.SplitN(line, ":", 2)
var newactivity shared.ReportActivity var newactivity shared.ReportActivity