Changeset 1460

Show
Ignore:
Timestamp:
11/27/2006 01:50:36 PM (22 months ago)
Author:
jan
Message:

fixed unix-domain socket support (fixes #912, patch from jakabosky)

- get the real address-length instead of the size of the struct-union
- fixes the connect()-error on BSDs
- enables unix:/... support

Location:
trunk/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/mod_indexfile.c

    r1349 r1460  
    206206                /* fce is already set up a few lines above */ 
    207207 
     208                /* need to reset condition cache since uri.path changed. */ 
     209                config_cond_cache_reset(srv, con); 
     210 
    208211                return HANDLER_GO_ON; 
    209212        } 
  • trunk/src/mod_proxy_core.c

    r1444 r1460  
    448448 
    449449        if (-1 == (fd = socket(con->address->addr.plain.sa_family, SOCK_STREAM, 0))) { 
     450                ERROR("socket failed: %s", strerror(errno)); 
     451                return HANDLER_ERROR; 
    450452        } 
    451453 
     
    456458        con->sock->type = IOSOCKET_TYPE_SOCKET; 
    457459 
    458         if (-1 == connect(fd, &(con->address->addr.plain), sizeof(con->address->addr))) { 
     460        if (-1 == connect(fd, &(con->address->addr.plain), con->address->addrlen)) { 
    459461                switch(errno) { 
    460462                case EINPROGRESS: 
     
    466468                        con->sock->fd = -1; 
    467469 
     470                        ERROR("connect failed: %s", strerror(errno)); 
    468471                        return HANDLER_ERROR; 
    469472                } 
     
    11901193                con->mode = p->id; 
    11911194 
     1195                if (con->conf.log_request_handling) { 
     1196                        ERROR("handling it in mod_proxy_core: uri.path=%s", BUF_STR(con->uri.path)); 
     1197                } 
    11921198                sess->remote_con = con; 
    11931199        } 
     
    15611567        p->set_defaults = mod_proxy_core_set_defaults; 
    15621568        p->handle_physical         = mod_proxy_core_check_extension; 
     1569        p->handle_start_backend = mod_proxy_core_check_extension; 
    15631570        p->handle_send_request_content = mod_proxy_send_request_content; 
    15641571        p->handle_read_response_content = mod_proxy_core_start_backend; 
  • trunk/src/mod_proxy_core_address.c

    r1422 r1460  
    9898        if (0 == strncmp(BUF_STR(name), "unix:", 5)) { 
    9999                /* a unix domain socket */ 
     100#ifdef HAVE_SYS_UN_H 
     101                proxy_address *a = proxy_address_init(); 
     102 
     103                /* setup AF_UNIX sockaddr */ 
     104                a->addr.un.sun_family = AF_UNIX; 
     105                strcpy(a->addr.un.sun_path, BUF_STR(name) + 5); 
     106                a->addrlen = sizeof(a->addr.un); 
     107/* 
     108#ifdef SUN_LEN 
     109                a->addrlen = SUN_LEN(&(a->addr.un)); 
     110#else 
     111                a->addrlen = (name->used - 5) + sizeof(a->addr.un.sun_family); 
     112#endif 
     113*/ 
     114 
     115                a->state = PROXY_ADDRESS_STATE_ACTIVE; 
     116                buffer_copy_string_buffer(a->name, name); 
     117 
     118                proxy_address_pool_add(address_pool, a); 
     119                return 0; 
     120#else 
    100121                ERROR("unix: scheme is not supported for %s", BUF_STR(name)); 
    101122                return -1; 
     123#endif 
    102124        } else if (name->ptr[0] == '[') { 
    103125                if (name->ptr[name->used - 1] == ']') { 
     
    152174 
    153175                memcpy(&(a->addr), cur->ai_addr, cur->ai_addrlen); 
     176                a->addrlen = cur->ai_addrlen; 
    154177 
    155178                a->state = PROXY_ADDRESS_STATE_ACTIVE; 
  • trunk/src/mod_proxy_core_address.h

    r1422 r1460  
    1515typedef struct { 
    1616        sock_addr addr; 
     17        socklen_t addrlen; 
    1718 
    1819        buffer *name; /* a inet_ntoa() prepresentation of the address */