History

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.

zeripath committed 4 years ago

Commit 01087e91 parent d894c9066 files · +591 −306Browse files

Showing the changes to services/gitdiff/gitdiff.go (1 of 66 files). Show all

Unified · Split

services/gitdiff/gitdiff.go+3−5
@@ -1303,8 +1303,9 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff · 1302 unmodified lines
13031303 return nil, err
13041304 }
13051305
1306− ctx, cancel := context.WithTimeout(git.DefaultContext, time.Duration(setting.Git.Timeout.Default)*time.Second)
1307− defer cancel()
1306+ timeout := time.Duration(setting.Git.Timeout.Default) * time.Second
1307+ ctx, _, finished := process.GetManager().AddContextTimeout(gitRepo.Ctx, timeout, fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath))
1308+ defer finished()
13081309
13091310 argsLength := 6
13101311 if len(opts.WhitespaceBehavior) > 0 {
@@ -1369,9 +1370,6 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff · 58 unmodified lines
13691370 return nil, fmt.Errorf("error during Start: %w", err)
13701371 }
13711372
1372− pid := process.GetManager().Add(fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath), cancel)
1373− defer process.GetManager().Remove(pid)
1374−
13751373 diff, err := ParsePatch(opts.MaxLines, opts.MaxLineCharacters, opts.MaxFiles, stdout, parsePatchSkipToFile)
13761374 if err != nil {
13771375 return nil, fmt.Errorf("unable to ParsePatch: %w", err)