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.
Showing the changes to services/gitdiff/gitdiff.go (1 of 66 files). Show all
Unified · Split
| @@ -1303,8 +1303,9 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff · 1302 unmodified lines | ||
| 1303 | 1303 | return nil, err |
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 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() | |
| 1308 | 1309 | |
| 1309 | 1310 | argsLength := 6 |
| 1310 | 1311 | if len(opts.WhitespaceBehavior) > 0 { |
| @@ -1369,9 +1370,6 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff · 58 unmodified lines | ||
| 1369 | 1370 | return nil, fmt.Errorf("error during Start: %w", err) |
| 1370 | 1371 | } |
| 1371 | 1372 | |
| 1372 | − pid := process.GetManager().Add(fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath), cancel) | |
| 1373 | − defer process.GetManager().Remove(pid) | |
| 1374 | − | |
| 1375 | 1373 | diff, err := ParsePatch(opts.MaxLines, opts.MaxLineCharacters, opts.MaxFiles, stdout, parsePatchSkipToFile) |
| 1376 | 1374 | if err != nil { |
| 1377 | 1375 | return nil, fmt.Errorf("unable to ParsePatch: %w", err) |