ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/res.c
(Generate patch)

Comparing:
ircd-hybrid/src/irc_res.c (file contents), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid-7.2/src/irc_res.c (file contents), Revision 982 by michael, Thu Aug 13 22:15:08 2009 UTC

# Line 7 | Line 7
7   * The authors takes no responsibility for any damage or loss
8   * of property which results from the use of this software.
9   *
10 < * $Id: irc_res.c,v 7.46 2005/07/30 03:35:18 metalrock Exp $
10 > * $Id$
11   *
12   * July 1999 - Rewrote a bunch of stuff here. Change hostent builder code,
13   *     added callbacks and reference counting of returned hostents.
# Line 30 | Line 30
30   #include "ircd.h"
31   #include "numeric.h"
32   #include "restart.h"
33 + #include "rng_mt.h"
34   #include "fdlist.h"
35   #include "fileio.h" /* for fbopen / fbclose / fbputs */
36   #include "s_bsd.h"
# Line 136 | Line 137 | res_ourserver(const struct irc_ssaddr *i
137    struct sockaddr_in *v4in = (struct sockaddr_in *)inp;
138    int ns;
139  
140 <  for (ns = 0;  ns < irc_nscount;  ns++)
140 >  for (ns = 0; ns < irc_nscount; ns++)
141    {
142      const struct irc_ssaddr *srv = &irc_nsaddr_list[ns];
143   #ifdef IPV6
# Line 256 | Line 257 | start_resolver(void)
257   void
258   init_resolver(void)
259   {
259 #ifdef HAVE_SRAND48
260  srand48(CurrentTime);
261 #endif
260    memset(&ResolverFileDescriptor, 0, sizeof(fde_t));
261    start_resolver();
262   }
# Line 320 | Line 318 | make_request(struct DNSQuery* query)
318    struct reslist *request;
319  
320    request = (struct reslist *)MyMalloc(sizeof(struct reslist));
323  memset(request, 0, sizeof(struct reslist));
321  
322    request->sentat  = CurrentTime;
323    request->retries = 3;
324    request->resend  = 1;
325    request->timeout = 4;    /* start at 4 and exponential inc. */
329  memset(&request->addr, 0, sizeof(request->addr));
326    request->query   = query;
327    request->state   = REQ_IDLE;
328  
# Line 550 | Line 546 | query_name(const char *name, int query_c
546        (unsigned char *)buf, sizeof(buf))) > 0)
547    {
548      HEADER *header = (HEADER *)buf;
549 < #ifndef HAVE_LRAND48
554 <    int k = 0;
555 <    struct timeval tv;
556 < #endif
549 >
550      /*
551       * generate an unique id
552       * NOTE: we don't have to worry about converting this to and from
553       * network byte order, the nameserver does not interpret this value
554       * and returns it unchanged
555       */
563 #ifdef HAVE_LRAND48
556      do
557 <    {
558 <      header->id = (header->id + lrand48()) & 0xffff;
559 <    } while (find_id(header->id));
568 < #else
569 <    gettimeofday(&tv, NULL);
570 <    do
571 <    {
572 <      header->id = (header->id + k + tv.tv_usec) & 0xffff;
573 <      k++;
574 <    } while (find_id(header->id));
575 < #endif /* HAVE_LRAND48 */
557 >      header->id = (header->id + genrand_int32()) & 0xffff;
558 >    while (find_id(header->id));
559 >
560      request->id = header->id;
561      ++request->sends;
562  
# Line 586 | Line 570 | resend_query(struct reslist *request)
570    if (request->resend == 0)
571      return;
572  
573 <  switch(request->type)
573 >  switch (request->type)
574    {
575      case T_PTR:
576        do_query_number(NULL, &request->addr, request);
# Line 764 | Line 748 | proc_answer(struct reslist *request, HEA
748   static void
749   res_readreply(fde_t *fd, void *data)
750   {
751 <  char buf[sizeof(HEADER) + MAXPACKET];
751 >  char buf[sizeof(HEADER) + MAXPACKET]
752 >        /* Sparc and alpha need 16bit-alignment for accessing header->id
753 >         * (which is uint16_t). Because of the header = (HEADER*) buf;
754 >         * lateron, this is neeeded. --FaUl
755 >         */
756 > #if defined(__sparc__) || defined(__alpha__)  
757 >          __attribute__((aligned (16)))
758 > #endif
759 >          ;
760    HEADER *header;
761    struct reslist *request = NULL;
762    struct DNSReply *reply  = NULL;
# Line 807 | Line 799 | res_readreply(fde_t *fd, void *data)
799  
800    if ((header->rcode != NO_ERRORS) || (header->ancount == 0))
801    {
802 <    if (SERVFAIL == header->rcode)
811 <      resend_query(request);
812 <    else
802 >    if (NXDOMAIN == header->rcode)
803      {
804        /*
805         * If we havent already tried this, and we're looking up AAAA, try A
806         * now
807         */
818
808   #ifdef IPV6
809        if (request->state == REQ_AAAA && request->type == T_AAAA)
810        {
# Line 827 | Line 816 | res_readreply(fde_t *fd, void *data)
816        {
817          request->state = REQ_INT;
818          request->timeout += 4;
819 <        request->retries--;
819 >        request->retries--;
820          resend_query(request);
821        }
822 <      else
822 >      else      /* It's NXDOMAIN but not IPV6 */
823   #endif
824        {
825          /*
826 <         * If a bad error was returned, we stop here and dont send
826 >         * If a bad error was returned, stop here and don't
827           * send any more (no retries granted).
828           */
829          (*request->query->callback)(request->query->ptr, NULL);
830 <        rem_request(request);
831 <      }
830 >        rem_request(request);
831 >      }
832 >    }
833 >    else        /* Some other error other than NXDOMAIN */
834 >    {
835 >      /*
836 >       * If a bad error was returned, stop here and don't
837 >       * send any more (no retries granted).
838 >       */
839 >      (*request->query->callback)(request->query->ptr, NULL);
840 >      rem_request(request);
841      }
844
842      return;
843    }
844    /*

Comparing:
ircd-hybrid/src/irc_res.c (property svn:keywords), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid-7.2/src/irc_res.c (property svn:keywords), Revision 982 by michael, Thu Aug 13 22:15:08 2009 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)