Skip to content

Commit c0f870f

Browse files
committed
refactor: Move global last_bootstrap_time to Toxic struct
Addresses an existing TODO and improves state management (one more step towards reentrant toxic).
1 parent 3b7990b commit c0f870f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/bootstrap.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,10 @@ void do_tox_connection(Toxic *toxic)
667667
return;
668668
}
669669

670-
static time_t last_bootstrap_time = 0; // TODO: Put this in Toxic
671670
const bool connected = prompt_selfConnectionStatus(toxic) != TOX_CONNECTION_NONE;
672671

673-
if (!connected && timed_out(last_bootstrap_time, TRY_BOOTSTRAP_INTERVAL)) {
672+
if (!connected && timed_out(toxic->last_bootstrap_time, TRY_BOOTSTRAP_INTERVAL)) {
674673
DHT_bootstrap(toxic->tox);
675-
last_bootstrap_time = get_unix_time();
674+
toxic->last_bootstrap_time = get_unix_time();
676675
}
677676
}

src/toxic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ typedef struct Toxic {
107107

108108
FriendRequests frnd_requests;
109109
Paths *paths;
110+
time_t last_bootstrap_time;
110111
} Toxic;
111112

112113
typedef struct Init_Queue Init_Queue;

0 commit comments

Comments
 (0)