make sure to close the repo if we fail to properly start the daemon
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Apr 3, 2019 at 15:38 UTC
a44f0d251fc45e16f40c6f0fc3f622fd830fe701
2 files changed
+9
cmd/ipfs/daemon.go
+4
@@ -278,6 +278,10 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
278
break
279
}
280
281
+ // The node will also close the repo but there are many places we could
282
+ // fail before we get to that. It can't hurt to close it twice.
283
+ defer repo.Close()
284
+
285
cfg, err := cctx.GetConfig()
286
if err != nil {
287
return err
test/sharness/t0060-daemon.sh
+5
@@ -128,6 +128,11 @@ test_expect_success "daemon with pipe eventually becomes live" '
128
test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr
129
'
130
131
+test_expect_success "'ipfs daemon' cleans up when it fails to start" '
132
+ test_must_fail ipfs daemon --routing=foobar &&
133
+ test ! -e "$IPFS_PATH/repo.lock"
134
+'
135
+
136
ulimit -S -n 512
137
TEST_ULIMIT_PRESET=1
138
test_launch_ipfs_daemon