Changeset c4cd7bd


Ignore:
Timestamp:
2009-11-19 12:40:23 (4 years ago)
Author:
Poul-Henning Kamp <phk@…>
Branches:
master, 3.0, 4.0, experimental-ims
Children:
e3207f
Parents:
1e1d24b
git-author:
Poul-Henning Kamp <phk@…> (2009-11-19 12:40:23)
git-committer:
Poul-Henning Kamp <phk@…> (2009-11-19 12:40:23)
Message:

Don't halfclose the backend polling TCP connection after sending the
request, some backends gets confused by this.

Add a ".status" to backend polling, to configure the expected HTTP
status code for a good poll.

Fixes #584

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

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • bin/varnishd/cache_backend_poll.c

    r91d802 rc4cd7bd  
    174174        } 
    175175        vt->good_xmit |= 1; 
    176  
    177         /* And do a shutdown(WR) so we know that the backend got it */ 
    178         i = shutdown(s, SHUT_WR); 
    179         if (i != 0) { 
    180                 vt->err_shut |= 1; 
    181                 TCP_close(&s); 
    182                 return; 
    183         } 
    184         vt->good_shut |= 1; 
    185  
    186         /* Check if that took too long time */ 
    187         t_now = TIM_real(); 
    188         tmo = (int)round((t_end - t_now) * 1e3); 
    189         if (tmo < 0) { 
    190                 TCP_close(&s); 
    191                 return; 
    192         } 
    193176 
    194177        pfd->fd = s; 
     
    238221        i = sscanf(vt->resp_buf, "HTTP/%*f %u %s", &resp, buf); 
    239222 
    240         if (i == 2 && resp == 200) 
     223        if (i == 2 && resp == vt->probe.exp_status) 
    241224                vt->happy |= 1; 
    242225} 
     
    337320        if (vt->probe.threshold == 0) 
    338321                vt->probe.threshold = 3; 
     322        if (vt->probe.exp_status == 0) 
     323                vt->probe.exp_status = 200; 
    339324 
    340325        if (vt->probe.threshold == ~0U) 
  • bin/varnishd/cache_backend_poll.h

    r1cc48fa rc4cd7bd  
    3434BITMAP( err_xmit, 'x', "Error Xmit", 0) 
    3535BITMAP(good_xmit, 'X', "Good Xmit", 0) 
    36 BITMAP( err_shut, 's', "Error Shut", 0) 
    37 BITMAP(good_shut, 'S', "Good Shut", 0) 
    3836BITMAP( err_recv, 'r', "Error Recv", 0) 
    3937BITMAP(good_recv, 'R', "Good Recv", 0) 
  • bin/varnishtest/tests/v00002.vtc

    r9e214d rc4cd7bd  
    186186} 
    187187 
     188 
     189varnish v1 -badvcl { 
     190        backend b1 { 
     191                .host = "127.0.0.1"; 
     192                .probe = { .status = 13; } 
     193        } 
     194} 
     195 
  • bin/varnishtest/tests/v00005.vtc

    r077c5d rc4cd7bd  
    22 
    33test "VCL: test backend probe syntax" 
     4 
     5# Check status definition 
     6varnish v1 -vcl { 
     7        backend b1 { 
     8                .host = "127.0.0.1"; 
     9                .probe = { 
     10                        .status = 204; 
     11                } 
     12        } 
     13} 
    414 
    515# Check url definition 
  • include/vrt.h

    r187313 rc4cd7bd  
    5353        double          timeout; 
    5454        double          interval; 
     55        unsigned        exp_status; 
    5556        unsigned        window; 
    5657        unsigned        threshold; 
  • lib/libvcl/vcc_backend.c

    r187313 rc4cd7bd  
    344344        struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL; 
    345345        struct token *t_initial = NULL; 
    346         unsigned window, threshold, initial; 
     346        unsigned window, threshold, initial, status; 
    347347 
    348348        fs = vcc_FldSpec(tl, 
    349349            "?url", 
    350350            "?request", 
     351            "?status", 
    351352            "?timeout", 
    352353            "?interval", 
     
    362363        threshold = 0; 
    363364        initial = 0; 
     365        status = 0; 
    364366        Fb(tl, 0, "\t.probe = {\n"); 
    365367        while (tl->t->tok != '}') { 
     
    405407                        t_initial = tl->t; 
    406408                        initial = vcc_UintVal(tl); 
     409                        vcc_NextToken(tl); 
     410                        ERRCHK(tl); 
     411                } else if (vcc_IdIs(t_field, "status")) { 
     412                        status = vcc_UintVal(tl); 
     413                        if (status < 100 || status > 999) { 
     414                                vsb_printf(tl->sb, 
     415                                    "Must specify .status with exactly three " 
     416                                    " digits (100 <= x <= 999)\n"); 
     417                                vcc_ErrWhere(tl, tl->t); 
     418                                return; 
     419                        } 
    407420                        vcc_NextToken(tl); 
    408421                        ERRCHK(tl); 
     
    458471        else 
    459472                Fb(tl, 0, "\t\t.initial = ~0U,\n", initial); 
     473        if (status > 0) 
     474                Fb(tl, 0, "\t\t.exp_status = %u,\n", status); 
    460475        Fb(tl, 0, "\t},\n"); 
    461476        ExpectErr(tl, '}'); 
  • lib/libvcl/vcc_fixed_token.c

    r187313 rc4cd7bd  
    11/* 
    2  * $Id$ 
     2 * $Id: vcc_gen_fixed_token.tcl 4236 2009-09-14 08:47:03Z phk $ 
    33 * 
    44 * NB:  This file is machine generated, DO NOT EDIT! 
     
    160160        /* ../../include/vcl.h */ 
    161161 
    162         vsb_cat(sb, "/*\n * $Id$\n *\n * NB:  This file is machine generate"); 
    163         vsb_cat(sb, "d, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_tok"); 
    164         vsb_cat(sb, "en.tcl instead\n */\n\nstruct sess;\n"); 
     162        vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4236 2009-09-14 08"); 
     163        vsb_cat(sb, ":47:03Z phk $\n *\n * NB:  This file is machine genera"); 
     164        vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t"); 
     165        vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sess;\n"); 
    165166        vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n"); 
    166167        vsb_cat(sb, "typedef void vcl_fini_f(struct cli *);\n"); 
     
    228229        vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT"); 
    229230        vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n"); 
    230         vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id$\n *\n"); 
    231         vsb_cat(sb, " * Runtime support for compiled VCL programs.\n"); 
    232         vsb_cat(sb, " *\n * XXX: When this file is changed, lib/libvcl/vcc_"); 
    233         vsb_cat(sb, "gen_fixed_token.tcl\n * XXX: *MUST* be rerun.\n"); 
    234         vsb_cat(sb, " */\n\nstruct sess;\nstruct vsb;\n"); 
    235         vsb_cat(sb, "struct cli;\nstruct director;\n"); 
    236         vsb_cat(sb, "struct VCL_conf;\nstruct sockaddr;\n"); 
    237         vsb_cat(sb, "\n/*\n * A backend probe specification\n"); 
    238         vsb_cat(sb, " */\n\nextern const void * const vrt_magic_string_end;"); 
    239         vsb_cat(sb, "\n\nstruct vrt_backend_probe {\n"); 
     231        vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 4336 2009-10-21 11:"); 
     232        vsb_cat(sb, "36:28Z kristian $\n *\n * Runtime support for compiled"); 
     233        vsb_cat(sb, " VCL programs.\n *\n * XXX: When this file is changed,"); 
     234        vsb_cat(sb, " lib/libvcl/vcc_gen_fixed_token.tcl\n"); 
     235        vsb_cat(sb, " * XXX: *MUST* be rerun.\n */\n"); 
     236        vsb_cat(sb, "\nstruct sess;\nstruct vsb;\nstruct cli;\n"); 
     237        vsb_cat(sb, "struct director;\nstruct VCL_conf;\n"); 
     238        vsb_cat(sb, "struct sockaddr;\n\n/*\n * A backend probe specificati"); 
     239        vsb_cat(sb, "on\n */\n\nextern const void * const vrt_magic_string_"); 
     240        vsb_cat(sb, "end;\n\nstruct vrt_backend_probe {\n"); 
    240241        vsb_cat(sb, "\tconst char\t*url;\n\tconst char\t*request;\n"); 
    241242        vsb_cat(sb, "\tdouble\t\ttimeout;\n\tdouble\t\tinterval;\n"); 
    242         vsb_cat(sb, "\tunsigned\twindow;\n\tunsigned\tthreshold;\n"); 
    243         vsb_cat(sb, "\tunsigned\tinitial;\n};\n\n/*\n"); 
    244         vsb_cat(sb, " * A backend is a host+port somewhere on the network\n"); 
    245         vsb_cat(sb, " */\nstruct vrt_backend {\n\tconst char\t\t\t*vcl_name"); 
    246         vsb_cat(sb, ";\n\tconst char\t\t\t*ident;\n\n"); 
    247         vsb_cat(sb, "\tconst char\t\t\t*hosthdr;\n\n"); 
    248         vsb_cat(sb, "\tconst unsigned char\t\t*ipv4_sockaddr;\n"); 
     243        vsb_cat(sb, "\tunsigned\texp_status;\n\tunsigned\twindow;\n"); 
     244        vsb_cat(sb, "\tunsigned\tthreshold;\n\tunsigned\tinitial;\n"); 
     245        vsb_cat(sb, "};\n\n/*\n * A backend is a host+port somewhere on the"); 
     246        vsb_cat(sb, " network\n */\nstruct vrt_backend {\n"); 
     247        vsb_cat(sb, "\tconst char\t\t\t*vcl_name;\n\tconst char\t\t\t*ident"); 
     248        vsb_cat(sb, ";\n\n\tconst char\t\t\t*hosthdr;\n"); 
     249        vsb_cat(sb, "\n\tconst unsigned char\t\t*ipv4_sockaddr;\n"); 
    249250        vsb_cat(sb, "\tconst unsigned char\t\t*ipv6_sockaddr;\n"); 
    250251        vsb_cat(sb, "\n\tdouble\t\t\t\tconnect_timeout;\n"); 
     
    319320        /* ../../include/vrt_obj.h */ 
    320321 
    321         vsb_cat(sb, "/*\n * $Id$\n *\n * NB:  This file is machine generate"); 
    322         vsb_cat(sb, "d, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_tok"); 
    323         vsb_cat(sb, "en.tcl instead\n */\n\nstruct sockaddr * VRT_r_client_"); 
    324         vsb_cat(sb, "ip(const struct sess *);\nstruct sockaddr * VRT_r_serv"); 
    325         vsb_cat(sb, "er_ip(struct sess *);\nconst char * VRT_r_server_hostn"); 
    326         vsb_cat(sb, "ame(struct sess *);\nconst char * VRT_r_server_identit"); 
    327         vsb_cat(sb, "y(struct sess *);\nint VRT_r_server_port(struct sess *"); 
    328         vsb_cat(sb, ");\nconst char * VRT_r_req_request(const struct sess *"); 
    329         vsb_cat(sb, ");\nvoid VRT_l_req_request(const struct sess *, const "); 
    330         vsb_cat(sb, "char *, ...);\nconst char * VRT_r_req_url(const struct"); 
    331         vsb_cat(sb, " sess *);\nvoid VRT_l_req_url(const struct sess *, con"); 
    332         vsb_cat(sb, "st char *, ...);\nconst char * VRT_r_req_proto(const s"); 
    333         vsb_cat(sb, "truct sess *);\nvoid VRT_l_req_proto(const struct sess"); 
    334         vsb_cat(sb, " *, const char *, ...);\nvoid VRT_l_req_hash(struct se"); 
    335         vsb_cat(sb, "ss *, const char *);\nstruct director * VRT_r_req_back"); 
    336         vsb_cat(sb, "end(struct sess *);\nvoid VRT_l_req_backend(struct ses"); 
    337         vsb_cat(sb, "s *, struct director *);\nint VRT_r_req_restarts(const"); 
    338         vsb_cat(sb, " struct sess *);\ndouble VRT_r_req_grace(struct sess *"); 
    339         vsb_cat(sb, ");\nvoid VRT_l_req_grace(struct sess *, double);\n"); 
     322        vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4236 2009-09-14 08"); 
     323        vsb_cat(sb, ":47:03Z phk $\n *\n * NB:  This file is machine genera"); 
     324        vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t"); 
     325        vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sockaddr * VRT_r_clien"); 
     326        vsb_cat(sb, "t_ip(const struct sess *);\nstruct sockaddr * VRT_r_se"); 
     327        vsb_cat(sb, "rver_ip(struct sess *);\nconst char * VRT_r_server_hos"); 
     328        vsb_cat(sb, "tname(struct sess *);\nconst char * VRT_r_server_ident"); 
     329        vsb_cat(sb, "ity(struct sess *);\nint VRT_r_server_port(struct sess"); 
     330        vsb_cat(sb, " *);\nconst char * VRT_r_req_request(const struct sess"); 
     331        vsb_cat(sb, " *);\nvoid VRT_l_req_request(const struct sess *, cons"); 
     332        vsb_cat(sb, "t char *, ...);\nconst char * VRT_r_req_url(const stru"); 
     333        vsb_cat(sb, "ct sess *);\nvoid VRT_l_req_url(const struct sess *, c"); 
     334        vsb_cat(sb, "onst char *, ...);\nconst char * VRT_r_req_proto(const"); 
     335        vsb_cat(sb, " struct sess *);\nvoid VRT_l_req_proto(const struct se"); 
     336        vsb_cat(sb, "ss *, const char *, ...);\nvoid VRT_l_req_hash(struct "); 
     337        vsb_cat(sb, "sess *, const char *);\nstruct director * VRT_r_req_ba"); 
     338        vsb_cat(sb, "ckend(struct sess *);\nvoid VRT_l_req_backend(struct s"); 
     339        vsb_cat(sb, "ess *, struct director *);\nint VRT_r_req_restarts(con"); 
     340        vsb_cat(sb, "st struct sess *);\ndouble VRT_r_req_grace(struct sess"); 
     341        vsb_cat(sb, " *);\nvoid VRT_l_req_grace(struct sess *, double);\n"); 
    340342        vsb_cat(sb, "const char * VRT_r_req_xid(struct sess *);\n"); 
    341343        vsb_cat(sb, "unsigned VRT_r_req_esi(struct sess *);\n"); 
  • lib/libvcl/vcc_obj.c

    reb05da5 rc4cd7bd  
    11/* 
    2  * $Id$ 
     2 * $Id: vcc_gen_fixed_token.tcl 4236 2009-09-14 08:47:03Z phk $ 
    33 * 
    44 * NB:  This file is machine generated, DO NOT EDIT! 
Note: See TracChangeset for help on using the changeset viewer.