diff --git a/closingd/Makefile b/closingd/Makefile index 53c732399..5c3373471 100644 --- a/closingd/Makefile +++ b/closingd/Makefile @@ -50,7 +50,6 @@ CLOSINGD_COMMON_OBJS := \ common/status_wiregen.o \ common/read_peer_msg.o \ common/setup.o \ - common/socket_close.o \ common/status.o \ common/status_wire.o \ common/subdaemon.o \ diff --git a/closingd/closingd.c b/closingd/closingd.c index 19665dd8e..2d228a462 100644 --- a/closingd/closingd.c +++ b/closingd/closingd.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -1097,10 +1096,7 @@ exit_thru_the_giftshop: #endif /* We're done! */ - /* Properly close the channel first. */ - if (!socket_close(pps->peer_fd)) - status_unusual("Closing and draining peerfd gave error: %s", - strerror(errno)); + /* Sending the below will kill us! */ wire_sync_write(REQ_FD, take(towire_closingd_complete(NULL))); tal_free(ctx); diff --git a/common/Makefile b/common/Makefile index 9c8dbfe39..a203a734a 100644 --- a/common/Makefile +++ b/common/Makefile @@ -76,7 +76,6 @@ COMMON_SRC_NOGEN := \ common/route.c \ common/setup.c \ common/shutdown_scriptpubkey.c \ - common/socket_close.c \ common/sphinx.c \ common/status.c \ common/status_levels.c \ diff --git a/common/socket_close.c b/common/socket_close.c deleted file mode 100644 index 5abaf80d3..000000000 --- a/common/socket_close.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "config.h" -#include -#include -#include -#include -#include -#include -#include - -/* makes read() return EINTR after 5 seconds */ -static void break_read(int signum) -{ -} - -bool socket_close(int fd) -{ - char unused[64]; - struct sigaction act, old_act; - int sys_res, saved_errno; - - /* We shutdown. Usually they then shutdown too, and read() gives 0 */ - sys_res = shutdown(fd, SHUT_WR); - if (sys_res < 0) { - close_noerr(fd); - return false; - } - - /* Let's not get too enthusiastic about waiting. */ - memset(&act, 0, sizeof(act)); - act.sa_handler = break_read; - sigaction(SIGALRM, &act, &old_act); - - alarm(5); - - while ((sys_res = read(fd, unused, sizeof(unused))) > 0); - saved_errno = errno; - - alarm(0); - sigaction(SIGALRM, &old_act, NULL); - - if (sys_res < 0) { - close(fd); - errno = saved_errno; - return false; - } - - return close(fd) == 0; -} diff --git a/common/socket_close.h b/common/socket_close.h deleted file mode 100644 index 8fc8030f9..000000000 --- a/common/socket_close.h +++ /dev/null @@ -1,23 +0,0 @@ -/* common/socket_close - Properly close a socket, - * ensuring that any data we write just before - * the close has been transmitted to the other - * side, and ignoring any data the other side - * has sent at the time the close was started. - * - * Reference: - * - * http://ia800504.us.archive.org/3/items/TheUltimateSo_lingerPageOrWhyIsMyTcpNotReliable/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable.html - */ -#ifndef LIGHTNING_COMMON_SOCKET_CLOSE_H -#define LIGHTNING_COMMON_SOCKET_CLOSE_H -#include "config.h" -#include - -/* Return false if something failed, true if - * nothing failed. - * If something failed, error is stored in - * `errno. - */ -bool socket_close(int fd); - -#endif /* LIGHTNING_COMMON_SOCKET_CLOSE_H */