diff --git a/binaries/aarch64/tpws b/binaries/aarch64/tpws index b18287a1..f9f982de 100755 Binary files a/binaries/aarch64/tpws and b/binaries/aarch64/tpws differ diff --git a/binaries/arm/tpws b/binaries/arm/tpws index 2bd09607..37504402 100755 Binary files a/binaries/arm/tpws and b/binaries/arm/tpws differ diff --git a/binaries/freebsd-x64/tpws b/binaries/freebsd-x64/tpws index e3479c5f..31abeb9c 100755 Binary files a/binaries/freebsd-x64/tpws and b/binaries/freebsd-x64/tpws differ diff --git a/binaries/mac64/tpws b/binaries/mac64/tpws index ee436be6..77c6fdfc 100755 Binary files a/binaries/mac64/tpws and b/binaries/mac64/tpws differ diff --git a/binaries/mips32r1-lsb/tpws b/binaries/mips32r1-lsb/tpws index 590d4e82..e948c275 100755 Binary files a/binaries/mips32r1-lsb/tpws and b/binaries/mips32r1-lsb/tpws differ diff --git a/binaries/mips32r1-msb/tpws b/binaries/mips32r1-msb/tpws index 2c97b5ae..afd38bcc 100755 Binary files a/binaries/mips32r1-msb/tpws and b/binaries/mips32r1-msb/tpws differ diff --git a/binaries/mips64r2-msb/tpws b/binaries/mips64r2-msb/tpws index 720373dc..e0419c90 100755 Binary files a/binaries/mips64r2-msb/tpws and b/binaries/mips64r2-msb/tpws differ diff --git a/binaries/ppc/tpws b/binaries/ppc/tpws index 99ef3de4..9bdffcd3 100755 Binary files a/binaries/ppc/tpws and b/binaries/ppc/tpws differ diff --git a/binaries/x86/tpws b/binaries/x86/tpws index 0571317f..af52d8de 100755 Binary files a/binaries/x86/tpws and b/binaries/x86/tpws differ diff --git a/binaries/x86_64/tpws b/binaries/x86_64/tpws index e3d781e5..718b5e7b 100755 Binary files a/binaries/x86_64/tpws and b/binaries/x86_64/tpws differ diff --git a/binaries/x86_64/tpws_wsl.tgz b/binaries/x86_64/tpws_wsl.tgz index ba5b991a..a016f876 100644 Binary files a/binaries/x86_64/tpws_wsl.tgz and b/binaries/x86_64/tpws_wsl.tgz differ diff --git a/tpws/tpws_conn.c b/tpws/tpws_conn.c index d92e1b1a..07e6d492 100644 --- a/tpws/tpws_conn.c +++ b/tpws/tpws_conn.c @@ -260,11 +260,15 @@ static bool conn_has_unsent_pair(tproxy_conn_t *conn) return conn_has_unsent(conn) || (conn_partner_alive(conn) && conn_has_unsent(conn->partner)); } -static void conn_shutdown(tproxy_conn_t *conn) +static bool conn_shutdown(tproxy_conn_t *conn) { - if (shutdown(conn->fd,SHUT_WR)<0) - DLOG_PERROR("shutdown"); conn->bShutdown = true; + if (shutdown(conn->fd,SHUT_WR)<0) + { + DLOG_PERROR("shutdown"); + return false; + } + return true; } static ssize_t send_or_buffer(send_buffer_t *sb, int fd, const void *buf, size_t len, int flags, int ttl) @@ -761,7 +765,11 @@ static bool handle_unsent(tproxy_conn_t *conn) if (!conn->bShutdown) { DBGPRINT("fd=%d no more has unsent. partner in RDHUP state. executing delayed shutdown.\n", conn->fd); - conn_shutdown(conn); + if (!conn_shutdown(conn)) + { + DBGPRINT("emergency connection close due to failed shutdown\n"); + return false; + } } if (conn->state==CONN_RDHUP && !conn_has_unsent(conn->partner)) { @@ -1606,7 +1614,11 @@ int event_loop(const int *listen_fd, size_t listen_fd_ct) else { DBGPRINT("partner has no unsent. shutting down partner.\n"); - conn_shutdown(conn->partner); + if (!conn_shutdown(conn->partner)) + { + DBGPRINT("emergency connection close due to failed shutdown\n"); + conn_close_with_partner_check(&conn_list,&close_list,conn); + } if (conn->partner->state==CONN_RDHUP) { DBGPRINT("both partners are in RDHUP state and have no unsent. closing.\n"); @@ -1644,7 +1656,12 @@ int event_loop(const int *listen_fd, size_t listen_fd_ct) if ((conn->state == CONN_RDHUP) && conn_partner_alive(conn) && !conn->partner->bShutdown && !conn_has_unsent(conn)) { DBGPRINT("conn fd=%d has no unsent. shutting down partner.\n", conn->fd); - conn_shutdown(conn->partner); + if (!conn_shutdown(conn->partner)) + { + DBGPRINT("emergency connection close due to failed shutdown\n"); + conn_close_with_partner_check(&conn_list,&close_list,conn); + continue; + } } }