on main help sign in
refactor: make func unexported
7ff6ba9Andrey Nering
internal/lsp/watcher/global_watcher.go+1−1
@@ -118,7 +118,7 @@ func Start() error {
118 // Check if the error might be due to file descriptor limits
118 // Check if the error might be due to file descriptor limits
119 if isFileLimitError(err) {
119 if isFileLimitError(err) {
120 slog.Warn("lsp watcher: Hit file descriptor limit, attempting to increase", "error", err)
120 slog.Warn("lsp watcher: Hit file descriptor limit, attempting to increase", "error", err)
121− if newLimit, rlimitErr := MaximizeOpenFileLimit(); rlimitErr == nil {
121+ if newLimit, rlimitErr := maximizeOpenFileLimit(); rlimitErr == nil {
122 slog.Info("lsp watcher: Increased file descriptor limit", "limit", newLimit)
122 slog.Info("lsp watcher: Increased file descriptor limit", "limit", newLimit)
123 // Retry the watch operation
123 // Retry the watch operation
124 if err = notify.Watch(watchPath, gw.events, events); err == nil {
124 if err = notify.Watch(watchPath, gw.events, events); err == nil {
internal/lsp/watcher/rlimit_stub.go+3−3
@@ -2,11 +2,11 @@
2
2
3package watcher
3package watcher
4
4
5−// MaximizeOpenFileLimit is a no-op on non-Unix systems.
5+// maximizeOpenFileLimit is a no-op on non-Unix systems.
6// Returns a high value to indicate no practical limit.
6// Returns a high value to indicate no practical limit.
7−func MaximizeOpenFileLimit() (int, error) {
7+func maximizeOpenFileLimit() (int, error) {
8 // Windows and other non-Unix systems don't have file descriptor limits
8 // Windows and other non-Unix systems don't have file descriptor limits
9 // in the same way Unix systems do. Return a very high value to indicate
9 // in the same way Unix systems do. Return a very high value to indicate
10 // there's no practical limit to worry about.
10 // there's no practical limit to worry about.
11 return 10000000, nil // 10M handles - way more than any process would use
11 return 10000000, nil // 10M handles - way more than any process would use
12−}
12+}
internal/lsp/watcher/rlimit_unix.go+2−2
@@ -16,11 +16,11 @@ const (
16 darwinOpenMax = 10240
16 darwinOpenMax = 10240
17)
17)
18
18
19−// MaximizeOpenFileLimit tries to set the resource limit RLIMIT_NOFILE (number
19+// maximizeOpenFileLimit tries to set the resource limit RLIMIT_NOFILE (number
20// of open file descriptors) to the max (hard limit), if the current (soft
20// of open file descriptors) to the max (hard limit), if the current (soft
21// limit) is below the max. Returns the new (though possibly unchanged) limit,
21// limit) is below the max. Returns the new (though possibly unchanged) limit,
22// or an error if it could not be changed.
22// or an error if it could not be changed.
23−func MaximizeOpenFileLimit() (int, error) {
23+func maximizeOpenFileLimit() (int, error) {
24 // Get the current limit on number of open files.
24 // Get the current limit on number of open files.
25 var lim syscall.Rlimit
25 var lim syscall.Rlimit
26 if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim); err != nil {
26 if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim); err != nil {