From 22e065e5cb972535ebd3f31f058d8a53c325b843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Fri, 15 Jun 2018 10:05:42 +0000 Subject: [PATCH] Add mud_sync() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud.c | 5 ++++- mud.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mud.c b/mud.c index 91723db..3a0cdda 100644 --- a/mud.c +++ b/mud.c @@ -502,9 +502,12 @@ mud_cmp_addr(struct sockaddr_storage *a, struct sockaddr_storage *b) } unsigned long -mud_get_sync_elapsed_msec(struct mud *mud) +mud_sync(struct mud *mud) { const uint64_t last = mud->last_recv_time; + + mud_send(mud, NULL, 0, 0); + return last ? MUD_TIME_MASK(mud_now() - last) / MUD_ONE_MSEC : ~0UL; } diff --git a/mud.h b/mud.h index 6be2827..09f0694 100644 --- a/mud.h +++ b/mud.h @@ -70,7 +70,7 @@ int mud_get_key (struct mud *, unsigned char *, size_t *); void mud_set_mtu (struct mud *, size_t); size_t mud_get_mtu (struct mud *); -unsigned long mud_get_sync_elapsed_msec (struct mud *); +unsigned long mud_sync (struct mud *); int mud_set_send_timeout (struct mud *, unsigned long); int mud_set_time_tolerance (struct mud *, unsigned long);