From 96e47f0373b84b6935ce68fcb9c6ac27002ae1a8 Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Fri, 29 Jan 2021 17:44:16 -0500 Subject: [PATCH] Removing GetHTTPSession for GetRunner --- instance.go | 6 +++--- poll.go | 2 +- retrieve.go | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/instance.go b/instance.go index bf98125..b762fc6 100644 --- a/instance.go +++ b/instance.go @@ -26,7 +26,7 @@ func DoTries(o *RunningInstance, req *http.Request) (*http.Response, error) { return resp, err } -func GetRunner(endpoint string) RunningInstance { +func GetRunner(endpoint string) (RunningInstance, bool) { ri_mutex.Lock() o, exists := runninginstances[endpoint] if exists == false { @@ -48,7 +48,7 @@ func GetRunner(endpoint string) RunningInstance { } ri_mutex.Unlock() - return o + return o, exists } func UpdateRunner(endpoint string, o RunningInstance) { @@ -162,7 +162,7 @@ func CheckInstance(newinstance string, callerEndpoint string) { func StartInstance(endpoint string) { // Check if exists. If so, get the object. If not, create it - o := GetRunner(endpoint) + o, _ := GetRunner(endpoint) o = GetNodeInfo(endpoint, o) UpdateRunner(endpoint, o) diff --git a/poll.go b/poll.go index 6348fce..5ed1b4a 100644 --- a/poll.go +++ b/poll.go @@ -63,7 +63,7 @@ func PollMastodonPleroma(endpoint string, o *RunningInstance) { for _, extaccount := range settings.Externalaccounts { if extaccount.Endpoint == endpoint { use_auth = true - o := GetRunner(endpoint) + o, _ := GetRunner(endpoint) err = get_client(endpoint, &o) if err != nil { logErr.Print("Unable to register client for " + endpoint + ": ", err) diff --git a/retrieve.go b/retrieve.go index e656f35..07de617 100644 --- a/retrieve.go +++ b/retrieve.go @@ -70,6 +70,7 @@ type PostJson struct { instance string } +/* func GetHTTPSession(endpoint string) RunningInstance { ri_mutex.Lock() o, exist := runninginstances[endpoint] @@ -86,6 +87,7 @@ func GetHTTPSession(endpoint string) RunningInstance { return o } +*/ func check_post(uri string) (PostJson, error) { var postjson PostJson @@ -107,7 +109,7 @@ func check_post(uri string) (PostJson, error) { } postjson.instance = uri[8 : endslash+8] - o := GetHTTPSession(postjson.instance) + o, _ := GetRunner(postjson.instance) req, _ := http.NewRequest("GET", uri, nil) req.Header.Set("User-Agent", "Tusky") req.Header.Add("Accept", "application/ld+json") @@ -188,7 +190,7 @@ func check_user(uri string) (UserJson, error) { } userjson.instance = uri[8 : endslash+8] - o := GetHTTPSession(userjson.instance) + o, _ := GetRunner(userjson.instance) req, _ := http.NewRequest("GET", uri, nil) req.Header.Set("User-Agent", "Tusky") req.Header.Add("Accept", "application/ld+json")