Skip to content

Commit 1aba4a7

Browse files
committed
runtime.GOMAXPROCS(0) for when threads is set to 0
1 parent c20c35b commit 1aba4a7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ More config settings can be found in `zipserver/config.go`.
2727

2828
## Limits
2929

30-
All limits are configured in `zipserver.json` using the names below. For `extract` and `list`, you can override limits per request via HTTP query parameters. CLI overrides are available for `extract` via flags, and `--threads` can override `ExtractionThreads`. A value of `0` means "unbounded" for all limits except `ExtractionThreads` (which is forced to at least 1).
30+
All limits are configured in `zipserver.json` using the names below. For `extract` and `list`, you can override limits per request via HTTP query parameters. CLI overrides are available for `extract` via flags, and `--threads` can override `ExtractionThreads`. A value of `0` means "unbounded" for all limits except `ExtractionThreads` (which uses `GOMAXPROCS`, and is forced to at least 1).
3131

3232
| Config field | Applies to | Description | Default |
3333
| --- | --- | --- | --- |

zipserver/archive.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"net/http"
1515
"os"
1616
"path"
17+
"runtime"
1718
"strconv"
1819
"strings"
1920
"time"
@@ -305,7 +306,10 @@ func (a *ArchiveExtractor) sendZipExtracted(
305306
results := make(chan UploadFileResult)
306307
threads := limits.ExtractionThreads
307308
if threads < 1 {
308-
threads = 1
309+
threads = runtime.GOMAXPROCS(0)
310+
if threads < 1 {
311+
threads = 1
312+
}
309313
}
310314

311315
done := make(chan struct{}, threads)

0 commit comments

Comments
 (0)