simplify do_tcp(...)

This commit is contained in:
sudden6 2021-01-02 22:53:47 +01:00
parent c9ad4a2e39
commit 25a56c3549
No known key found for this signature in database
GPG Key ID: 279509B499E032B9

View File

@ -2287,9 +2287,7 @@ static void do_tcp(Net_Crypto *c, void *userdata)
do_tcp_connections(c->log, c->tcp_c, userdata); do_tcp_connections(c->log, c->tcp_c, userdata);
pthread_mutex_unlock(&c->tcp_mutex); pthread_mutex_unlock(&c->tcp_mutex);
uint32_t i; for (uint32_t i = 0; i < c->crypto_connections_length; ++i) {
for (i = 0; i < c->crypto_connections_length; ++i) {
Crypto_Connection *conn = get_crypto_connection(c, i); Crypto_Connection *conn = get_crypto_connection(c, i);
if (conn == nullptr) { if (conn == nullptr) {
@ -2300,21 +2298,15 @@ static void do_tcp(Net_Crypto *c, void *userdata)
continue; continue;
} }
bool direct_connected = 0; bool direct_connected = false;
if (!crypto_connection_status(c, i, &direct_connected, nullptr)) { if (!crypto_connection_status(c, i, &direct_connected, nullptr)) {
continue; continue;
} }
if (direct_connected) { pthread_mutex_lock(&c->tcp_mutex);
pthread_mutex_lock(&c->tcp_mutex); set_tcp_connection_to_status(c->tcp_c, conn->connection_number_tcp, !direct_connected);
set_tcp_connection_to_status(c->tcp_c, conn->connection_number_tcp, 0); pthread_mutex_unlock(&c->tcp_mutex);
pthread_mutex_unlock(&c->tcp_mutex);
} else {
pthread_mutex_lock(&c->tcp_mutex);
set_tcp_connection_to_status(c->tcp_c, conn->connection_number_tcp, 1);
pthread_mutex_unlock(&c->tcp_mutex);
}
} }
} }