diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2024-02-26 12:21:04 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2024-02-26 12:21:04 +0100 |
commit | 0b38a3d937eb554dbefa3fe12093c460298beddc (patch) | |
tree | 524af6d96bbd89985cae189732778c63974d07a7 | |
parent | 3d1f1f49d41855f23a4943c83dd7cfec7c0c2f34 (diff) | |
download | gnunet-0b38a3d937eb554dbefa3fe12093c460298beddc.tar.gz gnunet-0b38a3d937eb554dbefa3fe12093c460298beddc.zip |
TRANSPORT: Attempt CPU hog fix in communicator
-rw-r--r-- | src/service/transport/gnunet-communicator-tcp.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/service/transport/gnunet-communicator-tcp.c b/src/service/transport/gnunet-communicator-tcp.c index 0e061ab76..b08b571d1 100644 --- a/src/service/transport/gnunet-communicator-tcp.c +++ b/src/service/transport/gnunet-communicator-tcp.c | |||
@@ -1407,11 +1407,12 @@ do_rekey (struct Queue *queue, const struct TCPRekey *rekey) | |||
1407 | } | 1407 | } |
1408 | queue->rekey_monotonic_time = rekey->monotonic_time; | 1408 | queue->rekey_monotonic_time = rekey->monotonic_time; |
1409 | queue->rekey_monotime_get = GNUNET_PEERSTORE_iteration_start (peerstore, | 1409 | queue->rekey_monotime_get = GNUNET_PEERSTORE_iteration_start (peerstore, |
1410 | "transport_tcp_communicator", | 1410 | "transport_tcp_communicator", |
1411 | &queue->target, | 1411 | &queue->target, |
1412 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY, | 1412 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY, |
1413 | &rekey_monotime_cb, | 1413 | & |
1414 | queue); | 1414 | rekey_monotime_cb, |
1415 | queue); | ||
1415 | gcry_cipher_close (queue->in_cipher); | 1416 | gcry_cipher_close (queue->in_cipher); |
1416 | queue->rekeyed = GNUNET_YES; | 1417 | queue->rekeyed = GNUNET_YES; |
1417 | setup_in_cipher (&rekey->ephemeral, queue); | 1418 | setup_in_cipher (&rekey->ephemeral, queue); |
@@ -2127,8 +2128,19 @@ queue_read (void *cls) | |||
2127 | } | 2128 | } |
2128 | /* try again */ | 2129 | /* try again */ |
2129 | left = GNUNET_TIME_absolute_get_remaining (queue->timeout); | 2130 | left = GNUNET_TIME_absolute_get_remaining (queue->timeout); |
2130 | queue->read_task = | 2131 | if (0 != left.rel_value_us) |
2131 | GNUNET_SCHEDULER_add_read_net (left, queue->sock, &queue_read, queue); | 2132 | { |
2133 | queue->read_task = | ||
2134 | GNUNET_SCHEDULER_add_read_net (left, queue->sock, &queue_read, queue); | ||
2135 | return; | ||
2136 | } | ||
2137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2138 | "Queue %p was idle for %s, disconnecting\n", | ||
2139 | queue, | ||
2140 | GNUNET_STRINGS_relative_time_to_string ( | ||
2141 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | ||
2142 | GNUNET_YES)); | ||
2143 | queue_finish (queue); | ||
2132 | return; | 2144 | return; |
2133 | } | 2145 | } |
2134 | if (0 == rcvd) | 2146 | if (0 == rcvd) |
@@ -2199,7 +2211,6 @@ queue_read (void *cls) | |||
2199 | if (max_queue_length > queue->backpressure) | 2211 | if (max_queue_length > queue->backpressure) |
2200 | { | 2212 | { |
2201 | /* continue reading */ | 2213 | /* continue reading */ |
2202 | left = GNUNET_TIME_absolute_get_remaining (queue->timeout); | ||
2203 | queue->read_task = | 2214 | queue->read_task = |
2204 | GNUNET_SCHEDULER_add_read_net (left, queue->sock, &queue_read, queue); | 2215 | GNUNET_SCHEDULER_add_read_net (left, queue->sock, &queue_read, queue); |
2205 | } | 2216 | } |
@@ -2859,11 +2870,11 @@ decrypt_and_check_tc (struct Queue *queue, | |||
2859 | if (GNUNET_YES == ret) | 2870 | if (GNUNET_YES == ret) |
2860 | queue->handshake_monotime_get = | 2871 | queue->handshake_monotime_get = |
2861 | GNUNET_PEERSTORE_iteration_start (peerstore, | 2872 | GNUNET_PEERSTORE_iteration_start (peerstore, |
2862 | "transport_tcp_communicator", | 2873 | "transport_tcp_communicator", |
2863 | &queue->target, | 2874 | &queue->target, |
2864 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE, | 2875 | GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE, |
2865 | &handshake_monotime_cb, | 2876 | &handshake_monotime_cb, |
2866 | queue); | 2877 | queue); |
2867 | return ret; | 2878 | return ret; |
2868 | } | 2879 | } |
2869 | 2880 | ||