[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-dev] [Patch] or/eventdns.c



I've made eventdns.c + '-DEVDNS_MAIN' compile and work
under Windows / MSVC. Some simple patches:

* Use set_socket_nonblocking() instead of the F_SETFL hacks.
* Preserve the ret-val from evdns_config_windows_nameservers().
* In main(), call network_init() to call WSAStartup() etc.
* Removed 'evdns_resolv_conf_parse(DNS_OPTION_NAMESERVERS, ...'
 and call evdns_init() instead. This uses 'DNS_OPTIONS_ALL'. Does that
 really matter?

Attached diff-1.txt. (sorry, I'm a Git neophyte).

--gv
--- Git-latest\src\or\eventdns.c	Wed Oct 19 21:11:09 2011
+++ or\eventdns.c	Wed Oct 19 20:44:05 2011
@@ -2293,14 +2293,7 @@

	ns->socket = tor_open_socket(address->sa_family, SOCK_DGRAM, 0);
	if (ns->socket < 0) { err = 1; goto out1; }
-#ifdef WIN32
-	{
-		u_long nonblocking = 1;
-		ioctlsocket(ns->socket, FIONBIO, &nonblocking);
-	}
-#else
-	fcntl(ns->socket, F_SETFL, O_NONBLOCK);
-#endif
+	set_socket_nonblocking(ns->socket);

	if (global_bind_addr_is_set &&
	    !sockaddr_is_loopback((struct sockaddr*)&global_bind_address)) {
@@ -3305,11 +3298,10 @@
{
		int res = 0;
#ifdef WIN32
-		evdns_config_windows_nameservers();
+		res = evdns_config_windows_nameservers();
#else
		res = evdns_resolv_conf_parse(DNS_OPTIONS_ALL, "/etc/resolv.conf");
#endif
-
		return (res);
}

@@ -3453,15 +3445,17 @@
			fprintf(stderr, "Unknown option %s\n", v[idx]);
		++idx;
	}
+	network_init();
	event_init();
+	evdns_init();
	if (verbose)
		evdns_set_log_fn(logfn);
-	evdns_resolv_conf_parse(DNS_OPTION_NAMESERVERS, "/etc/resolv.conf");
+
	if (servertest) {
		int sock;
		struct sockaddr_in my_addr;
		sock = tor_open_socket(PF_INET, SOCK_DGRAM, 0);
-		fcntl(sock, F_SETFL, O_NONBLOCK);
+		set_socket_nonblocking(sock);
		my_addr.sin_family = AF_INET;
		my_addr.sin_port = htons(10053);
		my_addr.sin_addr.s_addr = INADDR_ANY;
_______________________________________________
tor-dev mailing list
tor-dev@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev