From fc549805c1abfeac3d73f88aa95c1f58dc5ef499 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Wed, 22 Apr 2015 09:45:33 -0400 Subject: Fixed a case where the tcp_data_callback would get called when the connection only worked 1 way. --- toxcore/TCP_connection.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'toxcore/TCP_connection.c') diff --git a/toxcore/TCP_connection.c b/toxcore/TCP_connection.c index 26b35a92..d4c1b7c1 100644 --- a/toxcore/TCP_connection.c +++ b/toxcore/TCP_connection.c @@ -921,11 +921,13 @@ static int tcp_oob_callback(void *object, const uint8_t *public_key, const uint8 /* TODO: optimize */ int connections_number = find_tcp_connection_to(tcp_c, public_key); - if (connections_number == -1) { + TCP_Connection_to *con_to = get_connection(tcp_c, connections_number); + + if (con_to && tcp_connection_in_conn(con_to, tcp_connections_number)) { + return tcp_data_callback(object, connections_number, 0, data, length); + } else { if (tcp_c->tcp_oob_callback) tcp_c->tcp_oob_callback(tcp_c->tcp_oob_callback_object, public_key, tcp_connections_number, data, length); - } else { - return tcp_data_callback(object, connections_number, 0, data, length); } return 0; -- cgit v1.2.3