summaryrefslogtreecommitdiffstats
path: root/modules/git/command.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-11-30 20:06:32 +0000
committerGitHub <noreply@github.com>2021-11-30 20:06:32 +0000
commit01087e9eef21ff5ea1cebbb1e84933954671fdf2 (patch)
treeae618785a3bd46e012096683e2fd2309f87c571d /modules/git/command.go
parentd894c90b703ce215e2319ae2e2bf95989f77805d (diff)
downloadgitea-01087e9eef21ff5ea1cebbb1e84933954671fdf2.tar.gz
gitea-01087e9eef21ff5ea1cebbb1e84933954671fdf2.zip
Make Requests Processes and create process hierarchy. Associate OpenRepository with context. (#17125)
This PR registers requests with the process manager and manages hierarchy within the processes. Git repos are then associated with a context, (usually the request's context) - with sub commands using this context as their base context. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git/command.go')
-rw-r--r--modules/git/command.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/modules/git/command.go b/modules/git/command.go
index e7496f072c..3cf85c2d85 100644
--- a/modules/git/command.go
+++ b/modules/git/command.go
@@ -143,8 +143,13 @@ func (c *Command) RunWithContext(rc *RunContext) error {
log.Debug("%s: %v", rc.Dir, c)
}
- ctx, cancel := context.WithTimeout(c.parentContext, rc.Timeout)
- defer cancel()
+ desc := c.desc
+ if desc == "" {
+ desc = fmt.Sprintf("%s %s [repo_path: %s]", c.name, strings.Join(c.args, " "), rc.Dir)
+ }
+
+ ctx, cancel, finished := process.GetManager().AddContextTimeout(c.parentContext, rc.Timeout, desc)
+ defer finished()
cmd := exec.CommandContext(ctx, c.name, c.args...)
if rc.Env == nil {
@@ -172,13 +177,6 @@ func (c *Command) RunWithContext(rc *RunContext) error {
return err
}
- desc := c.desc
- if desc == "" {
- desc = fmt.Sprintf("%s %s %s [repo_path: %s]", GitExecutable, c.name, strings.Join(c.args, " "), rc.Dir)
- }
- pid := process.GetManager().Add(desc, cancel)
- defer process.GetManager().Remove(pid)
-
if rc.PipelineFunc != nil {
err := rc.PipelineFunc(ctx, cancel)
if err != nil {