mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
common/fdlimit: Rename fdlimit functions
This commit is contained in:
parent
f8c02cad2f
commit
eb3b13ad2a
5 changed files with 17 additions and 17 deletions
|
|
@ -725,7 +725,7 @@ func makeDatabaseHandles() int {
|
|||
if err := fdlimit.Raise(2048); err != nil {
|
||||
Fatalf("Failed to raise file descriptor allowance: %v", err)
|
||||
}
|
||||
limit, err := fdlimit.Get()
|
||||
limit, err := fdlimit.Current()
|
||||
if err != nil {
|
||||
Fatalf("Failed to retrieve file descriptor allowance: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ func Raise(max uint64) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Get retrieves the number of file descriptors allowed to be opened by this
|
||||
// Current retrieves the number of file descriptors allowed to be opened by this
|
||||
// process.
|
||||
func Get() (int, error) {
|
||||
func Current() (int, error) {
|
||||
var limit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
|
||||
return 0, err
|
||||
|
|
@ -53,9 +53,9 @@ func Get() (int, error) {
|
|||
return int(limit.Cur), nil
|
||||
}
|
||||
|
||||
// GetMax retrieves the maximum number of file descriptors this process is
|
||||
// Maximum retrieves the maximum number of file descriptors this process is
|
||||
// allowed to request for itself.
|
||||
func GetMax() (int, error) {
|
||||
func Maximum() (int, error) {
|
||||
var limit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
|
||||
return 0, err
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
// per this process can be retrieved.
|
||||
func TestFileDescriptorLimits(t *testing.T) {
|
||||
target := 4096
|
||||
hardlimit, err := GetMax()
|
||||
hardlimit, err := Maximum()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -33,13 +33,13 @@ func TestFileDescriptorLimits(t *testing.T) {
|
|||
t.Skip(fmt.Sprintf("system limit is less than desired test target: %d < %d", hardlimit, target))
|
||||
}
|
||||
|
||||
if limit, err := Get(); err != nil || limit <= 0 {
|
||||
if limit, err := Current(); err != nil || limit <= 0 {
|
||||
t.Fatalf("failed to retrieve file descriptor limit (%d): %v", limit, err)
|
||||
}
|
||||
if err := Raise(uint64(target)); err != nil {
|
||||
t.Fatalf("failed to raise file allowance")
|
||||
}
|
||||
if limit, err := Get(); err != nil || limit < target {
|
||||
if limit, err := Current(); err != nil || limit < target {
|
||||
t.Fatalf("failed to retrieve raised descriptor limit (have %v, want %v): %v", limit, target, err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ func Raise(max uint64) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Get retrieves the number of file descriptors allowed to be opened by this
|
||||
// Current retrieves the number of file descriptors allowed to be opened by this
|
||||
// process.
|
||||
func Get() (int, error) {
|
||||
func Current() (int, error) {
|
||||
var limit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
|
||||
return 0, err
|
||||
|
|
@ -49,9 +49,9 @@ func Get() (int, error) {
|
|||
return int(limit.Cur), nil
|
||||
}
|
||||
|
||||
// GetMax retrieves the maximum number of file descriptors this process is
|
||||
// Maximum retrieves the maximum number of file descriptors this process is
|
||||
// allowed to request for itself.
|
||||
func GetMax() (int, error) {
|
||||
func Maximum() (int, error) {
|
||||
var limit syscall.Rlimit
|
||||
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
|
||||
return 0, err
|
||||
|
|
|
|||
|
|
@ -33,15 +33,15 @@ func Raise(max uint64) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Get retrieves the number of file descriptors allowed to be opened by this
|
||||
// Current retrieves the number of file descriptors allowed to be opened by this
|
||||
// process.
|
||||
func Get() (int, error) {
|
||||
func Current() (int, error) {
|
||||
// Please see Raise for the reason why we use hard coded 16K as the limit
|
||||
return 16384, nil
|
||||
}
|
||||
|
||||
// GetMax retrieves the maximum number of file descriptors this process is
|
||||
// Maximum retrieves the maximum number of file descriptors this process is
|
||||
// allowed to request for itself.
|
||||
func GetMax() (int, error) {
|
||||
return Get()
|
||||
func Maximum() (int, error) {
|
||||
return Current()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue