From f8c02cad2fa2d1f6ff285e5afc2955ed921743eb Mon Sep 17 00:00:00 2001 From: Ricardo Domingos Date: Thu, 11 Jan 2018 18:07:27 +0100 Subject: [PATCH] common/fdlimit: Remove FdLimit from functions signature --- cmd/utils/flags.go | 4 ++-- common/fdlimit/fdlimit_freebsd.go | 12 ++++++------ common/fdlimit/fdlimit_test.go | 8 ++++---- common/fdlimit/fdlimit_unix.go | 12 ++++++------ common/fdlimit/fdlimit_windows.go | 16 ++++++++-------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 8cb853b528..820d7847c5 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -722,10 +722,10 @@ func setIPC(ctx *cli.Context, cfg *node.Config) { // makeDatabaseHandles raises out the number of allowed file handles per process // for Geth and returns half of the allowance to assign to the database. func makeDatabaseHandles() int { - if err := fdlimit.RaiseFdLimit(2048); err != nil { + if err := fdlimit.Raise(2048); err != nil { Fatalf("Failed to raise file descriptor allowance: %v", err) } - limit, err := fdlimit.GetFdLimit() + limit, err := fdlimit.Get() if err != nil { Fatalf("Failed to retrieve file descriptor allowance: %v", err) } diff --git a/common/fdlimit/fdlimit_freebsd.go b/common/fdlimit/fdlimit_freebsd.go index d89ffa66bb..3f4acf0b5a 100644 --- a/common/fdlimit/fdlimit_freebsd.go +++ b/common/fdlimit/fdlimit_freebsd.go @@ -24,9 +24,9 @@ import "syscall" // but Rlimit fields have type int64 on FreeBSD so it needs // an extra conversion. -// RaiseFdLimit tries to maximize the file descriptor allowance of this process +// Raise tries to maximize the file descriptor allowance of this process // to the maximum hard-limit allowed by the OS. -func RaiseFdLimit(max uint64) error { +func Raise(max uint64) error { // Get the current limit var limit syscall.Rlimit if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { @@ -43,9 +43,9 @@ func RaiseFdLimit(max uint64) error { return nil } -// GetFdLimit retrieves the number of file descriptors allowed to be opened by this +// Get retrieves the number of file descriptors allowed to be opened by this // process. -func GetFdLimit() (int, error) { +func Get() (int, error) { var limit syscall.Rlimit if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { return 0, err @@ -53,9 +53,9 @@ func GetFdLimit() (int, error) { return int(limit.Cur), nil } -// GetFdMaxLimit retrieves the maximum number of file descriptors this process is +// GetMax retrieves the maximum number of file descriptors this process is // allowed to request for itself. -func GetFdMaxLimit() (int, error) { +func GetMax() (int, error) { var limit syscall.Rlimit if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { return 0, err diff --git a/common/fdlimit/fdlimit_test.go b/common/fdlimit/fdlimit_test.go index feb5e05d59..671feab5ef 100644 --- a/common/fdlimit/fdlimit_test.go +++ b/common/fdlimit/fdlimit_test.go @@ -25,7 +25,7 @@ import ( // per this process can be retrieved. func TestFileDescriptorLimits(t *testing.T) { target := 4096 - hardlimit, err := GetFdMaxLimit() + hardlimit, err := GetMax() 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 := GetFdLimit(); err != nil || limit <= 0 { + if limit, err := Get(); err != nil || limit <= 0 { t.Fatalf("failed to retrieve file descriptor limit (%d): %v", limit, err) } - if err := RaiseFdLimit(uint64(target)); err != nil { + if err := Raise(uint64(target)); err != nil { t.Fatalf("failed to raise file allowance") } - if limit, err := GetFdLimit(); err != nil || limit < target { + if limit, err := Get(); err != nil || limit < target { t.Fatalf("failed to retrieve raised descriptor limit (have %v, want %v): %v", limit, target, err) } } diff --git a/common/fdlimit/fdlimit_unix.go b/common/fdlimit/fdlimit_unix.go index ec2c3e64ae..aaeba48f0f 100644 --- a/common/fdlimit/fdlimit_unix.go +++ b/common/fdlimit/fdlimit_unix.go @@ -20,9 +20,9 @@ package fdlimit import "syscall" -// RaiseFdLimit tries to maximize the file descriptor allowance of this process +// Raise tries to maximize the file descriptor allowance of this process // to the maximum hard-limit allowed by the OS. -func RaiseFdLimit(max uint64) error { +func Raise(max uint64) error { // Get the current limit var limit syscall.Rlimit if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { @@ -39,9 +39,9 @@ func RaiseFdLimit(max uint64) error { return nil } -// GetFdLimit retrieves the number of file descriptors allowed to be opened by this +// Get retrieves the number of file descriptors allowed to be opened by this // process. -func GetFdLimit() (int, error) { +func Get() (int, error) { var limit syscall.Rlimit if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { return 0, err @@ -49,9 +49,9 @@ func GetFdLimit() (int, error) { return int(limit.Cur), nil } -// GetFdMaxLimit retrieves the maximum number of file descriptors this process is +// GetMax retrieves the maximum number of file descriptors this process is // allowed to request for itself. -func GetFdMaxLimit() (int, error) { +func GetMax() (int, error) { var limit syscall.Rlimit if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil { return 0, err diff --git a/common/fdlimit/fdlimit_windows.go b/common/fdlimit/fdlimit_windows.go index 02f7ec5582..ab37de126a 100644 --- a/common/fdlimit/fdlimit_windows.go +++ b/common/fdlimit/fdlimit_windows.go @@ -18,9 +18,9 @@ package fdlimit import "errors" -// RaiseFdLimit tries to maximize the file descriptor allowance of this process +// Raise tries to maximize the file descriptor allowance of this process // to the maximum hard-limit allowed by the OS. -func RaiseFdLimit(max uint64) error { +func Raise(max uint64) error { // This method is NOP by design: // * Linux/Darwin counterparts need to manually increase per process limits // * On Windows Go uses the CreateFile API, which is limited to 16K files, non @@ -33,15 +33,15 @@ func RaiseFdLimit(max uint64) error { return nil } -// GetFdLimit retrieves the number of file descriptors allowed to be opened by this +// Get retrieves the number of file descriptors allowed to be opened by this // process. -func GetFdLimit() (int, error) { - // Please see RaiseFdLimit for the reason why we use hard coded 16K as the limit +func Get() (int, error) { + // Please see Raise for the reason why we use hard coded 16K as the limit return 16384, nil } -// GetFdMaxLimit retrieves the maximum number of file descriptors this process is +// GetMax retrieves the maximum number of file descriptors this process is // allowed to request for itself. -func GetFdMaxLimit() (int, error) { - return GetFdLimit() +func GetMax() (int, error) { + return Get() }