Don't initialize monotone timestamps with zero

The monotone timestamp is near zero on linux systems, confusing fastd.
This commit is contained in:
Matthias Schiffer 2013-08-29 19:04:31 +02:00
parent 620f1cd45f
commit 7f33ccb920
4 changed files with 14 additions and 5 deletions

View file

@ -769,6 +769,9 @@ int main(int argc, char *argv[]) {
update_time(&ctx);
conf.long_ago = ctx.now;
conf.long_ago.tv_sec -= 86400; /* 24h in the past */
ctx.next_keepalives = ctx.now;
ctx.next_keepalives.tv_sec += conf.keepalive_interval;

View file

@ -162,6 +162,8 @@ struct fastd_peer_group {
};
struct fastd_config {
struct timespec long_ago;
fastd_loglevel_t log_stderr_level;
fastd_loglevel_t log_syslog_level;
char *log_syslog_ident;

View file

@ -201,16 +201,16 @@ static void setup_peer(fastd_context_t *ctx, fastd_peer_t *peer) {
fastd_remote_t *remote;
for (remote = peer->remotes; remote; remote = remote->next) {
remote->last_resolve = (struct timespec){0, 0};
remote->last_resolve_return = (struct timespec){0, 0};
remote->last_resolve = ctx->conf->long_ago;
remote->last_resolve_return = ctx->conf->long_ago;
}
peer->next_remote = peer->remotes;
peer->last_handshake = (struct timespec){0, 0};
peer->last_handshake = ctx->conf->long_ago;
peer->last_handshake_address.sa.sa_family = AF_UNSPEC;
peer->last_handshake_response = (struct timespec){0, 0};
peer->last_handshake_response = ctx->conf->long_ago;
peer->last_handshake_response_address.sa.sa_family = AF_UNSPEC;
if (!peer->protocol_state)

View file

@ -240,8 +240,12 @@ static bool protocol_peer_check_temporary(fastd_context_t *ctx, fastd_peer_t *pe
}
static void init_protocol_state(fastd_context_t *ctx) {
if (!ctx->protocol_state)
if (!ctx->protocol_state) {
ctx->protocol_state = calloc(1, sizeof(fastd_protocol_state_t));
ctx->protocol_state->prev_handshake_key.preferred_till = ctx->conf->long_ago;
ctx->protocol_state->handshake_key.preferred_till = ctx->conf->long_ago;
}
}
static void new_handshake_key(fastd_context_t *ctx, keypair_t *key) {