From d3f3ee16d8adaef681afed67f236e3bb14e7cdc0 Mon Sep 17 00:00:00 2001 From: Joel Grunbaum <joelgrun@gmail.com> Date: Wed, 21 Oct 2020 13:05:26 +0000 Subject: [PATCH] change artifact name and added penalty for failed connections --- .gitignore | 3 ++- slist.c | 1 - Makefile | 4 ++-- main.c | 22 ++++++---------------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 543fa90..d297a5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o *.out -*~ \ No newline at end of file +*~ +dnscomp \ No newline at end of file diff --git a/Makefile b/Makefile index cdddcb0..582a31d 100644 --- a/Makefile +++ b/Makefile @@ -9,12 +9,12 @@ DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS)) OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) -default: a.out +default: dnscomp %.o: %c $(DEPS) $(CC) $(CFLAGS) -c -o $@ $< -a.out: $(_OBJ) +dnscomp: $(_OBJ) $(CC) $(CFLAGS) -o $@ $^ .PHONY: clean diff --git a/main.c b/main.c index 2f86224..5fb4cf2 100644 --- a/main.c +++ b/main.c @@ -16,19 +16,6 @@ #define NUM_TESTS 10 -/* struct test_server_input { */ -/* int dns; */ -/* //struct hosts_list *hosts; */ -/* int num_hosts; */ -/* int num_tests; */ -/* }; */ - -/* struct progress_input { */ -/* int num_hosts; */ -/* int num_tests; */ -/* int num_servers; */ -/* }; */ - int test_dns(void); void *test_server(void *in); void *print_progress(void *in); @@ -117,10 +104,13 @@ struct hosts_list *curr = hosts; while (curr) { struct timespec run; + run.tv_sec = -1; run.tv_nsec = 0; unsigned char buf[65536]; - run = resolve(buf, curr->server, dns->server, T_A); - if (run.tv_sec == -1) //currently ignore failed tests, need to figure out what to do with them - continue; + for (int i = 0; i < 3 && run.tv_sec == -1; i++) { + run = resolve(buf, curr->server, dns->server, T_A); + } + if (run.tv_sec == -1) //if test has failed 3 times, set time taken to 3s as penalty + run.tv_sec = 3; dns->time.tv_sec += run.tv_sec; dns->time.tv_nsec += run.tv_nsec; if (dns->time.tv_nsec >= 1000000000) { //nanoseconds have overflowed into seconds diff --git a/slist.c b/slist.c index 45bb3e6..5e799c9 100644 --- a/slist.c +++ b/slist.c @@ -99,7 +99,6 @@ struct dns_list *merge(struct dns_list *a, struct dns_list *b) { struct dns_list *out = NULL; - int comp; if (!a) return b; if (!b) -- Gitblit v1.10.0