httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/modules/metadata mod_unique_id.c
Date Mon, 19 Nov 2001 13:48:58 GMT
trawick     01/11/19 05:48:58

  Modified:    .        CHANGES STATUS
               modules/metadata mod_unique_id.c
  Log:
  APR-ize the resolver logic in mod_unique_id.  This fixes a bug
  in logging the error from a failed DNS lookup.
  
  Note: For a funky error scenario to work right (huge host name),
  this requires a tweak to apr_gethostname() which I have not yet
  committed.
  
  Revision  Changes    Path
  1.442     +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.441
  retrieving revision 1.442
  diff -u -r1.441 -r1.442
  --- CHANGES	2001/11/18 05:50:42	1.441
  +++ CHANGES	2001/11/19 13:48:57	1.442
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0.29-dev
   
  +  *) APR-ize the resolver logic in mod_unique_id.  This fixes a bug
  +     in logging the error from a failed DNS lookup.  [Jeff Trawick]
  +
     *) Added the missing macros AP_INIT_TAKE13 and AP_INIT_TAKE123.
        [Cliff Woolley]
   
  
  
  
  1.337     +1 -3      httpd-2.0/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/STATUS,v
  retrieving revision 1.336
  retrieving revision 1.337
  diff -u -r1.336 -r1.337
  --- STATUS	2001/11/17 14:02:25	1.336
  +++ STATUS	2001/11/19 13:48:57	1.337
  @@ -1,5 +1,5 @@
   APACHE 2.0 STATUS:						-*-text-*-
  -Last modified at [$Date: 2001/11/17 14:02:25 $]
  +Last modified at [$Date: 2001/11/19 13:48:57 $]
   
   Release:
   
  @@ -291,8 +291,6 @@
         into a VirtualHost container) to 2.0.
   
       * shift stuff to mod_core.h
  -
  -    * APR-ize resolver stuff in mod_unique_id (Jeff volunteers)
   
       * callers of ap_run_create_request() should check the return value
         for failure (Doug volunteers)
  
  
  
  1.32      +18 -21    httpd-2.0/modules/metadata/mod_unique_id.c
  
  Index: mod_unique_id.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_unique_id.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- mod_unique_id.c	2001/11/18 13:22:59	1.31
  +++ mod_unique_id.c	2001/11/19 13:48:57	1.32
  @@ -64,20 +64,15 @@
    */
   
   #include "apr_general.h"    /* for APR_XtOffsetOf                */
  +#include "apr_network_io.h"
   
   #include "httpd.h"
   #include "http_config.h"
   #include "http_log.h"
   #include "http_protocol.h"  /* for ap_hook_post_read_request */
   
  -#if APR_HAVE_NETDB_H
  -#include <netdb.h>
  -#endif
  -#if APR_HAVE_ARPA_INET_H
  -#include <arpa/inet.h>
  -#endif
   #if APR_HAVE_UNISTD_H
  -#include <unistd.h>
  +#include <unistd.h>         /* for getpid() */
   #endif
   
   typedef struct {
  @@ -177,12 +172,11 @@
   
   static void unique_id_global_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec
*main_server)
   {
  -#ifndef MAXHOSTNAMELEN
  -#define MAXHOSTNAMELEN 256
  -#endif
  -    char str[MAXHOSTNAMELEN + 1];
  -    struct hostent *hent;
  +    char str[APRMAXHOSTLEN + 1];
       apr_short_interval_time_t pause;
  +    apr_status_t rv;
  +    char *ipaddrstr;
  +    apr_sockaddr_t *sockaddr;
   
       /*
        * Calculate the sizes and offsets in cur_unique_id.
  @@ -211,24 +205,27 @@
        * of the addresses from the main_server, since those aren't as likely to
        * be unique as the physical address of the machine
        */
  -    if (gethostname(str, sizeof(str) - 1) != 0) {
  -        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, errno, main_server,
  -          "gethostname: mod_unique_id requires the hostname of the server");
  +    if ((rv = apr_gethostname(str, sizeof(str) - 1, p)) != APR_SUCCESS) {
  +        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server,
  +          "mod_unique_id: unable to find hostname of the server");
           exit(1);
       }
  -    str[sizeof(str) - 1] = '\0';
   
  -    if ((hent = gethostbyname(str)) == NULL) {
  -        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, h_errno, main_server,
  -                    "mod_unique_id: unable to gethostbyname(\"%s\")", str);
  +    /* XXX theoretically there are boxes out there which want to use
  +     *     mod_unique_id but which have no IPv4 address...  send in a patch :)
  +     */
  +    if ((rv = apr_sockaddr_info_get(&sockaddr, str, AF_INET, 0, 0, p)) != APR_SUCCESS)
{
  +        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, main_server,
  +                    "mod_unique_id: unable to find IPv4 address of \"%s\"", str);
           exit(1);
       }
   
  -    global_in_addr = ((struct in_addr *) hent->h_addr_list[0])->s_addr;
  +    global_in_addr = sockaddr->sa.sin.sin_addr.s_addr;
   
  +    apr_sockaddr_ip_get(&ipaddrstr, sockaddr);
       ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, main_server,
                   "mod_unique_id: using ip addr %s",
  -                inet_ntoa(*(struct in_addr *) hent->h_addr_list[0]));
  +                 ipaddrstr);
   
       /*
        * If the server is pummelled with restart requests we could possibly end
  
  
  

Mime
View raw message