File tree 2 files changed +26
-3
lines changed
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -30,18 +30,25 @@ func checkAndSetUlimit() error {
30
30
return fmt .Errorf ("error getting rlimit: %s" , err )
31
31
}
32
32
33
+ var setting bool
33
34
if rLimit .Cur < ipfsFileDescNum {
34
35
if rLimit .Max < ipfsFileDescNum {
36
+ log .Error ("adjusting max" )
35
37
rLimit .Max = ipfsFileDescNum
36
38
}
37
- fmt .Printf ("Adjusting current ulimit to %d.\n " , ipfsFileDescNum )
39
+ fmt .Printf ("Adjusting current ulimit to %d... \n " , ipfsFileDescNum )
38
40
rLimit .Cur = ipfsFileDescNum
41
+ setting = true
39
42
}
40
43
41
44
err = syscall .Setrlimit (syscall .RLIMIT_NOFILE , & rLimit )
42
45
if err != nil {
43
46
return fmt .Errorf ("error setting ulimit: %s" , err )
44
47
}
45
48
49
+ if setting {
50
+ fmt .Printf ("Successfully raised file descriptor limit to %d.\n " , ipfsFileDescNum )
51
+ }
52
+
46
53
return nil
47
54
}
Original file line number Diff line number Diff line change @@ -121,14 +121,30 @@ test_expect_success "daemon with pipe eventually becomes live" '
121
121
test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr
122
122
'
123
123
124
- ulimit -n 512
124
+ ulimit -S - n 512
125
125
TEST_ULIMIT_PRESET=1
126
126
test_launch_ipfs_daemon
127
127
128
128
test_expect_success " daemon raised its fd limit" '
129
- grep "ulimit " actual_daemon > /dev/null
129
+ grep "raised file descriptor limit to 1024. " actual_daemon > /dev/null
130
130
'
131
131
132
+ get_col_four () {
133
+ awk ' { print $4 }' $1
134
+ }
135
+
136
+ if [ ` uname` == " Linux" ]; then
137
+ test_expect_success " get fd limit through /proc" '
138
+ cat /proc/$IPFS_PID/limits > limits &&
139
+ grep "Max open files" limits > fd_limits_line &&
140
+ limit=$(get_col_four fd_limits_line)
141
+ '
142
+
143
+ test_expect_success " limit from system looks good" '
144
+ test "$limit" -eq 1024
145
+ '
146
+ fi
147
+
132
148
test_kill_ipfs_daemon
133
149
134
150
test_done
You can’t perform that action at this time.
0 commit comments