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:
+7
-5
@@ -890,10 +890,10 @@ static int send_sync_message(ChunkServer *state)
|
|||||||
|
|
||||||
int chunk_server_init(ChunkServer *state, int argc, char **argv, void **contexts, struct pollfd *polled, int *timeout)
|
int chunk_server_init(ChunkServer *state, int argc, char **argv, void **contexts, struct pollfd *polled, int *timeout)
|
||||||
{
|
{
|
||||||
string addr = getargs(argc, argv, "--addr", "127.0.0.1");
|
string addr = getargs(argc, argv, "--addr", "127.0.0.1");
|
||||||
int port = getargi(argc, argv, "--port", 8081);
|
int port = getargi(argc, argv, "--port", 8081);
|
||||||
string path = getargs(argc, argv, "--path", "chunk_server_data/");
|
string path = getargs(argc, argv, "--path", "chunk_server_data/");
|
||||||
bool trace = getargb(argc, argv, "--trace");
|
bool trace = getargb(argc, argv, "--trace");
|
||||||
string remote_addr = getargs(argc, argv, "--remote-addr", "127.0.0.1");
|
string remote_addr = getargs(argc, argv, "--remote-addr", "127.0.0.1");
|
||||||
int remote_port = getargi(argc, argv, "--remote-port", 8080);
|
int remote_port = getargi(argc, argv, "--remote-port", 8080);
|
||||||
|
|
||||||
@@ -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
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user