From 63831d6efcc9dc3fcc89dd01ca467d605ec04b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Fri, 9 Mar 2018 23:16:13 +0000 Subject: [PATCH] Update mud and path_status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud | 2 +- src/bind.c | 6 +++--- src/path.c | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mud b/mud index cd4ad61..bb6b87b 160000 --- a/mud +++ b/mud @@ -1 +1 @@ -Subproject commit cd4ad61d1cc04285aa358f74c38b1c50ba96918f +Subproject commit bb6b87bb54689987ab6b473e6563bd8509f0f3ea diff --git a/src/bind.c b/src/bind.c index d85bc4e..4c568dd 100644 --- a/src/bind.c +++ b/src/bind.c @@ -257,10 +257,10 @@ gt_bind(int argc, char **argv) res.ret = EAGAIN; for (unsigned i = 0; i < count; i++) { - if (i && sendto(ctl_fd, &res, sizeof(res), 0, - (const struct sockaddr *)&ss, sl) == -1) - perror("sendto(ctl)"); memcpy(&res.path_status, &paths[i], sizeof(struct mud_path)); + if (sendto(ctl_fd, &res, sizeof(res), 0, + (const struct sockaddr *)&ss, sl) == -1) + perror("sendto(ctl)"); } res.ret = 0; diff --git a/src/path.c b/src/path.c index 819ec6d..f0725ba 100644 --- a/src/path.c +++ b/src/path.c @@ -21,6 +21,12 @@ gt_path_status(int fd) if (recv(fd, &res, sizeof(struct ctl_msg), 0) == -1) return -1; + if (res.type != req.type) + return -2; + + if (!res.ret) + return 0; + char bindstr[INET6_ADDRSTRLEN] = {0}; char peerstr[INET6_ADDRSTRLEN] = {0};