Skip to content

Commit

Permalink
connectd: log status_failed on TOR problems
Browse files Browse the repository at this point in the history
This changes connectd to use `status_fail()` on TOR problems during statup
instead of `err()`. Using `err()` did not write to the logfile.

To find out TOR problems during startup, the user needed to stop the system
daemon and call `lightningd` manually in console to see the error.

`status_fail()` logs and exits, but also prints a whole stacktrace,
which is a bit too much imho on config errors. But currently there is
no `status_SOMETHING` method that logs, prints and exists on an error
without stacktrace.

Changelog-None
  • Loading branch information
m-schmoock authored and ddustin committed May 12, 2023
1 parent bf279a2 commit 4f1079b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions connectd/tor_autoservice.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "config.h"
#include <ccan/err/err.h>
#include <ccan/rbuf/rbuf.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/tal/grab_file/grab_file.h>
Expand Down Expand Up @@ -272,10 +271,12 @@ struct wireaddr *tor_autoservice(const tal_t *ctx,

fd = socket(ai_tor->ai_family, SOCK_STREAM, 0);
if (fd < 0)
err(1, "Creating stream socket for Tor");
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Creating stream socket for Tor");

if (connect(fd, ai_tor->ai_addr, ai_tor->ai_addrlen) != 0)
err(1, "Connecting stream socket to Tor service");
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Connecting stream socket to Tor service");

buffer = tal_arr(tmpctx, char, rbuf_good_size(fd));
rbuf_init(&rbuf, fd, buffer, tal_count(buffer), buf_resize);
Expand Down Expand Up @@ -312,10 +313,12 @@ struct wireaddr *tor_fixed_service(const tal_t *ctx,

fd = socket(ai_tor->ai_family, SOCK_STREAM, 0);
if (fd < 0)
err(1, "Creating stream socket for Tor");
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Creating stream socket for Tor");

if (connect(fd, ai_tor->ai_addr, ai_tor->ai_addrlen) != 0)
err(1, "Connecting stream socket to Tor service");
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Connecting stream socket to Tor service");

buffer = tal_arr(tmpctx, char, rbuf_good_size(fd));
rbuf_init(&rbuf, fd, buffer, tal_count(buffer), buf_resize);
Expand Down

0 comments on commit 4f1079b

Please sign in to comment.