diff --git a/cmd/ipfs/ulimit_unix.go b/cmd/ipfs/ulimit_unix.go index 1fec41472e8..943c8318869 100644 --- a/cmd/ipfs/ulimit_unix.go +++ b/cmd/ipfs/ulimit_unix.go @@ -30,12 +30,15 @@ func checkAndSetUlimit() error { return fmt.Errorf("error getting rlimit: %s", err) } + var setting bool if rLimit.Cur < ipfsFileDescNum { if rLimit.Max < ipfsFileDescNum { + log.Error("adjusting max") rLimit.Max = ipfsFileDescNum } - fmt.Printf("Adjusting current ulimit to %d.\n", ipfsFileDescNum) + fmt.Printf("Adjusting current ulimit to %d...\n", ipfsFileDescNum) rLimit.Cur = ipfsFileDescNum + setting = true } err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) @@ -43,5 +46,9 @@ func checkAndSetUlimit() error { return fmt.Errorf("error setting ulimit: %s", err) } + if setting { + fmt.Printf("Successfully raised file descriptor limit to %d.\n", ipfsFileDescNum) + } + return nil } diff --git a/package.json b/package.json index bc6cdc040cf..013ce59d151 100644 --- a/package.json +++ b/package.json @@ -189,6 +189,12 @@ "hash": "QmVvJ27GcLaLSXvcB4auk3Gn3xuWK5ti5ENkZ2pCoJEYW4", "name": "autobatch", "version": "0.2.0" + }, + { + "author": "whyrusleeping", + "hash": "QmdCL8M8DXJdSRnwhpDhukX5r8ydjxnzPJpaKrFudDA8yn", + "name": "hang-fds", + "version": "0.0.0" } ], "gxVersion": "0.4.0", diff --git a/test/Makefile b/test/Makefile index 4d824a88ed9..f6d53dbdd3a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -60,10 +60,18 @@ multihash_src: $(eval MULTIHASH_HASH := $(shell cd .. && bin/gx deps find go-multihash)) $(eval MULTIHASH_SRC := gx/ipfs/$(MULTIHASH_HASH)/go-multihash) +hang-fds_src: + $(eval HANG_FDS_HASH := $(shell cd .. && bin/gx deps find hang-fds)) + $(eval HANG_FDS_SRC := gx/ipfs/$(HANG_FDS_HASH)/hang-fds) + bin/multihash: multihash_src $(call find_go_files, $(MULTIHASH_SRC)) IPFS-BUILD-OPTIONS @echo "*** installing $@ ***" go build $(GOFLAGS) -o bin/multihash $(MULTIHASH_SRC)/multihash +bin/hang-fds: hang-fds_src $(call find_go_files, $(HANG_FDS_SRC)) IPFS-BUILD-OPTIONS + @echo "*** installing $@ ***" + go build $(GOFLAGS) -o bin/hang-fds $(HANG_FDS_SRC) + iptb_src: $(eval IPTB_HASH := $(shell cd .. && bin/gx deps find iptb)) $(eval IPTB_SRC := gx/ipfs/$(IPTB_HASH)/iptb) diff --git a/test/sharness/Makefile b/test/sharness/Makefile index 2c5488dcbc0..9b50ec7a22b 100644 --- a/test/sharness/Makefile +++ b/test/sharness/Makefile @@ -8,7 +8,7 @@ T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) BINS = bin/random bin/multihash bin/ipfs bin/pollEndpoint \ - bin/iptb bin/go-sleep bin/random-files bin/go-timeout + bin/iptb bin/go-sleep bin/random-files bin/go-timeout bin/hang-fds SHARNESS = lib/sharness/sharness.sh IPFS_ROOT = ../.. diff --git a/test/sharness/t0060-daemon.sh b/test/sharness/t0060-daemon.sh index 677fbe5aa12..beae67eb53d 100755 --- a/test/sharness/t0060-daemon.sh +++ b/test/sharness/t0060-daemon.sh @@ -121,12 +121,20 @@ test_expect_success "daemon with pipe eventually becomes live" ' test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr ' -ulimit -n 512 +ulimit -S -n 512 TEST_ULIMIT_PRESET=1 test_launch_ipfs_daemon test_expect_success "daemon raised its fd limit" ' - grep "ulimit" actual_daemon > /dev/null + grep "raised file descriptor limit to 1024." actual_daemon > /dev/null +' + +test_expect_success "daemon actually can handle 1024 file descriptors" ' + hang-fds -hold=2s 1000 '$API_MADDR' +' + +test_expect_success "daemon didnt throw any errors" ' + test_expect_code 1 grep "too many open files" daemon_err ' test_kill_ipfs_daemon