Fix value of CHUNK_SERVER_RECONNECT_TIME by expressing it in seconds, also change it to a runtime-modifiable value

This commit is contained in:
2025-11-15 12:10:26 +01:00
parent 11054cae86
commit 7af1bc27b5
2 changed files with 8 additions and 7 deletions
+3 -1
View File
@@ -907,6 +907,8 @@ int chunk_server_init(ChunkServer *state, int argc, char **argv, void **contexts
state->trace = trace; state->trace = trace;
state->reconnect_delay = 1; // 1 second
tcp_context_init(&state->tcp); tcp_context_init(&state->tcp);
int ret = tcp_listen(&state->tcp, addr, port); int ret = tcp_listen(&state->tcp, addr, port);
@@ -1109,7 +1111,7 @@ int chunk_server_step(ChunkServer *state, void **contexts, struct pollfd *polled
start_download(state); start_download(state);
if (state->disconnect_time != INVALID_TIME) { if (state->disconnect_time != INVALID_TIME) {
Time reconnect_time = state->disconnect_time + (Time) CHUNK_SERVER_RECONNECT_TIME * 1000000000; Time reconnect_time = state->disconnect_time + (Time) state->reconnect_delay * 1000000000;
if (reconnect_time <= current_time) { if (reconnect_time <= current_time) {
state->disconnect_time = INVALID_TIME; state->disconnect_time = INVALID_TIME;
if (start_connecting_to_metadata_server(state) < 0) if (start_connecting_to_metadata_server(state) < 0)
+1 -2
View File
@@ -10,8 +10,6 @@
#define TAG_METADATA_SERVER 1 #define TAG_METADATA_SERVER 1
#define TAG_CHUNK_SERVER 2 #define TAG_CHUNK_SERVER 2
#define CHUNK_SERVER_RECONNECT_TIME 10000
typedef struct { typedef struct {
char path[PATH_MAX]; char path[PATH_MAX];
} ChunkStore; } ChunkStore;
@@ -37,6 +35,7 @@ typedef struct {
Time disconnect_time; Time disconnect_time;
Time last_sync_time; Time last_sync_time;
int reconnect_delay; // In seconds
TCP tcp; TCP tcp;