summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-09-21 11:24:43 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2009-09-21 11:24:43 +0200
commit81d97cfa2654827029492b23fc11bcb86e8e3912 (patch)
tree29f3dc0cf66183eb6dac9680ff86a3cf7afc37b9 /src
parent530eed5796faa5fd16c39743a4516bef0e26449c (diff)
conntrackd: improve error handling in tcp_send
With this patch, we increase the error stats if: * we failed to connect to the other peer. * some unexpected error made connect() fail. * sendto returned ECONNRESET or EPIPE. Moreover, we propagate the sendto() errors to upper layers under failure as Samuel Gauthier suggested. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/tcp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tcp.c b/src/tcp.c
index f99c1cb..2b7ca19 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -301,9 +301,11 @@ ssize_t tcp_send(struct tcp_sock *m, const void *data, int size)
} else if (errno == ECONNREFUSED) {
/* connection refused. */
m->state = TCP_CLIENT_DISCONNECTED;
+ m->stats.error++;
} else {
/* unexpected error, give up. */
m->state = TCP_CLIENT_DISCONNECTED;
+ m->stats.error++;
}
break;
} else {
@@ -318,9 +320,10 @@ ssize_t tcp_send(struct tcp_sock *m, const void *data, int size)
close(m->fd);
tcp_client_init(m, tcp_client_conf);
m->state = TCP_CLIENT_DISCONNECTED;
+ m->stats.error++;
} else {
m->stats.error++;
- return 0;
+ return -1;
}
}
}