Skip to content

Commit 63eb2e9

Browse files
zcheefjl
authored andcommitted
rpc: avoid use of cgo by hard-coding maxPathSize (ethereum#27447)
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 <fjl@twurst.com>
1 parent e9686ce commit 63eb2e9

File tree

3 files changed

+8
-62
lines changed

3 files changed

+8
-62
lines changed

rpc/constants_unix.go

-34
This file was deleted.

rpc/constants_unix_nocgo.go

-26
This file was deleted.

rpc/ipc_unix.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ import (
2929
"github.com/ethereum/go-ethereum/log"
3030
)
3131

32+
const (
33+
// On Linux, sun_path is 108 bytes in size
34+
// see http://man7.org/linux/man-pages/man7/unix.7.html
35+
maxPathSize = int(108)
36+
)
37+
3238
// ipcListen will create a Unix socket on the given endpoint.
3339
func ipcListen(endpoint string) (net.Listener, error) {
3440
// account for null-terminator too
35-
if len(endpoint)+1 > int(max_path_size) {
36-
log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", max_path_size-1),
41+
if len(endpoint)+1 > maxPathSize {
42+
log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", maxPathSize-1),
3743
"endpoint", endpoint)
3844
}
3945

0 commit comments

Comments
 (0)