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

Comparing ircd-hybrid/trunk/src/res.c (file contents):
Revision 4311 by michael, Thu Jul 31 17:02:13 2014 UTC vs.
Revision 4316 by michael, Thu Jul 31 20:46:32 2014 UTC

# Line 692 | Line 692 | res_readreply(fde_t *fd, void *data)
692    }
693  
694    /*
695 <   * If this fails there was an error decoding the received packet,
696 <   * try it again and hope it works the next time.
695 >   * If this fails there was an error decoding the received packet.
696 >   * We only give it one shot. If it fails, just leave the client
697 >   * unresolved.
698     */
699 <  if (proc_answer(request, header, buf, buf + rc))
699 >  if (!proc_answer(request, header, buf, buf + rc))
700    {
701 <    if (request->type == T_PTR)
702 <    {
703 <      if (request->name == NULL)
704 <      {
704 <        /*
705 <         * Got a PTR response with no name, something bogus is happening
706 <         * don't bother trying again, the client address doesn't resolve
707 <         */
708 <        (*request->callback)(request->callback_ctx, NULL, NULL);
709 <        rem_request(request);
710 <        return;
711 <      }
701 >    (*request->callback)(request->callback_ctx, NULL, NULL);
702 >    rem_request(request);
703 >    return;
704 >  }
705  
706 <      /*
707 <       * Lookup the 'authoritative' name that we were given for the ip#.
708 <       */
716 < #ifdef IPV6
717 <      if (request->addr.ss.ss_family == AF_INET6)
718 <        gethost_byname_type(request->callback, request->callback_ctx, request->name, T_AAAA);
719 <      else
720 < #endif
721 <      gethost_byname_type(request->callback, request->callback_ctx, request->name, T_A);
722 <      rem_request(request);
723 <    }
724 <    else
706 >  if (request->type == T_PTR)
707 >  {
708 >    if (request->name == NULL)
709      {
710        /*
711 <       * Got a name and address response, client resolved
711 >       * Got a PTR response with no name, something bogus is happening
712 >       * don't bother trying again, the client address doesn't resolve
713         */
714 <      (*request->callback)(request->callback_ctx, &request->addr, request->name);
714 >      (*request->callback)(request->callback_ctx, NULL, NULL);
715        rem_request(request);
716 +      return;
717      }
718 +
719 +    /*
720 +     * Lookup the 'authoritative' name that we were given for the ip#.
721 +     */
722 + #ifdef IPV6
723 +    if (request->addr.ss.ss_family == AF_INET6)
724 +      gethost_byname_type(request->callback, request->callback_ctx, request->name, T_AAAA);
725 +    else
726 + #endif
727 +    gethost_byname_type(request->callback, request->callback_ctx, request->name, T_A);
728 +    rem_request(request);
729    }
730 <  else if (!request->sent)
730 >  else
731    {
732 <    /* XXX - we got a response for a query we didn't send with a valid id?
733 <     * this should never happen, bail here and leave the client unresolved
732 >    /*
733 >     * Got a name and address response, client resolved
734       */
735 <    assert(0);
739 <
740 <    (*request->callback)(request->callback_ctx, NULL, NULL);
741 <    /* XXX don't leak it */
735 >    (*request->callback)(request->callback_ctx, &request->addr, request->name);
736      rem_request(request);
737    }
738   }

Diff Legend

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