Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-signal committed Oct 19, 2023
1 parent ac3a876 commit 330fb74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
16 changes: 14 additions & 2 deletions src/apps/relay/netengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
11 changes: 2 additions & 9 deletions src/apps/relay/turn_admin_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 330fb74

Please sign in to comment.