-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #1083 MaxFileDescriptors setting shouldn't reduce the system de…
…fined values #1083 Rework based on PR feedback 1. consolidated getSoftFDLimit() and getSoftFDLimitWithCurrent() into single function. 2. pass syscall.Rlimit as parameter instead of individual values 3. fix numbering in comment #1504
- Loading branch information
Traun Leyden
authored and
Andrew Reslan
committed
Jan 26, 2016
1 parent
800047e
commit 7001155
Showing
2 changed files
with
108 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package base | ||
|
||
import ( | ||
"syscall" | ||
"testing" | ||
|
||
"github.com/couchbaselabs/go.assert" | ||
) | ||
|
||
func TestGetSoftFDLimitWithCurrent(t *testing.T) { | ||
|
||
requestedSoftFDLimit := uint64(1024) | ||
currentSoftFdLimit := uint64(2048) | ||
currentHardFdLimit := uint64(4096) | ||
|
||
limit := syscall.Rlimit{ | ||
Cur: currentSoftFdLimit, | ||
Max: currentHardFdLimit, | ||
} | ||
|
||
requiresUpdate, softFDLimit := getSoftFDLimit( | ||
requestedSoftFDLimit, | ||
limit, | ||
) | ||
assert.False(t, requiresUpdate) | ||
|
||
limit.Cur = uint64(512) | ||
|
||
requiresUpdate, softFDLimit = getSoftFDLimit( | ||
requestedSoftFDLimit, | ||
limit, | ||
) | ||
assert.True(t, requiresUpdate) | ||
assert.Equals(t, softFDLimit, requestedSoftFDLimit) | ||
|
||
} |