diff --git a/mud.c b/mud.c index 26b90dd..6fc5b29 100644 --- a/mud.c +++ b/mud.c @@ -1415,10 +1415,11 @@ mud_cleanup_path(struct mud *mud, uint64_t now, struct mud_path *path) return path->state <= MUD_DOWN; } -static int +int mud_update(struct mud *mud) { int count = 0; + int mtu_probe = 0; uint64_t rate = 0; size_t mtu = 0; @@ -1436,6 +1437,9 @@ mud_update(struct mud *mud) path->ok = 0; count++; + if (path->mtu.probe) + mtu_probe = 1; + if (!mud->backup && path->state == MUD_BACKUP) continue; @@ -1482,7 +1486,10 @@ mud_update(struct mud *mud) mud->rate = rate; mud->mtu = mtu; - return count; + if (!count) + return -1; + + return (mtu_probe << 1) | (mud->window < 1500); } int @@ -1526,12 +1533,9 @@ mud_set_state(struct mud *mud, struct sockaddr *addr, return 0; } -long +int mud_send_wait(struct mud *mud) { - if (!mud_update(mud)) - return -1; - return mud->window < 1500; } diff --git a/mud.h b/mud.h index 9f310f5..0592ac1 100644 --- a/mud.h +++ b/mud.h @@ -70,6 +70,9 @@ struct mud_bad { struct mud *mud_create (struct sockaddr *); void mud_delete (struct mud *); +int mud_update (struct mud *); +int mud_send_wait (struct mud *); + int mud_get_fd (struct mud *); size_t mud_get_mtu (struct mud *); int mud_get_bad (struct mud *, struct mud_bad *); @@ -77,8 +80,6 @@ int mud_get_bad (struct mud *, struct mud_bad *); int mud_set_key (struct mud *, unsigned char *, size_t); int mud_get_key (struct mud *, unsigned char *, size_t *); -long mud_send_wait (struct mud *); - int mud_set_time_tolerance (struct mud *, unsigned long); int mud_set_keyx_timeout (struct mud *, unsigned long); int mud_set_loss_limit (struct mud *, unsigned); diff --git a/test.c b/test.c index e387cca..64b0527 100644 --- a/test.c +++ b/test.c @@ -62,7 +62,7 @@ main(int argc, char **argv) for (;;) { // mandatory, mud have lot of work to do. - if (mud_send_wait(mud)) + if (mud_update(mud)) usleep(100000); // don't use all the cpu if (client) {