summaryrefslogtreecommitdiffstats
path: root/modules/private/serv.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-07-14 15:43:13 +0100
committerGitHub <noreply@github.com>2021-07-14 10:43:13 -0400
commit3dcb3e9073d825a4ada184f832892cf4bd5836a3 (patch)
treeaab77b7726f0e20f34b452df166113950ff5fc62 /modules/private/serv.go
parentee43d70a0c237ef9c02b99b9b49d1af348840319 (diff)
downloadgitea-3dcb3e9073d825a4ada184f832892cf4bd5836a3.tar.gz
gitea-3dcb3e9073d825a4ada184f832892cf4bd5836a3.zip
Second attempt at preventing zombies (#16326)
* Second attempt at preventing zombies * Ensure that the pipes are closed in ssh.go * Ensure that a cancellable context is passed up in cmd/* http requests * Make cmd.fail return properly so defers are obeyed * Ensure that something is sent to stdout in case of blocks here Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint 2 Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint 3 Signed-off-by: Andrew Thornton <art27@cantab.net> * fixup Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/private/serv.go')
-rw-r--r--modules/private/serv.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/private/serv.go b/modules/private/serv.go
index 659af6dff5..9643dad679 100644
--- a/modules/private/serv.go
+++ b/modules/private/serv.go
@@ -5,6 +5,7 @@
package private
import (
+ "context"
"fmt"
"net/http"
"net/url"
@@ -21,10 +22,10 @@ type KeyAndOwner struct {
}
// ServNoCommand returns information about the provided key
-func ServNoCommand(keyID int64) (*models.PublicKey, *models.User, error) {
+func ServNoCommand(ctx context.Context, keyID int64) (*models.PublicKey, *models.User, error) {
reqURL := setting.LocalURL + fmt.Sprintf("api/internal/serv/none/%d",
keyID)
- resp, err := newInternalRequest(reqURL, "GET").Response()
+ resp, err := newInternalRequest(ctx, reqURL, "GET").Response()
if err != nil {
return nil, nil, err
}
@@ -73,7 +74,7 @@ func IsErrServCommand(err error) bool {
}
// ServCommand preps for a serv call
-func ServCommand(keyID int64, ownerName, repoName string, mode models.AccessMode, verbs ...string) (*ServCommandResults, error) {
+func ServCommand(ctx context.Context, keyID int64, ownerName, repoName string, mode models.AccessMode, verbs ...string) (*ServCommandResults, error) {
reqURL := setting.LocalURL + fmt.Sprintf("api/internal/serv/command/%d/%s/%s?mode=%d",
keyID,
url.PathEscape(ownerName),
@@ -85,7 +86,7 @@ func ServCommand(keyID int64, ownerName, repoName string, mode models.AccessMode
}
}
- resp, err := newInternalRequest(reqURL, "GET").Response()
+ resp, err := newInternalRequest(ctx, reqURL, "GET").Response()
if err != nil {
return nil, err
}