diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-04-26 12:29:20 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-04-29 13:56:01 +0300 |
commit | 91e12334dd16cfec45d419fd654212839792944f (patch) | |
tree | 87f804e2380a3fff39536ebd86b4c0c54bbe1231 | |
parent | 2f53e4a59cfd71af097752c71ca8dcb5f6dcc56b (diff) |
catfile: Replace mentions of "batch" in the cache
The catfile cache still mentions "batch" in a lot of places, even though
what it's actually handling is processes that may or may not be a batch
process.
Adjust the variable names to instead say "process".
-rw-r--r-- | internal/git/catfile/cache.go | 24 | ||||
-rw-r--r-- | internal/git/catfile/cache_test.go | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/internal/git/catfile/cache.go b/internal/git/catfile/cache.go index e86248feb..f63fd36ec 100644 --- a/internal/git/catfile/cache.go +++ b/internal/git/catfile/cache.go @@ -216,7 +216,7 @@ func (c *ProcessCache) getOrCreateProcess( ) (_ cacheable, returnedErr error) { requestDone := ctx.Done() if requestDone == nil { - panic("empty ctx.Done() in catfile.Batch.New()") + panic("empty ctx.Done() when creating catfile process") } defer c.reportCacheMembers() @@ -224,11 +224,11 @@ func (c *ProcessCache) getOrCreateProcess( var cancel func() cacheKey, isCacheable := newCacheKey(metadata.GetValue(ctx, SessionIDField), repo) if isCacheable { - // We only try to look up cached batch processes in case it is cacheable, which - // requires a session ID. This is mostly done such that git-cat-file(1) processes - // from one user cannot interfer with those from another user. The main intent is to - // disallow trivial denial of service attacks against other users in case it is - // possible to poison the cache with broken git-cat-file(1) processes. + // We only try to look up cached processes in case it is cacheable, which requires a + // session ID. This is mostly done such that git-cat-file(1) processes from one user + // cannot interfere with those from another user. The main intent is to disallow + // trivial denial of service attacks against other users in case it is possible to + // poison the cache with broken git-cat-file(1) processes. if entry, ok := processes.Checkout(cacheKey); ok { go c.returnWhenDone(requestDone, processes, cacheKey, entry.value, entry.cancel) @@ -256,15 +256,15 @@ func (c *ProcessCache) getOrCreateProcess( ctx = opentracing.ContextWithSpan(ctx, nil) } - batch, err := create(ctx) + process, err := create(ctx) if err != nil { return nil, err } defer func() { - // If we somehow fail after creating a new Batch process, then we want to kill - // spawned processes right away. + // If we somehow fail after creating a new process, then we want to kill spawned + // processes right away. if returnedErr != nil { - batch.close() + process.close() } }() @@ -278,10 +278,10 @@ func (c *ProcessCache) getOrCreateProcess( if isCacheable { // If the process is cacheable, then we want to put the process into the cache when // the current outer context is done. - go c.returnWhenDone(requestDone, processes, cacheKey, batch, cancel) + go c.returnWhenDone(requestDone, processes, cacheKey, process, cancel) } - return batch, nil + return process, nil } func (c *ProcessCache) reportCacheMembers() { diff --git a/internal/git/catfile/cache_test.go b/internal/git/catfile/cache_test.go index b90124ec8..61728a25a 100644 --- a/internal/git/catfile/cache_test.go +++ b/internal/git/catfile/cache_test.go @@ -188,7 +188,7 @@ func TestCache_ObjectReader(t *testing.T) { t.Run("uncancellable", func(t *testing.T) { ctx := testhelper.ContextWithoutCancel() - require.PanicsWithValue(t, "empty ctx.Done() in catfile.Batch.New()", func() { + require.PanicsWithValue(t, "empty ctx.Done() when creating catfile process", func() { _, _ = cache.ObjectReader(ctx, repoExecutor) }) }) @@ -317,7 +317,7 @@ func TestCache_ObjectInfoReader(t *testing.T) { t.Run("uncancellable", func(t *testing.T) { ctx := testhelper.ContextWithoutCancel() - require.PanicsWithValue(t, "empty ctx.Done() in catfile.Batch.New()", func() { + require.PanicsWithValue(t, "empty ctx.Done() when creating catfile process", func() { _, _ = cache.ObjectInfoReader(ctx, repoExecutor) }) }) |