Skip to content

Commit b351d1b

Browse files
committed
Making cache as global
1 parent 018356a commit b351d1b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

simple_dns_server.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "args.h"
2323
#include "Dns.hpp"
2424

25+
dns::Cache cache;
26+
2527
static void udp_cb(const int sock, short int which, void *arg){
2628

2729
struct sockaddr_in server_sin;
@@ -34,13 +36,15 @@ static void udp_cb(const int sock, short int which, void *arg){
3436
event_loopbreak();
3537
}
3638

37-
dns::Cache cache;
38-
cache.load(arguments.host_file);
3939
dns::Resolver resolver(cache);
40+
4041
dns::Package package(buf);
42+
4143
if (arguments.verbose)
4244
package.prettyPrint();
45+
4346
resolver.resolve(package);
47+
4448
if (arguments.verbose)
4549
package.prettyPrint();
4650

@@ -81,6 +85,8 @@ int main(int argc, char **argv) {
8185

8286
}
8387

88+
cache.load(arguments.host_file);
89+
8490
sock = socket(AF_INET, SOCK_DGRAM, 0);
8591
memset(&sin, 0, sizeof(sin));
8692
sin.sin_family = AF_INET;

0 commit comments

Comments
 (0)