Skip to content

Commit

Permalink
cf-socket: TCP trace output local address used in connect
Browse files Browse the repository at this point in the history
Closes curl#12427
  • Loading branch information
icing authored and bagder committed Dec 1, 2023
1 parent 8414273 commit 83e4d61
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/cf-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ static CURLcode cf_tcp_connect(struct Curl_cfilter *cf,

*done = FALSE; /* a very negative world view is best */
if(ctx->sock == CURL_SOCKET_BAD) {
int error;

result = cf_socket_open(cf, data);
if(result)
Expand All @@ -1158,8 +1159,12 @@ static CURLcode cf_tcp_connect(struct Curl_cfilter *cf,

/* Connect TCP socket */
rc = do_connect(cf, data, cf->conn->bits.tcp_fastopen);
error = SOCKERRNO;
set_local_ip(cf, data);
CURL_TRC_CF(data, cf, "local address %s port %d...",
ctx->l_ip, ctx->l_port);
if(-1 == rc) {
result = socket_connect_result(data, ctx->r_ip, SOCKERRNO);
result = socket_connect_result(data, ctx->r_ip, error);
goto out;
}
}
Expand Down Expand Up @@ -1197,13 +1202,14 @@ static CURLcode cf_tcp_connect(struct Curl_cfilter *cf,
out:
if(result) {
if(ctx->error) {
set_local_ip(cf, data);
data->state.os_errno = ctx->error;
SET_SOCKERRNO(ctx->error);
#ifndef CURL_DISABLE_VERBOSE_STRINGS
{
char buffer[STRERROR_LEN];
infof(data, "connect to %s port %u failed: %s",
ctx->r_ip, ctx->r_port,
infof(data, "connect to %s port %u from %s port %d failed: %s",
ctx->r_ip, ctx->r_port, ctx->l_ip, ctx->l_port,
Curl_strerror(ctx->error, buffer, sizeof(buffer)));
}
#endif
Expand Down

0 comments on commit 83e4d61

Please sign in to comment.