From 3d668aabb6eb17252672bb3d900e406ba8ce3fb2 Mon Sep 17 00:00:00 2001 From: Soner Tari Date: Thu, 25 Oct 2018 14:58:18 +0300 Subject: [PATCH] Minor improvements --- protopassthrough.c | 6 +++--- pxyconn.c | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/protopassthrough.c b/protopassthrough.c index 4d4e165..17fde8c 100644 --- a/protopassthrough.c +++ b/protopassthrough.c @@ -95,9 +95,9 @@ protopassthrough_engage(pxy_conn_ctx_t *ctx) // Free any/all data of the previous proto if (ctx->protoctx->proto_free) { ctx->protoctx->proto_free(ctx); + // Disable proto_free callback of the previous proto, otherwise it is called while passthrough is closing too + ctx->protoctx->proto_free = NULL; } - // Disable proto_free callback of the previous proto, or it is called while passthrough is closing too - ctx->protoctx->proto_free = NULL; ctx->proto = protopassthrough_setup(ctx); pxy_fd_readcb(ctx->fd, 0, ctx); @@ -420,7 +420,7 @@ protopassthrough_bev_eventcb(struct bufferevent *bev, short events, void *arg) if (bev == ctx->src.bev) { protopassthrough_log_connect_src(ctx); } else if (ctx->connected) { - // @todo Do we need to set dstaddr here? It must have already been set by the original proto. + // @attention dstaddr may not have been set by the original proto. if (pxy_set_dstaddr(ctx) == -1) { return; } diff --git a/pxyconn.c b/pxyconn.c index 1c979bf..59ffe49 100644 --- a/pxyconn.c +++ b/pxyconn.c @@ -798,7 +798,7 @@ pxy_log_dbg_disconnect_child(pxy_conn_child_ctx_t *ctx) } } -#ifdef HAVE_NETFILTER +#ifdef __linux__ /* * Copied from: * https://github.com/tmux/tmux/blob/master/compat/getdtablecount.c @@ -819,7 +819,7 @@ getdtablecount() globfree(&g); return n; } -#endif /* HAVE_NETFILTER */ +#endif /* __linux__ */ unsigned char * pxy_malloc_packet(size_t sz, pxy_conn_ctx_t *ctx) @@ -1229,6 +1229,7 @@ int pxy_set_dstaddr(pxy_conn_ctx_t *ctx) { if (sys_sockaddr_str((struct sockaddr *)&ctx->addr, ctx->addrlen, &ctx->dsthost_str, &ctx->dstport_str) != 0) { + // sys_sockaddr_str() may fail due to either malloc() or getnameinfo() ctx->enomem = 1; pxy_conn_term(ctx, 1); return -1;