diff --git a/src/apps/relay/netengine.c b/src/apps/relay/netengine.c index 0ca1ad155..6fbea5793 100644 --- a/src/apps/relay/netengine.c +++ b/src/apps/relay/netengine.c @@ -1940,8 +1940,20 @@ size_t cycle_rtt_ms_maps(ur_map ** rtt_ms_maps, size_t len) { ++count; } } - if (pthread_barrier_init(&rtt_barrier, NULL, count + 1) < 0) { - perror("rtt barrier init"); + + static size_t last_count = 0; + if (last_count != count) { + if (last_count) { + if (pthread_barrier_destroy(&rtt_barrier) != 0) { + perror("rtt barrier destroy"); + return 0; + } + } + if (pthread_barrier_init(&rtt_barrier, NULL, count + 1) != 0) { + perror("rtt barrier init"); + return 0; + } + last_count = count; } for (size_t i = 0; i < get_real_general_relay_servers_number(); i++) { diff --git a/src/apps/relay/turn_admin_server.c b/src/apps/relay/turn_admin_server.c index 21f86708d..3960709f5 100644 --- a/src/apps/relay/turn_admin_server.c +++ b/src/apps/relay/turn_admin_server.c @@ -3813,15 +3813,8 @@ void admin_server_rtt_timer_handler(ioa_engine * engine, void * arg) { if (fflush(rtt_file) != 0) { TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "fflush /var/tmp/rtt_dump.tmp failed, not relinking (%d)\n", errno); } else { - if (unlink("/var/tmp/rtt_dump") == -1) { - if (errno != ENOENT) { - TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "could not unlink /var/tmp/rtt_dump (%d)\n", errno); - } - } - if (link("/var/tmp/rtt_dump.tmp", "/var/tmp/rtt_dump") == -1) { - TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "could not link rtt dump as /var/tmp/rtt_dump (%d)\n", errno); - } else { - unlink("/var/tmp/rtt_dump.tmp"); + if (rename("/var/tmp/rtt_dump.tmp", "/var/tmp/rtt_dump") == -1) { + TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "could not rename rtt dump int /var/tmp/rtt_dump (%d)\n", errno); } } fclose(rtt_file);