Skip to content

Commit

Permalink
rpc: avoid use of cgo by hard-coding maxPathSize (ethereum#27447)
Browse files Browse the repository at this point in the history
Package rpc uses cgo to find the maximum UNIX domain socket path 
length. If exceeded, a warning is printed. This is the only use of cgo in this
package. It seems excessive to depend on cgo just for this warning, so
we now hard-code the usual limit for Linux instead.

---------

Co-authored-by: Felix Lange <[email protected]>
  • Loading branch information
zchee and fjl authored Jun 19, 2023
1 parent e4660a1 commit f0b5af7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 62 deletions.
34 changes: 0 additions & 34 deletions rpc/constants_unix.go

This file was deleted.

26 changes: 0 additions & 26 deletions rpc/constants_unix_nocgo.go

This file was deleted.

10 changes: 8 additions & 2 deletions rpc/ipc_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ import (
"github.com/ethereum/go-ethereum/log"
)

const (
// On Linux, sun_path is 108 bytes in size
// see http://man7.org/linux/man-pages/man7/unix.7.html
maxPathSize = int(108)
)

// ipcListen will create a Unix socket on the given endpoint.
func ipcListen(endpoint string) (net.Listener, error) {
// account for null-terminator too
if len(endpoint)+1 > int(max_path_size) {
log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", max_path_size-1),
if len(endpoint)+1 > maxPathSize {
log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", maxPathSize-1),
"endpoint", endpoint)
}

Expand Down

0 comments on commit f0b5af7

Please sign in to comment.