Changeset db6344


Ignore:
Timestamp:
2009-11-24 18:36:13 (4 years ago)
Author:
Poul-Henning Kamp <phk@…>
Branches:
master, 3.0, 4.0, experimental-ims
Children:
88de52
Parents:
d260cf5
git-author:
Poul-Henning Kamp <phk@…> (2009-11-24 18:36:13)
git-committer:
Poul-Henning Kamp <phk@…> (2009-11-24 18:36:13)
Message:

Define macros for the actual ip/port bound by the server and produce
the vcl based on same. This allows the port to be specified as
zero rather than a hardcoded number.

git-svn-id:  http://www.varnish-cache.org/svn/trunk/varnish-cache@4362 d4fa192b-c00b-0410-8231-f00ffab90ce4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bin/varnishtest/vtc_server.c

    r79a782 rdb6344  
    6666        char                    *addr; 
    6767        char                    *port; 
     68        char                    aaddr[32]; 
     69        char                    aport[32]; 
    6870 
    6971        pthread_t               tp; 
     
    9294        vl = vtc_logopen(s->name); 
    9395 
    94         vtc_log(vl, 2, "Started on %s", s->listen); 
     96        vtc_log(vl, 2, "Started on %s:%s", s->aaddr, s->aport); 
    9597        for (i = 0; i < s->repeat; i++) { 
    9698                if (s->repeat > 1) 
     
    106108                TCP_close(&fd); 
    107109        } 
     110        macro_def(s->vl, s->name, "addr", NULL); 
     111        macro_def(s->vl, s->name, "port", NULL); 
     112        macro_def(s->vl, s->name, "sock", NULL); 
    108113        vtc_log(vl, 2, "Ending"); 
    109114        return (NULL); 
     
    173178                s->sock = VSS_listen(s->vss_addr[0], s->depth); 
    174179                assert(s->sock >= 0); 
    175         } 
    176         vtc_log(s->vl, 3, "listen on %s (fd %d)", 
    177             s->listen, s->sock); 
     180                TCP_myname(s->sock, s->aaddr, sizeof s->aaddr, 
     181                    s->aport, sizeof s->aport); 
     182                macro_def(s->vl, s->name, "addr", "%s", s->aaddr); 
     183                macro_def(s->vl, s->name, "port", "%s", s->aport); 
     184                macro_def(s->vl, s->name, "sock", "%s:%s", s->aaddr, s->aport); 
     185        } 
     186        vtc_log(s->vl, 1, "Listen on %s:%s", s->addr, s->port); 
    178187        AZ(pthread_create(&s->tp, NULL, server_thread, s)); 
    179188} 
     
    211220                vsb_printf(vsb, 
    212221                    "backend %s { .host = \"%s\"; .port = \"%s\"; }\n", 
    213                     s->name, 
    214                     s->addr == NULL ? "127.0.0.1" : s->addr, 
    215                     s->port); 
     222                    s->name, s->aaddr, s->aport); 
    216223        } 
    217224} 
Note: See TracChangeset for help on using the changeset viewer.