~ubuntu-branches/ubuntu/raring/maradns/raring

« back to all changes in this revision

Viewing changes to update/1.3.04/maradns-1.3.03-connect_udp.patch

  • Committer: Bazaar Package Importer
  • Author(s): Kai Hendry
  • Date: 2010-01-24 12:17:40 UTC
  • mfrom: (1.1.13 upstream) (10.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100124121740-a4e1fjobwaouz443
Tags: 1.4.02-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--- maradns-1.3.03/server/recursive.c   2007-02-14 07:25:28.000000000 -0800
2
 
+++ maradns-1.3.04/server/recursive.c   2007-02-16 13:46:29.000000000 -0800
3
 
@@ -1685,8 +1685,7 @@
4
 
            printf("Bind failed, trying again\n");
5
 
            log_unlock();
6
 
            }
7
 
-        /* XXX read some kvars which determine the range of this 
8
 
-          (V1.2 feature) */
9
 
+        /* To add: Read mararc parameters which determine the range of this */
10
 
         dns_udp.sin_port = htons(15000 + (srng() & 4095));
11
 
        counter++;
12
 
        } while(bind(s,(struct sockaddr *)&dns_udp,sizeof(dns_udp)) < 0 &&
13
 
@@ -1707,8 +1706,16 @@
14
 
     /* (End code snippet removed in rng-disabled version) */
15
 
 
16
 
     /* And send, on the same socket, the message to the server */
17
 
-    counter = sendto(s,outdata->string,outdata->unit_count,0,
18
 
-                 (struct sockaddr *)&server,len_inet);
19
 
+    /* Thanks to Rani Assaf for pointing out that you can actually
20
 
+     * connect with a UDP connection */
21
 
+#ifdef SELECT_PROBLEM
22
 
+    /* Set socket to non-blocking mode to work around select() being
23
 
+       unreliable in linux; packet may have been dropped.
24
 
+     */
25
 
+    fcntl(s, F_SETFL, O_NONBLOCK);
26
 
+#endif
27
 
+    connect(s, (struct sockaddr *)&server, sizeof(server));
28
 
+    counter = send(s,outdata->string,outdata->unit_count,0);
29
 
     if(counter < 0) {
30
 
         close(s);
31
 
         if(rlog_level >= 4) {
32
 
@@ -1726,8 +1733,13 @@
33
 
     maxd = s + 1;
34
 
     tv.tv_sec = timeout_seconds;
35
 
     tv.tv_usec = 0;
36
 
+    /* Since a number of different threads will be at this point waiting
37
 
+     * for a reply from a remote DNS server on a heavily loaded resolver,
38
 
+     * we let each thread do a select() at the same time */
39
 
     big_unlock();
40
 
     n = select(maxd,&rx_set,NULL,NULL,&tv);
41
 
+    /* OK, we're done waiting for the slow remote DNS server.  Lock the
42
 
+     * thread again */
43
 
     do_big_lock();
44
 
     if(n == -1)  /* select error */ {
45
 
         if(rlog_level >= 4) {
46
 
@@ -1749,16 +1761,8 @@
47
 
             }
48
 
         goto minus2;
49
 
         }
50
 
-#ifdef SELECT_PROBLEM
51
 
-    /* Set socket to non-blocking mode to work around select() being
52
 
-       unreliable in linux; packet may have been dropped.
53
 
-     */
54
 
-    fcntl(s, F_SETFL, O_NONBLOCK);
55
 
-#endif
56
 
     /* Get the actual reply from the DNS server */
57
 
-    if((count = recvfrom(s,indata->string,indata->max_count,0,
58
 
-                         (struct sockaddr *)&dns_udp,
59
 
-                         (socklen_t *)&len_inet)) < 0) {
60
 
+    if((count = recv(s,indata->string,indata->max_count,0)) < 0) {
61
 
         close(s);
62
 
         if(rlog_level >= 4) {
63
 
             log_lock();