Fix measlat

This commit is contained in:
Quentin 2019-10-16 17:56:51 +02:00
parent c4ec089d44
commit a90018c871

View file

@ -36,6 +36,7 @@ void register_timer(struct evt_core_ctx* evts, struct timespec* next_tick) {
exit(EXIT_FAILURE);
}
struct measlat_ctx* mctx = ucat->app_ctx;
mctx->is_timer_started = 1;
if (clock_gettime(CLOCK_REALTIME, &now) == -1) {
@ -98,7 +99,7 @@ int on_receive_measure_packet(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
}
// Used to start sending from the server in sync with client
if (!mctx->is_timer_started) {
if (!mctx->is_timer_started && mctx->mc.counter <= mctx->mc.max_measure) {
struct timespec next_tick = {0};
measure_next_tick(&mctx->mc, &next_tick);
register_timer (ctx, &next_tick);
@ -159,7 +160,7 @@ int on_timer(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
struct evt_core_fdinfo* tgtinfo = evt_core_get_first_from_cat (ctx, "udp-read");
if (tgtinfo == NULL) tgtinfo = evt_core_get_first_from_cat (ctx, "tcp-read");
if (tgtinfo == NULL) {
if (tgtinfo == NULL || mctx->mc.counter > mctx->mc.max_measure) {
printf("No connection yet\n");
struct evt_core_fdinfo* timer_fd = evt_core_get_first_from_cat (ctx, "timer");
evt_core_rm_fd(ctx, timer_fd->fd);